Skip to content

Commit

Permalink
👽️ Oppdaterer oppsett mot api vi spør etter fullmakt mot
Browse files Browse the repository at this point in the history
Disabler deploy til prod

Co-authored-by: Øydis Kind Refsum <[email protected]>
  • Loading branch information
oyvindhagen and oydisrefsum committed Nov 27, 2024
1 parent 0ce1de5 commit 673166a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
14 changes: 8 additions & 6 deletions config/representasjon/dev-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ azure:
tenant: trygdeetaten.no
accessPolicy:
outbound:
external:
- host: pdl-fullmakt.dev-fss-pub.nais.io
rules:
- application: repr-api
namespace: repr
cluster: dev-gcp
env:
- name: PDL_FULLMAKT_URL
value: https://pdl-fullmakt.dev-fss-pub.nais.io
- name: PDL_FULLMAKT_SCOPE
value: api://dev-fss.pdl.pdl-fullmakt/.default
- name: REPR_API_URL
value: https://repr-api.intern.dev.nav.no
- name: REPR_API_SCOPE
value: api://dev-gcp.repr.repr-api/.default
19 changes: 0 additions & 19 deletions config/representasjon/prod-gcp.yml

This file was deleted.

21 changes: 21 additions & 0 deletions config/representasjon/prod-gcp.yml.disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
kafkaPool: nav-prod
replicas:
min: 2
max: 2
azure:
enabled: true
claims:
extra:
- azp_name
tenant: nav.no
accessPolicy:
outbound:
rules:
- application: repr-api
namespace: repr
cluster: prod-gcp
env:
- name: REPR_API_URL
value: https://repr-api.intern.nav.no
- name: REPR_API_SCOPE
value: api://prod-gcp.repr.repr-api/.default
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ internal fun createApp(env: Map<String, String>): RapidsConnection {
val azureClient = createAzureTokenClientFromEnvironment(env)

val representasjonClient = RepresentasjonClient(
baseUrl = env.getValue("PDL_FULLMAKT_URL"),
baseUrl = env.getValue("REPR_API_URL"),
tokenClient = azureClient,
httpClient = httpClient,
scope = env.getValue("PDL_FULLMAKT_SCOPE")
scope = env.getValue("REPR_API_SCOPE")
)

RepresentasjonRiver(rapidsConnection = this, representasjonClient = representasjonClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import io.ktor.client.request.setBody
import io.ktor.http.ContentType
import io.ktor.http.HttpStatusCode
import io.ktor.http.contentType
import java.util.Base64
import java.util.UUID
import kotlinx.coroutines.runBlocking
import org.slf4j.LoggerFactory
Expand All @@ -33,29 +32,29 @@ class RepresentasjonClient(
val callId = UUID.randomUUID()
return try {
runBlocking {
val response = httpClient.preparePost("$baseUrl/api/internbruker/fullmaktsgiver") {
val response = httpClient.preparePost("$baseUrl/api/internbruker/fullmakt/fullmaktsgiver") {
contentType(ContentType.Application.Json)
accept(ContentType.Application.Json)
val bearerToken = tokenClient.bearerToken(scope).getOrThrow()
bearerAuth(bearerToken.token)
setBody(mapOf("ident" to Base64.getEncoder().encodeToString(fnr.toByteArray())))
setBody(mapOf("ident" to fnr))
header("Nav-Call-Id", "$callId")
header("no.nav.callid", "$callId")
header("Nav-Consumer-Id", "sparkel-representasjon")
header("no.nav.consumer.id", "sparkel-representasjon")
}.execute()

if (response.status != HttpStatusCode.OK) {
"Feil ved kall mot fullmakt-api, http-status: ${response.status.value}, returnerer tomt resultat. CallId=$callId".also {
"Feil ved kall mot repr-api, http-status: ${response.status.value}, returnerer tomt resultat. CallId=$callId".also {
log.warn(it)
sikkerlog.warn("$it, response:\n$response")
}
Result.failure(RuntimeException("Feil ved kall mot fullmakt-api"))
Result.failure(RuntimeException("Feil ved kall mot repr-api"))
} else Result.success(response.body())
}
} catch (e: Exception) {
log.warn("Feil mot fullmakt-api, callId=$callId, se sikker logg for exception")
sikkerlog.warn("Feil mot fullmakt-api, callId=$callId", e)
log.warn("Feil mot repr-api, callId=$callId, se sikker logg for exception")
sikkerlog.warn("Feil mot repr-api, callId=$callId", e)
Result.failure(e)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class RepresentasjonRiverTest {
}

@Test
fun `kaster exception ved feil mot fullmakt-api`() {
fun `kaster exception ved feil mot repr-api`() {
every { representasjonClient.hentFullmakt(any()) } returns Result.failure(RuntimeException())
assertThrows<RuntimeException> { rapid.sendTestMessage(behov()) }
assertEquals(0, rapid.inspektør.size)
Expand Down

0 comments on commit 673166a

Please sign in to comment.