Skip to content

Commit

Permalink
Fikse mangler med vedtak api (#6864)
Browse files Browse the repository at this point in the history
* Legger til auth i swagger

* vedtakklient i etterlatte-api mangler contentType

* Feil url i vedtaksklient

* Uthenting av vedtak med fnr uten spesifisert saktype fungerte ikke

* Rydde i test
  • Loading branch information
Bjodn authored Jan 27, 2025
1 parent 804aa72 commit 651ec52
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import io.ktor.client.plugins.ClientRequestException
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import io.ktor.client.request.url
import io.ktor.http.ContentType
import io.ktor.http.HttpStatusCode
import io.ktor.http.contentType
import no.nav.etterlatte.libs.common.feilhaandtering.IkkeFunnetException
import no.nav.etterlatte.libs.common.feilhaandtering.IkkeTillattException
import no.nav.etterlatte.libs.common.feilhaandtering.InternfeilException
Expand All @@ -23,7 +25,7 @@ class VedtaksvurderingKlient(
) {
private val logger = LoggerFactory.getLogger(VedtaksvurderingKlient::class.java)

private val vedtaksvurderingUrl = "${config.getString("vedtak.url")}/api/vedtak/for/eksternt"
private val vedtaksvurderingUrl = "${config.getString("vedtak.url")}/vedtak/fnr"

suspend fun hentVedtak(request: Folkeregisteridentifikator): List<VedtakDto> {
sikkerlogger().info("Henter vedtak med fnr=$request")
Expand All @@ -32,6 +34,7 @@ class VedtaksvurderingKlient(
httpClient
.post {
url(vedtaksvurderingUrl)
contentType(ContentType.Application.Json)
setBody(request)
}.body()
} catch (e: ClientRequestException) {
Expand Down
14 changes: 13 additions & 1 deletion apps/etterlatte-api/src/main/resources/vedtakSwaggerV1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ servers:
- url: https://etterlatte-api.intern.dev.nav.no/api/v1
- url: https://etterlatte-api.intern.prod.nav.no/api/v1

security:
- BearerAuth: []

paths:
/vedtak:
post:
Expand Down Expand Up @@ -91,4 +94,13 @@ components:
beloep:
type: string
format: decimal
description: BigDecimal
description: BigDecimal

securitySchemes:
BearerAuth:
type: http
description: "Legg til token uten Bearer prefiks"
name: bearerAuth
in: header
scheme: bearer
bearerFormat: JWT
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,7 @@ class VedtaksvurderingRepository(

fun hentFerdigstilteVedtak(
fnr: Folkeregisteridentifikator,
sakType: SakType,
tx: TransactionalSession? = null,
): List<Vedtak> = hentFerdigstilteVedtak(fnr, listOf(sakType), tx)

fun hentFerdigstilteVedtak(
fnr: Folkeregisteridentifikator,
sakType: List<SakType> = listOf(SakType.BARNEPENSJON, SakType.OMSTILLINGSSTOENAD),
sakType: SakType? = null,
tx: TransactionalSession? = null,
): List<Vedtak> {
val hentVedtak = """
Expand All @@ -334,16 +328,16 @@ class VedtaksvurderingRepository(
attestertVedtakEnhet, fattetVedtakEnhet, type, revurderingsaarsak, revurderinginfo, opphoer_fom
FROM vedtak
WHERE fnr = :fnr
AND saktype in (:saktype)
AND vedtakstatus in ('TIL_SAMORDNING', 'SAMORDNET', 'IVERKSATT')
${if (sakType == null) "" else "AND saktype = :saktype"}
"""
return tx.session {
hentListe(
queryString = hentVedtak,
params = {
mapOf(
"fnr" to fnr.value,
"saktype" to sakType.joinToString { it.name },
"saktype" to sakType?.name,
)
},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,4 +465,23 @@ internal class VedtaksvurderingRepositoryTest(
it.soeker shouldBe soeker2
}
}

@Test
fun `skal hente vedtak for fnr selv om ikke saktype er spesifisert`() {
val soeker1 = Folkeregisteridentifikator.of(FNR_1)

val vedtak =
opprettVedtak(
sakId = SakId(10),
soeker = soeker1,
virkningstidspunkt = YearMonth.of(2024, Month.JANUARY),
status = VedtakStatus.IVERKSATT,
)
repository.opprettVedtak(vedtak)
repository.iverksattVedtak(vedtak.behandlingId)

val results = repository.hentFerdigstilteVedtak(soeker1)

results.size shouldBe 1
}
}

0 comments on commit 651ec52

Please sign in to comment.