diff --git a/apps/tilgangskontroll/build.gradle.kts b/apps/tilgangskontroll/build.gradle.kts index 0eb4b3f0..afa230b1 100644 --- a/apps/tilgangskontroll/build.gradle.kts +++ b/apps/tilgangskontroll/build.gradle.kts @@ -44,7 +44,7 @@ dependencies { implementation(libs.jackson.datatypeJsr310) implementation(libs.ktor3.server.coreJvm) implementation(libs.ktor3.server.openapi) - testImplementation(libs.ktor.server.testJvm) + testImplementation(libs.ktor3.server.test.host) testImplementation(libs.test.junit5.runner) testImplementation(libs.test.kotest.assertionsCore) testImplementation(libs.test.mockOauth2Server) diff --git a/apps/tilgangskontroll/src/test/kotlin/no/nav/paw/tilgangskontroll/TilgangskontrollTest.kt b/apps/tilgangskontroll/src/test/kotlin/no/nav/paw/tilgangskontroll/TilgangskontrollTest.kt index f22540bd..906ffa91 100644 --- a/apps/tilgangskontroll/src/test/kotlin/no/nav/paw/tilgangskontroll/TilgangskontrollTest.kt +++ b/apps/tilgangskontroll/src/test/kotlin/no/nav/paw/tilgangskontroll/TilgangskontrollTest.kt @@ -8,12 +8,15 @@ import io.kotest.core.spec.style.FreeSpec import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.ktor.client.call.body -import io.ktor.client.plugins.contentnegotiation.ContentNegotiation import io.ktor.client.plugins.defaultRequest import io.ktor.client.request.bearerAuth +import io.ktor.client.request.headers import io.ktor.client.request.post import io.ktor.client.request.setBody +import io.ktor.http.ContentType +import io.ktor.http.HttpHeaders import io.ktor.http.HttpStatusCode +import io.ktor.http.append import io.ktor.serialization.jackson.jackson import io.ktor.server.application.Application import io.ktor.server.auth.authenticate @@ -55,12 +58,12 @@ class TilgangskontrollTest: FreeSpec({ } } - "Verifiser applikasjonsflyt".config(enabled = false) { + "Verifiser applikasjonsflyt".config(enabled = true) { val ansatt = NavAnsatt(UUID.randomUUID(), "Z123") val person = Identitetsnummer("12345678901") val token = mockOAuthServer.ansattToken(ansatt) map[Triple(EntraId(ansatt.azureId), person, Tilgang.LESE)] = true - map[Triple(EntraId(ansatt.azureId), person, Tilgang.SKRIVE)] = true + map[Triple(EntraId(ansatt.azureId), person, Tilgang.SKRIVE)] = false testApplication { application { configureAuthentication(mockOAuthServer, AuthProvider.EntraId) @@ -75,6 +78,9 @@ class TilgangskontrollTest: FreeSpec({ val client = createClient { defaultRequest { bearerAuth(token.serialize()) + headers { + append(HttpHeaders.ContentType, ContentType.Application.Json) + } } install(io.ktor.client.plugins.contentnegotiation.ContentNegotiation) { jackson { @@ -135,4 +141,4 @@ fun MockOAuth2Server.ansattToken(navAnsatt: NavAnsatt): SignedJWT = issueToken( data class NavAnsatt( val azureId: UUID, val ident: String -) \ No newline at end of file +) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6f2c8ba4..9c980555 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,7 +30,7 @@ hikariVersion = "6.2.1" kotlinxCoroutinesVersion = "1.9.0" kotlinxSerializationJsonVersion = "1.7.3" ktorVersion = "2.3.12" -ktor3Version = "3.0.1" +ktor3Version = "3.0.2" [libraries] coroutinesCore = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutinesVersion" } @@ -81,7 +81,7 @@ ktor3-server-openapi = { group = "io.ktor", name = "ktor-server-openapi", versio ktor3-server-netty = { group = "io.ktor", name = "ktor-server-netty", version.ref = "ktor3Version" } ktor3-server-auth = { group = "io.ktor", name = "ktor-server-auth", version.ref = "ktor3Version" } ktor3-server-metricsMicrometer = { group = "io.ktor", name = "ktor-server-metrics-micrometer", version.ref = "ktor3Version" } -ktor3-server-testJvm = { group = "io.ktor", name = "ktor-server-tests-jvm", version.ref = "ktor3Version" } +ktor3-server-test-host = { group = "io.ktor", name = "ktor-server-test-host", version.ref = "ktor3Version" } ktor3-serialization-core = { group = "io.ktor", name = "ktor-serialization", version.ref = "ktor3Version" } ktor3-serialization-jvm = { group = "io.ktor", name = "ktor-serialization-jvm", version.ref = "ktor3Version" } ktor3-serialization-jackson = { group = "io.ktor", name = "ktor-serialization-jackson", version.ref = "ktor3Version" }