Skip to content

Commit 827c9b1

Browse files
Bump no.nav.dagpenger:dp-version-catalog from 20240918.87.a55420 to 20241125.106.f5f8a9 (#259)
* Bump no.nav.dagpenger:dp-version-catalog Bumps no.nav.dagpenger:dp-version-catalog from 20240918.87.a55420 to 20241125.106.f5f8a9. --- updated-dependencies: - dependency-name: no.nav.dagpenger:dp-version-catalog dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * Fjernet deprekerte ktor funksjoner. --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Geir A. Lund <[email protected]>
1 parent 466dda5 commit 827c9b1

File tree

6 files changed

+16
-33
lines changed

6 files changed

+16
-33
lines changed

dp-inntekt-api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ dependencies {
7070
implementation("no.bekk.bekkopen:nocommons:0.16.0")
7171

7272
implementation("com.uchuhimo:kotlinx-bimap:1.2")
73-
implementation(libs.dp.biblioteker.oauth2.klient)
73+
implementation("no.nav.dagpenger:oauth2-klient:2024.10.31-15.02.1d4f08a38d24")
7474

7575
testImplementation(kotlin("test"))
7676
testImplementation(libs.ktor.server.test.host)

dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/InntektApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import io.ktor.server.metrics.micrometer.MicrometerMetrics
1919
import io.ktor.server.plugins.BadRequestException
2020
import io.ktor.server.plugins.callid.CallId
2121
import io.ktor.server.plugins.callid.callIdMdc
22-
import io.ktor.server.plugins.callloging.CallLogging
22+
import io.ktor.server.plugins.calllogging.CallLogging
2323
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
2424
import io.ktor.server.plugins.defaultheaders.DefaultHeaders
2525
import io.ktor.server.plugins.statuspages.StatusPages

dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/v1/UklassifisertInntektRoute.kt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import io.ktor.server.routing.Route
1414
import io.ktor.server.routing.get
1515
import io.ktor.server.routing.post
1616
import io.ktor.server.routing.route
17-
import io.ktor.util.pipeline.PipelineContext
1817
import io.prometheus.client.Counter
1918
import kotlinx.coroutines.Dispatchers
2019
import kotlinx.coroutines.withContext
@@ -60,7 +59,7 @@ fun Route.uklassifisertInntekt(
6059
route("/uklassifisert/{aktørId}/{kontekstType}/{kontekstId}/{beregningsDato}") {
6160
get {
6261
withContext(Dispatchers.IO) {
63-
withInntektRequest("GET /uklassifisert/") {
62+
call.withInntektRequest("GET /uklassifisert/") {
6463
val person = personOppslag.hentPerson(this.aktørId)
6564
inntektStore.getInntektId(
6665
Inntektparametre(
@@ -82,7 +81,7 @@ fun Route.uklassifisertInntekt(
8281
}
8382
post {
8483
withContext(Dispatchers.IO) {
85-
withInntektRequest("POST /uklassifisert/") {
84+
call.withInntektRequest("POST /uklassifisert/") {
8685
val person = personOppslag.hentPerson(this.aktørId)
8786
val guiInntekt = call.receive<GUIInntekt>()
8887
mapToStoredInntekt(guiInntekt).let {
@@ -99,7 +98,7 @@ fun Route.uklassifisertInntekt(
9998
manueltRedigert =
10099
ManueltRedigert.from(
101100
guiInntekt.redigertAvSaksbehandler,
102-
getSubject(),
101+
call.getSubject(),
103102
),
104103
),
105104
)
@@ -124,7 +123,7 @@ fun Route.uklassifisertInntekt(
124123
get {
125124
val callId = call.callId
126125
withContext(Dispatchers.IO) {
127-
withInntektRequest("GET /uklassifisert/uncached/") {
126+
call.withInntektRequest("GET /uklassifisert/uncached/") {
128127
val person = personOppslag.hentPerson(this.aktørId)
129128
val opptjeningsperiode = Opptjeningsperiode(this.beregningsDato)
130129
toInntektskomponentRequest(person, opptjeningsperiode).let {
@@ -146,7 +145,7 @@ fun Route.uklassifisertInntekt(
146145

147146
post {
148147
withContext(Dispatchers.IO) {
149-
withInntektRequest("POST /uklassifisert/uncached/") {
148+
call.withInntektRequest("POST /uklassifisert/uncached/") {
150149
val guiInntekt = call.receive<GUIInntekt>()
151150
val person = personOppslag.hentPerson(this.aktørId)
152151
mapToDetachedInntekt(guiInntekt).let {
@@ -163,7 +162,7 @@ fun Route.uklassifisertInntekt(
163162
manueltRedigert =
164163
ManueltRedigert.from(
165164
guiInntekt.redigertAvSaksbehandler,
166-
getSubject(),
165+
call.getSubject(),
167166
),
168167
),
169168
)
@@ -193,27 +192,27 @@ fun Route.uklassifisertInntekt(
193192
}
194193
}
195194

196-
private fun PipelineContext<Unit, ApplicationCall>.getSubject(): String {
195+
private fun ApplicationCall.getSubject(): String {
197196
return runCatching {
198-
call.authentication.principal<JWTPrincipal>()?.payload?.subject
197+
this.authentication.principal<JWTPrincipal>()?.payload?.subject
199198
?: throw JWTDecodeException("Unable to get subject from JWT")
200199
}.getOrElse {
201200
logger.error(it) { "Unable to get subject" }
202201
return@getOrElse "UNKNOWN"
203202
}
204203
}
205204

206-
private inline fun PipelineContext<Unit, ApplicationCall>.withInntektRequest(
205+
private inline fun ApplicationCall.withInntektRequest(
207206
route: String,
208207
block: InntektRequest.() -> Unit,
209208
) {
210209
val inntektRequest =
211210
runCatching {
212211
InntektRequest(
213-
aktørId = call.parameters["aktørId"]!!,
214-
kontekstId = call.parameters["kontekstId"]!!,
215-
kontekstType = call.parameters["kontekstType"]!!,
216-
beregningsDato = LocalDate.parse(call.parameters["beregningsDato"]!!),
212+
aktørId = this.parameters["aktørId"]!!,
213+
kontekstId = this.parameters["kontekstId"]!!,
214+
kontekstType = this.parameters["kontekstType"]!!,
215+
beregningsDato = LocalDate.parse(this.parameters["beregningsDato"]!!),
217216
)
218217
}.getOrElse { t -> throw IllegalArgumentException("Failed to parse parameters", t) }
219218

dp-inntekt-api/src/test/kotlin/no/nav/dagpenger/inntekt/v1/InntektRouteSpec.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import io.ktor.client.statement.bodyAsText
1212
import io.ktor.http.HttpHeaders
1313
import io.ktor.http.HttpMethod
1414
import io.ktor.http.HttpStatusCode
15-
import io.ktor.server.testing.setBody
1615
import io.mockk.coEvery
1716
import io.mockk.coVerify
1817
import io.mockk.mockk

dp-inntekt-api/src/test/kotlin/no/nav/dagpenger/inntekt/v1/TestApplication.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import io.ktor.http.HttpMethod
1313
import io.ktor.http.content.TextContent
1414
import io.ktor.server.application.Application
1515
import io.ktor.server.testing.ApplicationTestBuilder
16-
import io.ktor.server.testing.TestApplicationCall
17-
import io.ktor.server.testing.TestApplicationEngine
18-
import io.ktor.server.testing.TestApplicationRequest
19-
import io.ktor.server.testing.handleRequest
2016
import io.ktor.server.testing.testApplication
2117
import io.mockk.mockk
2218
import io.prometheus.client.CollectorRegistry
@@ -106,15 +102,4 @@ internal object TestApplication {
106102
this.header("X-Request-Id", it)
107103
}
108104
}
109-
110-
internal fun TestApplicationEngine.handleAuthenticatedAzureAdRequest(
111-
method: HttpMethod,
112-
uri: String,
113-
test: TestApplicationRequest.() -> Unit = {},
114-
): TestApplicationCall {
115-
return this.handleRequest(method, uri) {
116-
addHeader("Authorization", "Bearer $testOAuthToken")
117-
test()
118-
}
119-
}
120105
}

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencyResolutionManagement {
1919
}
2020
versionCatalogs {
2121
create("libs") {
22-
from("no.nav.dagpenger:dp-version-catalog:20240918.87.a55420")
22+
from("no.nav.dagpenger:dp-version-catalog:20241125.106.f5f8a9")
2323
}
2424
}
2525
}

0 commit comments

Comments
 (0)