Skip to content

Commit

Permalink
Get AAREG_SCOPE from yaml files.
Browse files Browse the repository at this point in the history
  • Loading branch information
MalazAlkoj committed Aug 28, 2024
1 parent f662b01 commit 61541d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/kotlin/no/nav/syfo/aareg/AaregClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -32,7 +33,7 @@ class AaregClient(
fun arbeidsforholdArbeidstaker(fnr: String): List<Arbeidsforhold> {
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<List<Arbeidsforhold>> = RestTemplate().exchange(
Expand Down
3 changes: 2 additions & 1 deletion src/test/kotlin/no/nav/syfo/aareg/AaregClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Metrikk>(relaxed = true)
Expand All @@ -39,7 +40,7 @@ class AaregClientTest : FunSpec({

val azureAdTokenClient = mockk<AzureAdTokenClient>()

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))
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 61541d1

Please sign in to comment.