From 61541d1c0b307ec17b18ee1fc7c5848781b00f02 Mon Sep 17 00:00:00 2001 From: malazalkoj Date: Wed, 28 Aug 2024 13:28:02 +0200 Subject: [PATCH] Get AAREG_SCOPE from yaml files. --- src/main/kotlin/no/nav/syfo/aareg/AaregClient.kt | 5 +++-- src/test/kotlin/no/nav/syfo/aareg/AaregClientTest.kt | 3 ++- src/test/resources/application.yaml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/no/nav/syfo/aareg/AaregClient.kt b/src/main/kotlin/no/nav/syfo/aareg/AaregClient.kt index 11fb773..3cbfa20 100644 --- a/src/main/kotlin/no/nav/syfo/aareg/AaregClient.kt +++ b/src/main/kotlin/no/nav/syfo/aareg/AaregClient.kt @@ -20,7 +20,8 @@ import org.springframework.web.client.RestTemplate class AaregClient( private val metrikk: Metrikk, private val azureAdTokenClient: AzureAdTokenClient, - @Value("\${aareg.services.url}") private val url: String + @Value("\${aareg.services.url}") private val url: String, + @Value("\${aareg.scope}") private val scope: String ) { companion object { private val LOG = LoggerFactory.getLogger(AaregClient::class.java) @@ -32,7 +33,7 @@ class AaregClient( fun arbeidsforholdArbeidstaker(fnr: String): List { metrikk.tellHendelse("call_aareg") // check which function to use for getting token, or we need to use getOnBehalfOfToken - val token = azureAdTokenClient.getSystemToken("scope") + val token = azureAdTokenClient.getSystemToken(scope) return try { val response: ResponseEntity> = RestTemplate().exchange( diff --git a/src/test/kotlin/no/nav/syfo/aareg/AaregClientTest.kt b/src/test/kotlin/no/nav/syfo/aareg/AaregClientTest.kt index 864c636..a8db832 100644 --- a/src/test/kotlin/no/nav/syfo/aareg/AaregClientTest.kt +++ b/src/test/kotlin/no/nav/syfo/aareg/AaregClientTest.kt @@ -31,6 +31,7 @@ import org.springframework.web.client.RestClientException import org.springframework.web.client.RestTemplate const val AAREG_URL = "http://localhost:9000" +const val AAREG_SCOPE = "scope" class AaregClientTest : FunSpec({ val metrikk = mockk(relaxed = true) @@ -39,7 +40,7 @@ class AaregClientTest : FunSpec({ val azureAdTokenClient = mockk() - val aaregClient = AaregClient(metrikk, azureAdTokenClient, AAREG_URL) + val aaregClient = AaregClient(metrikk, azureAdTokenClient, AAREG_URL, AAREG_SCOPE) val isAaregServer = WireMockServer(9000) listener(WireMockListener(isAaregServer, ListenerMode.PER_TEST)) diff --git a/src/test/resources/application.yaml b/src/test/resources/application.yaml index 3172b54..3e0ff9d 100644 --- a/src/test/resources/application.yaml +++ b/src/test/resources/application.yaml @@ -57,6 +57,7 @@ azure.app.client.secret: 'client.secret' security.token.service.rest.url: "http://security-token-service.url" ereg.url: "http://ereg" aareg.services.url: "http://aareg-services.url" +aareg.scope: "scope" felleskodeverk.url: "http://kodeverk.url" krr.url: "http://krr.url"