Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Fjerner wildcard import for klint
Browse files Browse the repository at this point in the history
  • Loading branch information
simhos committed Nov 3, 2023
1 parent e830b12 commit 1a3c94e
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ constructor(
val privateKey: String,
val validInSeconds: Int
)

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import org.springframework.context.annotation.Import
import org.springframework.context.annotation.Scope

@Configuration
@Import(RestTemplateBuilderBean::class,
MaskinportenBearerTokenClientInterceptor::class)
@Import(
RestTemplateBuilderBean::class,
MaskinportenBearerTokenClientInterceptor::class
)
class RestOperationsMaskinporten {

@Bean("maskinporten")
Expand All @@ -18,4 +20,4 @@ class RestOperationsMaskinporten {
restTemplateBuilder: RestTemplateBuilder,
maskinportenBearerTokenClientInterceptor: MaskinportenBearerTokenClientInterceptor
) = restTemplateBuilder.additionalInterceptors(maskinportenBearerTokenClientInterceptor).build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.springframework.stereotype.Component

@Component
@Import(MaskinportenClient::class)
class MaskinportenBearerTokenClientInterceptor(private val maskinportenClient: MaskinportenClient): ClientHttpRequestInterceptor {
class MaskinportenBearerTokenClientInterceptor(private val maskinportenClient: MaskinportenClient) : ClientHttpRequestInterceptor {

override fun intercept(
request: HttpRequest,
Expand All @@ -23,4 +23,4 @@ class MaskinportenBearerTokenClientInterceptor(private val maskinportenClient: M
request.headers.contentType = MediaType.APPLICATION_JSON
return execution.execute(request, body)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package no.nav.bidrag.commons.logging.audit

import io.kotest.assertions.throwables.shouldThrow
import io.mockk.*
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.unmockkStatic
import io.mockk.verify
import no.nav.bidrag.commons.security.ContextService
import no.nav.bidrag.commons.testdata.*
import no.nav.bidrag.commons.testdata.DummyMedPersonIdentobjekt
import no.nav.bidrag.commons.testdata.DummyMedPersonIdentobjektFørst
import no.nav.bidrag.commons.testdata.DummyMedSaksummerobjekt
import no.nav.bidrag.commons.testdata.DummyMedSaksummerobjektFørst
import no.nav.bidrag.commons.testdata.DummyMedString
import no.nav.bidrag.commons.testdata.DummyMedStringFørst
import no.nav.bidrag.commons.tilgang.TilgangClient
import no.nav.bidrag.commons.util.PersonidentGenerator
import no.nav.bidrag.domene.ident.Personident
Expand Down Expand Up @@ -211,7 +221,12 @@ class AuditAdviceTest {
every { codeSignature.parameterNames } returns arrayOf("dill", "dall", "id")
every { joinPoint.signature } returns codeSignature

shouldThrow<IllegalStateException> { auditAdvice.loggTilgang(joinPoint, AuditLog(AuditLoggerEvent.ACCESS, "id")) }
shouldThrow<IllegalStateException> {
auditAdvice.loggTilgang(
joinPoint,
AuditLog(AuditLoggerEvent.ACCESS, "id")
)
}
}

@Test
Expand Down Expand Up @@ -280,7 +295,12 @@ class AuditAdviceTest {
every { codeSignature.parameterNames } returns arrayOf("dill", "dall", "id")
every { joinPoint.signature } returns codeSignature

shouldThrow<IllegalStateException> { auditAdvice.loggTilgang(joinPoint, AuditLog(AuditLoggerEvent.ACCESS, "fnr")) }
shouldThrow<IllegalStateException> {
auditAdvice.loggTilgang(
joinPoint,
AuditLog(AuditLoggerEvent.ACCESS, "fnr")
)
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ class MaskinportenTokenGeneratorTest {
private val TOKEN_PATH = "/token"
private val MASKINPORTEN_MOCK_HOST = "http://localhost:$PORT"


val maskinportenConfig = MaskinportenConfig(
tokenUrl = MASKINPORTEN_MOCK_HOST + TOKEN_PATH,
audience = MASKINPORTEN_MOCK_HOST,
clientId = "17b3e4e8-8203-4463-a947-5c24021b7742",
privateKey = RSAKeyGenerator(2048).keyID("123").generate().toString(),
validInSeconds = 120,
scope = "skatt:testscope.read skatt:testscope.write")

scope = "skatt:testscope.read skatt:testscope.write"
)

@Test
fun `Skal sjekke at maskonporten token er signed med privat key i config`() {
Expand Down Expand Up @@ -72,4 +71,4 @@ class MaskinportenTokenGeneratorTest {

private infix fun Date.likInnenEtSekund(date: Date): Boolean = (time - date.time).absoluteValue < 1000L
private infix fun Date.plusSekunder(seconds: Int): Date = Date(time + seconds * 1000)
}
}
1 change: 0 additions & 1 deletion src/test/kotlin/no/nav/bidrag/commons/testdata/DummyDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package no.nav.bidrag.commons.testdata
import no.nav.bidrag.domene.ident.Personident
import no.nav.bidrag.domene.streng.Saksnummer


data class DummyMedSaksummerobjektFørst(
val saksnummer: Saksnummer,
val dummy1: Int? = null,
Expand Down
14 changes: 12 additions & 2 deletions src/test/kotlin/no/nav/bidrag/commons/tilgang/TilgangAdviceTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package no.nav.bidrag.commons.tilgang

import io.kotest.assertions.throwables.shouldThrow
import io.mockk.*
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.unmockkStatic
import io.mockk.verify
import no.nav.bidrag.commons.security.ContextService
import no.nav.bidrag.commons.testdata.*
import no.nav.bidrag.commons.testdata.DummyMedPersonIdentobjekt
import no.nav.bidrag.commons.testdata.DummyMedPersonIdentobjektFørst
import no.nav.bidrag.commons.testdata.DummyMedSaksummerobjekt
import no.nav.bidrag.commons.testdata.DummyMedSaksummerobjektFørst
import no.nav.bidrag.commons.testdata.DummyMedString
import no.nav.bidrag.commons.testdata.DummyMedStringFørst
import no.nav.bidrag.commons.util.PersonidentGenerator
import no.nav.bidrag.domene.ident.Personident
import no.nav.bidrag.domene.streng.Saksnummer
Expand Down

0 comments on commit 1a3c94e

Please sign in to comment.