Skip to content

Commit

Permalink
Fikset test deps for ktor3
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsmsa committed Dec 12, 2024
1 parent 4e1286d commit 3c55d8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/tilgangskontroll/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -135,4 +141,4 @@ fun MockOAuth2Server.ansattToken(navAnsatt: NavAnsatt): SignedJWT = issueToken(
data class NavAnsatt(
val azureId: UUID,
val ident: String
)
)
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 3c55d8f

Please sign in to comment.