diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 9351999c60b..8303efae301 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -2,6 +2,7 @@ name: Integration Tests on: push: paths: + - 'docker-compose.yml' - 'apps/bruker-service/**' workflow_dispatch: diff --git a/apps/adresse-service/src/main/resources/application.yml b/apps/adresse-service/src/main/resources/application.yml index 5b3bf750fca..9c91e9c3470 100644 --- a/apps/adresse-service/src/main/resources/application.yml +++ b/apps/adresse-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: adresse-service @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java b/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java index 2eb944da40e..c4a8080629f 100644 --- a/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java +++ b/apps/adresse-service/src/test/java/no/nav/testnav/apps/adresseservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/adresse-service/src/test/resources/application-test.yml b/apps/adresse-service/src/test/resources/application-test.yml index 594f36142c8..6d2a24d37e0 100644 --- a/apps/adresse-service/src/test/resources/application-test.yml +++ b/apps/adresse-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/altinn3-tilgang-service/src/main/resources/application.yml b/apps/altinn3-tilgang-service/src/main/resources/application.yml index 654d076c3a4..94b117c5c9b 100644 --- a/apps/altinn3-tilgang-service/src/main/resources/application.yml +++ b/apps/altinn3-tilgang-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api://${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java b/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java index 3fed84b2557..699fd8581f4 100644 --- a/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java +++ b/apps/altinn3-tilgang-service/src/test/java/no/nav/testnav/altinn3tilgangservice/ApplicationContextTest.java @@ -4,21 +4,21 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { @MockBean - public ReactiveJwtDecoder jwtDecoder; - - @MockBean + @SuppressWarnings("unused") public SecretManagerServiceClient secretManagerClient; @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/altinn3-tilgang-service/src/test/resources/application-test.yml b/apps/altinn3-tilgang-service/src/test/resources/application-test.yml index dfbee67495e..58d0dd3fd6a 100644 --- a/apps/altinn3-tilgang-service/src/test/resources/application-test.yml +++ b/apps/altinn3-tilgang-service/src/test/resources/application-test.yml @@ -1,5 +1,6 @@ -ALTINN_URL: http://localhost:8080 ALTINN_API_KEY: dummy +ALTINN_URL: http://localhost:8080 +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder MASKINPORTEN_CLIENT_ID: dummy MASKINPORTEN_CLIENT_JWK: dummy MASKINPORTEN_SCOPES: dummy diff --git a/apps/amelding-service/src/main/resources/application.yml b/apps/amelding-service/src/main/resources/application.yml index 404bec3cc25..3829765adf7 100644 --- a/apps/amelding-service/src/main/resources/application.yml +++ b/apps/amelding-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-amelding-service @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/amelding-service/src/test/resources/application-test.yml b/apps/amelding-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/amelding-service/src/test/resources/application-test.yml +++ b/apps/amelding-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/app-tilgang-analyse-service/src/main/resources/application.yml b/apps/app-tilgang-analyse-service/src/main/resources/application.yml index 829bfd78a09..9dce8eae053 100644 --- a/apps/app-tilgang-analyse-service/src/main/resources/application.yml +++ b/apps/app-tilgang-analyse-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo #TODO Finn ut hvordan denne kan settes fra gradle @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java b/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java index 5c21de929dd..d36088e8995 100644 --- a/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java +++ b/apps/app-tilgang-analyse-service/src/test/java/no/nav/testnav/apps/apptilganganalyseservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/app-tilgang-analyse-service/src/test/resources/application-test.yml b/apps/app-tilgang-analyse-service/src/test/resources/application-test.yml index 77a88244e60..b5cec49b00a 100644 --- a/apps/app-tilgang-analyse-service/src/test/resources/application-test.yml +++ b/apps/app-tilgang-analyse-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder DOLLY_READER_TOKEN: test TOKEN_X_ISSUER: dummy diff --git a/apps/arbeidsforhold-service/src/main/resources/application.yml b/apps/arbeidsforhold-service/src/main/resources/application.yml index f15c64ba7ef..934e8722ccd 100644 --- a/apps/arbeidsforhold-service/src/main/resources/application.yml +++ b/apps/arbeidsforhold-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-arbeidsforhold-service @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java b/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java index ff2a9c6e847..49691443caf 100644 --- a/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java +++ b/apps/arbeidsforhold-service/src/test/java/no/nav/registre/testnorge/arbeidsforholdservice/ApplicationContextTest.java @@ -1,10 +1,7 @@ package no.nav.registre.testnorge.arbeidsforholdservice; -import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -13,12 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test - @DisplayName("Application context should load") void load_app_context() { assertThat(true).isTrue(); } diff --git a/apps/arbeidsforhold-service/src/test/resources/application-test.yml b/apps/arbeidsforhold-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/arbeidsforhold-service/src/test/resources/application-test.yml +++ b/apps/arbeidsforhold-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/batch-bestilling-service/src/main/resources/application.yml b/apps/batch-bestilling-service/src/main/resources/application.yml index 0a85377386b..b64b4503002 100644 --- a/apps/batch-bestilling-service/src/main/resources/application.yml +++ b/apps/batch-bestilling-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -10,8 +8,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java b/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java index 5d5cc248a00..ffcbb8894b2 100644 --- a/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java +++ b/apps/batch-bestilling-service/src/test/java/no/nav/registre/testnorge/batchbestillingservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @ActiveProfiles("test") @SpringBootTest -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/batch-bestilling-service/src/test/resources/application-test.yml b/apps/batch-bestilling-service/src/test/resources/application-test.yml index aa8bfa92394..7af80f7078f 100644 --- a/apps/batch-bestilling-service/src/test/resources/application-test.yml +++ b/apps/batch-bestilling-service/src/test/resources/application-test.yml @@ -1,3 +1,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java b/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java index 0a880e2a08a..91b0dd22dab 100644 --- a/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java +++ b/apps/bruker-service/src/test/java/no/nav/testnav/apps/brukerservice/integrationtest/BrukerServiceIntegrationTest.java @@ -8,29 +8,22 @@ import no.nav.testnav.libs.securitycore.domain.AccessToken; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; +import org.junit.jupiter.api.*; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; import java.io.IOException; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @Tag("integration") class BrukerServiceIntegrationTest { private static final String PID = "01810048413"; private static final String ORGNUMMER = "811306312"; public static MockWebServer mockBackEnd; - @MockBean - JwtDecoder jwtDecoder; private ObjectMapper objectMapper; private WebClient webClient; @@ -65,7 +58,7 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws .setBody(objectMapper.writeValueAsString(new AccessToken("test")))); var token = tokendingsClient.generateToken("dev-gcp:dolly:testnav-bruker-service", PID).block(); - + assertThat(token).isNotNull(); // Create user var expected = new BrukerDTO(null, "username", ORGNUMMER, null, null); @@ -83,7 +76,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws .bodyToMono(BrukerDTO.class) .block(); - Assertions.assertThat(bruker) + assertThat(bruker) + .isNotNull() .usingRecursiveComparison() .comparingOnlyFields("brukernavn", "organisasjonsnummer") .isEqualTo(expected); @@ -132,7 +126,8 @@ void should_create_new_user_login_change_username_and_then_delete_user() throws .bodyToMono(BrukerDTO.class) .block(); - Assertions.assertThat(updatedUser.brukernavn()).isEqualTo("new-username"); + assertThat(updatedUser).isNotNull(); + assertThat(updatedUser.brukernavn()).isEqualTo("new-username"); mockBackEnd.enqueue( new MockResponse().setResponseCode(200) diff --git a/apps/budpro-service/src/main/resources/application.yml b/apps/budpro-service/src/main/resources/application.yml index 2f26a58b56d..2e9db0bdbcd 100644 --- a/apps/budpro-service/src/main/resources/application.yml +++ b/apps/budpro-service/src/main/resources/application.yml @@ -1,12 +1,10 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: security: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api://${AZURE_APP_CLIENT_ID} management: diff --git a/apps/dolly-backend/src/main/resources/application.yml b/apps/dolly-backend/src/main/resources/application.yml index 7187259ca47..8cfa4fb3c41 100644 --- a/apps/dolly-backend/src/main/resources/application.yml +++ b/apps/dolly-backend/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - dolly: api: v1: @@ -45,8 +43,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} jackson: parser: diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java b/apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java deleted file mode 100644 index 91ea6e800d3..00000000000 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package no.nav.dolly; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.oauth2.jwt.JwtDecoder; - -@Configuration -@Slf4j -public class MockedJwtDecoderConfig { - - @MockBean - private JwtDecoder jwtDecoder; - - @Bean - public JwtDecoder jwtDecoder() { - log.info("Using a mocked JwtDecoder"); - return jwtDecoder; - } - -} diff --git a/apps/dolly-backend/src/test/resources/application-test.yml b/apps/dolly-backend/src/test/resources/application-test.yml index 2af37395a12..c70a9fef887 100644 --- a/apps/dolly-backend/src/test/resources/application-test.yml +++ b/apps/dolly-backend/src/test/resources/application-test.yml @@ -1,7 +1,9 @@ APP_NAME: dolly APP_VERSION: ${application.version} -environment: localhost +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: placeholder TOKEN_X_ISSUER: dummy +environment: localhost jira: host: http://localhost:${wiremock.server.port:0}/jira diff --git a/apps/dolly-frontend/src/main/resources/application-local.yml b/apps/dolly-frontend/src/main/resources/application-local.yml index 48b781833ba..dd94d3a8798 100644 --- a/apps/dolly-frontend/src/main/resources/application-local.yml +++ b/apps/dolly-frontend/src/main/resources/application-local.yml @@ -22,9 +22,9 @@ spring: client-secret: ${AZURE_APP_CLIENT_SECRET} provider: aad: - authorization-uri: ${AAD_ISSUER_URI}/oauth2/v2.0/authorize - token-uri: ${AAD_ISSUER_URI}/oauth2/v2.0/token - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + authorization-uri: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b/oauth2/v2.0/authorize # Not set by NAIS, but required because of authorization_code. + token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} consumers: testnav-altinn3-tilgang-service: diff --git a/apps/dolly-frontend/src/main/resources/application.yml b/apps/dolly-frontend/src/main/resources/application.yml index d448be506fd..53b7cccde72 100644 --- a/apps/dolly-frontend/src/main/resources/application.yml +++ b/apps/dolly-frontend/src/main/resources/application.yml @@ -1,4 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b POST_LOGOUT_REDIRECT_URI: https://dolly-frontend.intern.dev.nav.no/login REDIS_HOST: dolly-redis-session.dolly.svc.cluster.local @@ -16,8 +15,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/dolly-frontend/src/test/resources/application-test.yml b/apps/dolly-frontend/src/test/resources/application-test.yml index e55e0f2063d..1b8205278c4 100644 --- a/apps/dolly-frontend/src/test/resources/application-test.yml +++ b/apps/dolly-frontend/src/test/resources/application-test.yml @@ -1,7 +1,7 @@ -TOKEN_X_ISSUER: dummy - +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder IDPORTEN_CLIENT_ID: dummy IDPORTEN_CLIENT_JWK: "{}" +TOKEN_X_ISSUER: dummy spring: cloud: diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/SecurityConfig.java b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/SecurityConfig.java index a6633b0baec..0818d60f358 100644 --- a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/SecurityConfig.java +++ b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/SecurityConfig.java @@ -6,20 +6,28 @@ import org.springframework.security.config.web.server.ServerHttpSecurity; import org.springframework.security.web.server.SecurityWebFilterChain; +import static org.springframework.security.config.Customizer.withDefaults; + @Configuration @EnableWebFluxSecurity public class SecurityConfig { @Bean - public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { - return http.cors(ServerHttpSecurity.CorsSpec::disable) + public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { + return http + .cors(ServerHttpSecurity.CorsSpec::disable) .csrf(ServerHttpSecurity.CsrfSpec::disable) - .authorizeExchange(authorizeExchangeSpec -> authorizeExchangeSpec - .pathMatchers("/internal/isReady", "/internal/isAlive", "/internal/metrics").permitAll() - .anyExchange().authenticated()) - .oauth2Login(oAuth2LoginSpec -> { - }) + .authorizeExchange(authorizeExchange -> authorizeExchange + .pathMatchers( + "/internal/isReady", + "/internal/isAlive", + "/internal/metrics") + .permitAll() + .anyExchange() + .authenticated()) + .oauth2Login(withDefaults()) .build(); } + } diff --git a/apps/endringsmelding-frontend/src/main/resources/application-local.yml b/apps/endringsmelding-frontend/src/main/resources/application-local.yml index baa3afe677c..c5694fb8898 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application-local.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application-local.yml @@ -1,5 +1,8 @@ AZURE_APP_CLIENT_ID: ${sm://azure-app-client-id} AZURE_APP_CLIENT_SECRET: ${sm://azure-app-client-secret} +AZURE_APP_TENANT_ID: ${sm://azure-app-tenant-id} +AZURE_OPENID_CONFIG_ISSUER: ${sm://azure-openid-config-issuer} +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: ${sm://azure-openid-config-token-endpoint} spring: config: diff --git a/apps/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 0437a6213d6..19feeba2fa1 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: endringsmelding-frontend @@ -11,16 +9,14 @@ spring: client: registration: aad: + authorization-grant-type: authorization_code client-id: ${AZURE_APP_CLIENT_ID} client-secret: ${AZURE_APP_CLIENT_SECRET} - authorization-grant-type: authorization_code redirect-uri: '{baseUrl}/login/oauth2/code/{registrationId}' - scope: openid, ${AZURE_APP_CLIENT_ID}/.default + scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: aad: - authorization-uri: ${AAD_ISSUER_URI}/oauth2/v2.0/authorize - token-uri: ${AAD_ISSUER_URI}/oauth2/v2.0/token - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} consumers: endringsmelding-service: diff --git a/apps/endringsmelding-frontend/src/main/resources/logback-spring.xml b/apps/endringsmelding-frontend/src/main/resources/logback-spring.xml index 05ead4bd0b2..01d8cc207fa 100644 --- a/apps/endringsmelding-frontend/src/main/resources/logback-spring.xml +++ b/apps/endringsmelding-frontend/src/main/resources/logback-spring.xml @@ -36,4 +36,6 @@ + + \ No newline at end of file diff --git a/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java b/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java index a36f833f2bc..bf22354b0bc 100644 --- a/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java +++ b/apps/endringsmelding-frontend/src/test/java/no/nav/testnav/apps/endringsmeldingfrontend/ApplicationContextTest.java @@ -3,18 +3,23 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { @MockBean - public JwtDecoder jwtDecoder; + @SuppressWarnings("unused") + private ReactiveClientRegistrationRepository reactiveClientRegistrationRepository; @Test @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/endringsmelding-service/src/main/resources/application.yml b/apps/endringsmelding-service/src/main/resources/application.yml index d552f471d1e..a667cde98cf 100644 --- a/apps/endringsmelding-service/src/main/resources/application.yml +++ b/apps/endringsmelding-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo #TODO Finn ut hvordan denne kan settes fra gradle @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/endringsmelding-service/src/test/resources/application-test.yml b/apps/endringsmelding-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/endringsmelding-service/src/test/resources/application-test.yml +++ b/apps/endringsmelding-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/faste-data-frontend/src/main/resources/application.yml b/apps/faste-data-frontend/src/main/resources/application.yml index 6d226e085c8..7cd235a5286 100644 --- a/apps/faste-data-frontend/src/main/resources/application.yml +++ b/apps/faste-data-frontend/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-faste-data-frontend @@ -21,9 +19,9 @@ spring: scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: aad: - authorization-uri: ${AAD_ISSUER_URI}/oauth2/v2.0/authorize - token-uri: ${AAD_ISSUER_URI}/oauth2/v2.0/token - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + authorization-uri: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b/oauth2/v2.0/authorize # Not set by NAIS, but required because of authorization_code. + token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} consumers: testnorge-profil-api: diff --git a/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java b/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java index 1b2c4d1c9b8..205b1bd0fb4 100644 --- a/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java +++ b/apps/faste-data-frontend/src/test/java/no/nav/testnav/apps/fastedatafrontend/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml b/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml index 716b962f019..d3003d513d1 100644 --- a/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml +++ b/apps/generer-arbeidsforhold-populasjon-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-generer-arbeidsforhold-populasjon-service @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java b/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java index 8f02c58e9b9..a2392ea6603 100644 --- a/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java +++ b/apps/generer-arbeidsforhold-populasjon-service/src/test/java/no/nav/registre/testnav/genererarbeidsforholdpopulasjonservice/ApplicationContextTest.java @@ -3,20 +3,18 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-arbeidsforhold-populasjon-service/src/test/resources/application-test.yml b/apps/generer-arbeidsforhold-populasjon-service/src/test/resources/application-test.yml index aa8bfa92394..7af80f7078f 100644 --- a/apps/generer-arbeidsforhold-populasjon-service/src/test/resources/application-test.yml +++ b/apps/generer-arbeidsforhold-populasjon-service/src/test/resources/application-test.yml @@ -1,3 +1,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/generer-navn-service/src/main/resources/application.yml b/apps/generer-navn-service/src/main/resources/application.yml index f470d5ceed7..8467dde1098 100644 --- a/apps/generer-navn-service/src/main/resources/application.yml +++ b/apps/generer-navn-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -11,8 +9,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java b/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java index 054bfe6bd61..dd102f395c8 100644 --- a/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java +++ b/apps/generer-navn-service/src/test/java/no/nav/registre/testnorge/generernavnservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-navn-service/src/test/resources/application-test.yml b/apps/generer-navn-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/generer-navn-service/src/test/resources/application-test.yml +++ b/apps/generer-navn-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml b/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml index c26902af9b9..bc464c3a1ba 100644 --- a/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml +++ b/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-generer-organisasjon-populasjon-service @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java b/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java index 77490415474..355fae27f01 100644 --- a/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java +++ b/apps/generer-organisasjon-populasjon-service/src/test/java/no/nav/registre/testnav/genererorganisasjonpopulasjonservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-organisasjon-populasjon-service/src/test/resources/application-test.yml b/apps/generer-organisasjon-populasjon-service/src/test/resources/application-test.yml index 825469b32e6..43d79553644 100644 --- a/apps/generer-organisasjon-populasjon-service/src/test/resources/application-test.yml +++ b/apps/generer-organisasjon-populasjon-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy KAFKA_KEYSTORE_PATH: "" diff --git a/apps/generer-synt-amelding-service/src/main/resources/application.yml b/apps/generer-synt-amelding-service/src/main/resources/application.yml index df0c280972e..36816a442bd 100644 --- a/apps/generer-synt-amelding-service/src/main/resources/application.yml +++ b/apps/generer-synt-amelding-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -13,8 +11,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java b/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java index 9a3aaac3414..f178668a74c 100644 --- a/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java +++ b/apps/generer-synt-amelding-service/src/test/java/no/nav/registre/testnorge/generersyntameldingservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/generer-synt-amelding-service/src/test/resources/application-test.yml b/apps/generer-synt-amelding-service/src/test/resources/application-test.yml index 3a6b7afa2ab..d2a2473f158 100644 --- a/apps/generer-synt-amelding-service/src/test/resources/application-test.yml +++ b/apps/generer-synt-amelding-service/src/test/resources/application-test.yml @@ -1,4 +1,5 @@ -AAD_ISSUER_URI: http://localhost:${wiremock.server.port:0}/token +AZURE_OPENID_CONFIG_ISSUER: http://localhost:${wiremock.server.port:0}/token/v2.0 +AZURE_OPENID_CONFIG_JWKS_URI: http://localhost:${wiremock.server.port:0}/token/discovery/v2.0/keys TOKEN_X_ISSUER: dummy spring: diff --git a/apps/helsepersonell-service/src/main/resources/application.yml b/apps/helsepersonell-service/src/main/resources/application.yml index da7af8a8eee..e1407b4de4c 100644 --- a/apps/helsepersonell-service/src/main/resources/application.yml +++ b/apps/helsepersonell-service/src/main/resources/application.yml @@ -1,4 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b spring: main: banner-mode: off @@ -11,8 +10,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java b/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java index a54dd5c821e..828115f0d3c 100644 --- a/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java +++ b/apps/helsepersonell-service/src/test/java/no/nav/registre/testnorge/helsepersonellservice/ApplicationContextTest.java @@ -2,20 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/helsepersonell-service/src/test/resources/application-test.yml b/apps/helsepersonell-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/helsepersonell-service/src/test/resources/application-test.yml +++ b/apps/helsepersonell-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/inntektsmelding-generator-service/src/main/resources/application.yml b/apps/inntektsmelding-generator-service/src/main/resources/application.yml index edb4821e98f..5cf4be136bc 100644 --- a/apps/inntektsmelding-generator-service/src/main/resources/application.yml +++ b/apps/inntektsmelding-generator-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -10,8 +8,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java b/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java index 3281df17537..534799e6dab 100644 --- a/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java +++ b/apps/inntektsmelding-generator-service/src/test/java/no/nav/testnav/inntektsmeldinggeneratorservice/ApplicationContextTest.java @@ -4,21 +4,21 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @ActiveProfiles("test") @SpringBootTest -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @MockBean + @SuppressWarnings("unused") public MapperFacade mapperFacade; @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/inntektsmelding-generator-service/src/test/resources/application-test.yml b/apps/inntektsmelding-generator-service/src/test/resources/application-test.yml index 09e586a7980..c247f2ad542 100644 --- a/apps/inntektsmelding-generator-service/src/test/resources/application-test.yml +++ b/apps/inntektsmelding-generator-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/inntektsmelding-service/src/main/resources/application.yml b/apps/inntektsmelding-service/src/main/resources/application.yml index 3e93ae1704b..1ec5aeb1b9f 100644 --- a/apps/inntektsmelding-service/src/main/resources/application.yml +++ b/apps/inntektsmelding-service/src/main/resources/application.yml @@ -1,4 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b spring: jpa: properties: @@ -14,8 +13,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/inntektsmelding-service/src/test/resources/application-test.yml b/apps/inntektsmelding-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/inntektsmelding-service/src/test/resources/application-test.yml +++ b/apps/inntektsmelding-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/jenkins-batch-status-service/src/main/resources/application.yml b/apps/jenkins-batch-status-service/src/main/resources/application.yml index 38b6be1140a..fc3f24ab41b 100644 --- a/apps/jenkins-batch-status-service/src/main/resources/application.yml +++ b/apps/jenkins-batch-status-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -11,8 +9,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java b/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java index 9fc4b631887..b5c2a008670 100644 --- a/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java +++ b/apps/jenkins-batch-status-service/src/test/java/no/nav/registre/testnorge/jenkinsbatchstatusservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/jenkins-batch-status-service/src/test/resources/application-test.yml b/apps/jenkins-batch-status-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/jenkins-batch-status-service/src/test/resources/application-test.yml +++ b/apps/jenkins-batch-status-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/joark-dokument-service/src/main/resources/application.yml b/apps/joark-dokument-service/src/main/resources/application.yml index 76d160784c6..357947af212 100644 --- a/apps/joark-dokument-service/src/main/resources/application.yml +++ b/apps/joark-dokument-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - consumers.testnav-saf-proxy: url: https://testnav-saf-proxy.dev-fss-pub.nais.io cluster: dev-fss @@ -16,8 +14,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java b/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java index b6b552e1b36..671643c7fe8 100644 --- a/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java +++ b/apps/joark-dokument-service/src/test/java/no/nav/testnav/joarkdokumentservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @ActiveProfiles("test") @SpringBootTest -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/joark-dokument-service/src/test/resources/application-test.yml b/apps/joark-dokument-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/joark-dokument-service/src/test/resources/application-test.yml +++ b/apps/joark-dokument-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/kodeverk-service/src/main/resources/application.yml b/apps/kodeverk-service/src/main/resources/application.yml index 7f880895661..b2b2bd893f8 100644 --- a/apps/kodeverk-service/src/main/resources/application.yml +++ b/apps/kodeverk-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-kodeverk-service @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/kodeverk-service/src/test/java/no/nav/testnav/kodeverkservice/ApplicationContextTest.java b/apps/kodeverk-service/src/test/java/no/nav/testnav/kodeverkservice/ApplicationContextTest.java index f277d06fc62..341d0d5583b 100644 --- a/apps/kodeverk-service/src/test/java/no/nav/testnav/kodeverkservice/ApplicationContextTest.java +++ b/apps/kodeverk-service/src/test/java/no/nav/testnav/kodeverkservice/ApplicationContextTest.java @@ -1,24 +1,18 @@ package no.nav.testnav.kodeverkservice; -import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @SpringBootTest @ActiveProfiles("test") -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @DisplayName("Application context should load") void load_app_context() { assertThat(true).isTrue(); } + } diff --git a/apps/kodeverk-service/src/test/resources/application-test.yml b/apps/kodeverk-service/src/test/resources/application-test.yml index 0aeb22a14f6..70b074dc087 100644 --- a/apps/kodeverk-service/src/test/resources/application-test.yml +++ b/apps/kodeverk-service/src/test/resources/application-test.yml @@ -1,3 +1,6 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder + spring: cloud: gcp: diff --git a/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml b/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml index 9e676dc80e1..d5987e736f4 100644 --- a/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml +++ b/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -11,8 +9,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} flyway: locations: classpath:db/migration diff --git a/apps/levende-arbeidsforhold-ansettelse/src/test/java/no/nav/testnav/levendearbeidsforholdansettelse/LevendeArbeidsforholdAnsettelseApplicationTests.java b/apps/levende-arbeidsforhold-ansettelse/src/test/java/no/nav/testnav/levendearbeidsforholdansettelse/LevendeArbeidsforholdAnsettelseApplicationTests.java index bfc00a93a64..1dfa258ae9e 100644 --- a/apps/levende-arbeidsforhold-ansettelse/src/test/java/no/nav/testnav/levendearbeidsforholdansettelse/LevendeArbeidsforholdAnsettelseApplicationTests.java +++ b/apps/levende-arbeidsforhold-ansettelse/src/test/java/no/nav/testnav/levendearbeidsforholdansettelse/LevendeArbeidsforholdAnsettelseApplicationTests.java @@ -3,9 +3,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.r2dbc.core.R2dbcEntityTemplate; -import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -14,17 +12,12 @@ @ActiveProfiles("test") class LevendeArbeidsforholdAnsettelseApplicationTests { - @MockBean - @SuppressWarnings("unused") - public ReactiveJwtDecoder jwtDecoder; - @Autowired private R2dbcEntityTemplate template; @Test void load_app_context() { - assertThat(template) - .isNotNull(); + assertThat(template).isNotNull(); } } diff --git a/apps/levende-arbeidsforhold-ansettelse/src/test/resources/application-test.yml b/apps/levende-arbeidsforhold-ansettelse/src/test/resources/application-test.yml index 6f0b72ba8ea..fd31a953be4 100644 --- a/apps/levende-arbeidsforhold-ansettelse/src/test/resources/application-test.yml +++ b/apps/levende-arbeidsforhold-ansettelse/src/test/resources/application-test.yml @@ -1,3 +1,6 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder + spring: r2dbc: url: r2dbc:h2:mem:///~/db/testdb diff --git a/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml b/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml index 0ade711cee5..6513436ff64 100644 --- a/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml +++ b/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -11,8 +9,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/levende-arbeidsforhold-scheduler/src/test/resources/application-test.yml b/apps/levende-arbeidsforhold-scheduler/src/test/resources/application-test.yml index 0aeb22a14f6..70b074dc087 100644 --- a/apps/levende-arbeidsforhold-scheduler/src/test/resources/application-test.yml +++ b/apps/levende-arbeidsforhold-scheduler/src/test/resources/application-test.yml @@ -1,3 +1,6 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder + spring: cloud: gcp: diff --git a/apps/levende-arbeidsforhold-service/src/main/resources/application.yml b/apps/levende-arbeidsforhold-service/src/main/resources/application.yml index 9366022b2f8..2319771adbf 100644 --- a/apps/levende-arbeidsforhold-service/src/main/resources/application.yml +++ b/apps/levende-arbeidsforhold-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -12,8 +10,8 @@ spring: client: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} kafka: consumer: diff --git a/apps/levende-arbeidsforhold-service/src/test/java/no/nav/testnav/levendearbeidsforholdservice/ApplicationContextTest.java b/apps/levende-arbeidsforhold-service/src/test/java/no/nav/testnav/levendearbeidsforholdservice/ApplicationContextTest.java index 8f3a5ea5356..db33e70155b 100644 --- a/apps/levende-arbeidsforhold-service/src/test/java/no/nav/testnav/levendearbeidsforholdservice/ApplicationContextTest.java +++ b/apps/levende-arbeidsforhold-service/src/test/java/no/nav/testnav/levendearbeidsforholdservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } -} + +} \ No newline at end of file diff --git a/apps/levende-arbeidsforhold-service/src/test/resources/application-test.yml b/apps/levende-arbeidsforhold-service/src/test/resources/application-test.yml index 0aeb22a14f6..70b074dc087 100644 --- a/apps/levende-arbeidsforhold-service/src/test/resources/application-test.yml +++ b/apps/levende-arbeidsforhold-service/src/test/resources/application-test.yml @@ -1,3 +1,6 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder + spring: cloud: gcp: diff --git a/apps/miljoer-service/src/main/resources/application.yml b/apps/miljoer-service/src/main/resources/application.yml index 47f1bcc1780..bdaf189cf4b 100644 --- a/apps/miljoer-service/src/main/resources/application.yml +++ b/apps/miljoer-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - config: miljoer: t13, q1, q2, q4, qx @@ -13,8 +11,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java b/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java index 44ecb7599b0..beb878a52ca 100644 --- a/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java +++ b/apps/miljoer-service/src/test/java/no/nav/registre/testnorge/miljoerservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @ActiveProfiles("test") @SpringBootTest -public class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; +class ApplicationContextTest { @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/miljoer-service/src/test/resources/application-test.yml b/apps/miljoer-service/src/test/resources/application-test.yml index 594f36142c8..6d2a24d37e0 100644 --- a/apps/miljoer-service/src/test/resources/application-test.yml +++ b/apps/miljoer-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/oppsummeringsdokument-service/src/main/resources/application.yml b/apps/oppsummeringsdokument-service/src/main/resources/application.yml index 780c6e746f0..021c5a887c6 100644 --- a/apps/oppsummeringsdokument-service/src/main/resources/application.yml +++ b/apps/oppsummeringsdokument-service/src/main/resources/application.yml @@ -1,12 +1,10 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: security: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} application: name: oppsummeringsdokument-service diff --git a/apps/organisasjon-bestilling-service/src/main/resources/application.yml b/apps/organisasjon-bestilling-service/src/main/resources/application.yml index e8d0b3a450e..33460028360 100644 --- a/apps/organisasjon-bestilling-service/src/main/resources/application.yml +++ b/apps/organisasjon-bestilling-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -12,8 +10,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java b/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java index 0a3ef843ece..62b6f52369a 100644 --- a/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java +++ b/apps/organisasjon-bestilling-service/src/test/java/no/nav/testnav/apps/organisasjonbestillingservice/ApplicationContextTest.java @@ -3,19 +3,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } \ No newline at end of file diff --git a/apps/organisasjon-bestilling-service/src/test/resources/application-test.yml b/apps/organisasjon-bestilling-service/src/test/resources/application-test.yml index 594f36142c8..6d2a24d37e0 100644 --- a/apps/organisasjon-bestilling-service/src/test/resources/application-test.yml +++ b/apps/organisasjon-bestilling-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/organisasjon-faste-data-service/src/main/resources/application.yml b/apps/organisasjon-faste-data-service/src/main/resources/application.yml index f0e7149af43..55bb42585b0 100644 --- a/apps/organisasjon-faste-data-service/src/main/resources/application.yml +++ b/apps/organisasjon-faste-data-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-organisasjon-faste-data-service @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java b/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java index ba30cd1d952..b6071475775 100644 --- a/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java +++ b/apps/organisasjon-faste-data-service/src/test/java/no/nav/registre/testnorge/organisasjonfastedataservice/ApplicationContextTest.java @@ -3,19 +3,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } \ No newline at end of file diff --git a/apps/organisasjon-faste-data-service/src/test/resources/application-test.yml b/apps/organisasjon-faste-data-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/organisasjon-faste-data-service/src/test/resources/application-test.yml +++ b/apps/organisasjon-faste-data-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/organisasjon-forvalter/src/main/resources/application.yml b/apps/organisasjon-forvalter/src/main/resources/application.yml index 8e48224db96..3980ba3afb8 100644 --- a/apps/organisasjon-forvalter/src/main/resources/application.yml +++ b/apps/organisasjon-forvalter/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: Testnav-Organisasjon-Forvalter @@ -13,8 +11,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java b/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java index 28a222eebd2..352c8aa0ee3 100644 --- a/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java +++ b/apps/organisasjon-forvalter/src/test/java/no/nav/organisasjonforvalter/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - private JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/organisasjon-forvalter/src/test/resources/application-test.yml b/apps/organisasjon-forvalter/src/test/resources/application-test.yml index f5afb1ea114..ed88a762c5a 100644 --- a/apps/organisasjon-forvalter/src/test/resources/application-test.yml +++ b/apps/organisasjon-forvalter/src/test/resources/application-test.yml @@ -1,4 +1,5 @@ TOKEN_X_ISSUER: dummy +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder spring: cloud: diff --git a/apps/organisasjon-mottak-service/src/main/resources/application.yml b/apps/organisasjon-mottak-service/src/main/resources/application.yml index 77d033f0b1c..11e68815c67 100644 --- a/apps/organisasjon-mottak-service/src/main/resources/application.yml +++ b/apps/organisasjon-mottak-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-organisasjon-mottak-service @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/organisasjon-mottak-service/src/test/java/no/nav/registre/testnorge/organisasjonmottak/ApplicationContextTest.java b/apps/organisasjon-mottak-service/src/test/java/no/nav/registre/testnorge/organisasjonmottak/ApplicationContextTest.java index c34645a7afd..d7618c2c5a5 100644 --- a/apps/organisasjon-mottak-service/src/test/java/no/nav/registre/testnorge/organisasjonmottak/ApplicationContextTest.java +++ b/apps/organisasjon-mottak-service/src/test/java/no/nav/registre/testnorge/organisasjonmottak/ApplicationContextTest.java @@ -1,10 +1,7 @@ package no.nav.registre.testnorge.organisasjonmottak; -import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -13,12 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test - @DisplayName("Application context should load") void load_app_context() { assertThat(true).isTrue(); } diff --git a/apps/organisasjon-mottak-service/src/test/resources/application-test.yml b/apps/organisasjon-mottak-service/src/test/resources/application-test.yml index a28916c6e65..39d4850ba29 100644 --- a/apps/organisasjon-mottak-service/src/test/resources/application-test.yml +++ b/apps/organisasjon-mottak-service/src/test/resources/application-test.yml @@ -1,3 +1,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/organisasjon-service/src/main/resources/application.yml b/apps/organisasjon-service/src/main/resources/application.yml index 64de1fe9017..0e259f82d84 100644 --- a/apps/organisasjon-service/src/main/resources/application.yml +++ b/apps/organisasjon-service/src/main/resources/application.yml @@ -7,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} @@ -20,8 +20,6 @@ springdoc: disable-swagger-default-url: true url: /v3/api-docs -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - consumers: testnav-ereg-proxy: url: https://testnav-ereg-proxy.dev-fss-pub.nais.io diff --git a/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java b/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java index b5cebbd5b6b..6dd3857d70e 100644 --- a/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java +++ b/apps/organisasjon-service/src/test/java/no/nav/registre/testnorge/organisasjonservice/ApplicationContextTest.java @@ -1,28 +1,16 @@ package no.nav.registre.testnorge.organisasjonservice; import org.junit.Test; -import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@AutoConfigureWireMock(port = 0) -@TestPropertySource(locations = "classpath:application-test.yml") +@SpringBootTest +@ActiveProfiles("test") public class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") public void loadAppContext() { assertThat(true).isTrue(); } diff --git a/apps/orgnummer-service/src/main/resources/application.yml b/apps/orgnummer-service/src/main/resources/application.yml index 2de7966ba4c..fe9af2875a7 100644 --- a/apps/orgnummer-service/src/main/resources/application.yml +++ b/apps/orgnummer-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-orgnummer-service @@ -13,8 +11,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java b/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java index 96a45c6acd5..9183af0d4f0 100644 --- a/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java +++ b/apps/orgnummer-service/src/test/java/no/nav/registre/orgnrservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/orgnummer-service/src/test/resources/application-test.yml b/apps/orgnummer-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/orgnummer-service/src/test/resources/application-test.yml +++ b/apps/orgnummer-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/oversikt-frontend/src/main/resources/application.yml b/apps/oversikt-frontend/src/main/resources/application.yml index e843d6fb138..72258122b37 100644 --- a/apps/oversikt-frontend/src/main/resources/application.yml +++ b/apps/oversikt-frontend/src/main/resources/application.yml @@ -1,12 +1,10 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: security: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/pdl-forvalter/src/main/resources/application.yml b/apps/pdl-forvalter/src/main/resources/application.yml index 5acfc5165d8..87a8ee64115 100644 --- a/apps/pdl-forvalter/src/main/resources/application.yml +++ b/apps/pdl-forvalter/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - consumers: adresse-service: url: http://testnav-adresse-service.dolly.svc.cluster.local @@ -42,8 +40,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/person-faste-data-service/src/main/resources/application.yml b/apps/person-faste-data-service/src/main/resources/application.yml index aaa24d49517..879b0263c43 100644 --- a/apps/person-faste-data-service/src/main/resources/application.yml +++ b/apps/person-faste-data-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-person-faste-data-service @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/person-faste-data-service/src/test/java/no/nav/testnav/personfastedataservice/ApplicationContextTest.java b/apps/person-faste-data-service/src/test/java/no/nav/testnav/personfastedataservice/ApplicationContextTest.java index cb9ba64e65d..621682c9800 100644 --- a/apps/person-faste-data-service/src/test/java/no/nav/testnav/personfastedataservice/ApplicationContextTest.java +++ b/apps/person-faste-data-service/src/test/java/no/nav/testnav/personfastedataservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public ReactiveJwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/person-faste-data-service/src/test/resources/application-test.yml b/apps/person-faste-data-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/person-faste-data-service/src/test/resources/application-test.yml +++ b/apps/person-faste-data-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/person-search-service/src/main/resources/application.yml b/apps/person-search-service/src/main/resources/application.yml index e2fbb948c45..8054a6fa42c 100644 --- a/apps/person-search-service/src/main/resources/application.yml +++ b/apps/person-search-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-person-search-service @@ -13,8 +11,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java b/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java index 821f8f6468b..c1429860143 100644 --- a/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java +++ b/apps/person-search-service/src/test/java/no/nav/registre/testnorge/personsearchservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/person-search-service/src/test/resources/application-test.yml b/apps/person-search-service/src/test/resources/application-test.yml index ee2f6b75ba0..49f732a190d 100644 --- a/apps/person-search-service/src/test/resources/application-test.yml +++ b/apps/person-search-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/person-service/src/main/resources/application.yml b/apps/person-service/src/main/resources/application.yml index 8c6411c1eaf..5fcb3b3736e 100644 --- a/apps/person-service/src/main/resources/application.yml +++ b/apps/person-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo #TODO Finn ut hvordan denne kan settes fra gradle @@ -15,8 +13,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} jackson: serialization: diff --git a/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java b/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java index 369d96f7540..b371304188d 100644 --- a/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java +++ b/apps/person-service/src/test/java/no/nav/testnav/apps/personservice/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/person-service/src/test/resources/application-test.yml b/apps/person-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/person-service/src/test/resources/application-test.yml +++ b/apps/person-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java index 0efac636604..aeffef43a04 100644 --- a/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java +++ b/apps/profil-api/src/main/java/no/nav/registre/testnorge/profil/service/AzureAdTokenService.java @@ -17,6 +17,7 @@ import java.net.URI; +// TODO: Why do we not use a library here? @Slf4j @Service public class AzureAdTokenService { @@ -26,7 +27,7 @@ public class AzureAdTokenService { public AzureAdTokenService( @Value("${http.proxy:#{null}}") String proxyHost, - @Value("${AAD_ISSUER_URI}") String issuerUrl, + @Value("${AZURE_OPENID_CONFIG_ISSUER}") String issuerUrl, AzureClientCredential clientCredential, GetAuthenticatedToken getAuthenticatedToken ) { diff --git a/apps/profil-api/src/main/resources/application.yml b/apps/profil-api/src/main/resources/application.yml index 7e343630c04..98525088a6b 100644 --- a/apps/profil-api/src/main/resources/application.yml +++ b/apps/profil-api/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo #TODO Finn ut hvordan denne kan settes fra gradle @@ -11,8 +9,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/profil-api/src/test/java/no/nav/registre/testnorge/profil/ApplicationContextTest.java b/apps/profil-api/src/test/java/no/nav/registre/testnorge/profil/ApplicationContextTest.java index 42873bbb9e3..c06dac535d9 100644 --- a/apps/profil-api/src/test/java/no/nav/registre/testnorge/profil/ApplicationContextTest.java +++ b/apps/profil-api/src/test/java/no/nav/registre/testnorge/profil/ApplicationContextTest.java @@ -2,19 +2,17 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + @SpringBootTest @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - public JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } + } diff --git a/apps/profil-api/src/test/resources/application-test.yml b/apps/profil-api/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/profil-api/src/test/resources/application-test.yml +++ b/apps/profil-api/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/skattekort-service/src/main/resources/application.yml b/apps/skattekort-service/src/main/resources/application.yml index 72a52109bee..5142cfd6998 100644 --- a/apps/skattekort-service/src/main/resources/application.yml +++ b/apps/skattekort-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: Testnav-Skattekort-Service @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/skattekort-service/src/test/resources/application-test.yml b/apps/skattekort-service/src/test/resources/application-test.yml index 0aeb22a14f6..a69fa740f61 100644 --- a/apps/skattekort-service/src/test/resources/application-test.yml +++ b/apps/skattekort-service/src/test/resources/application-test.yml @@ -1,3 +1,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder + spring: cloud: gcp: diff --git a/apps/sykemelding-api/src/main/resources/application.yml b/apps/sykemelding-api/src/main/resources/application.yml index b49e9a7862a..e973c8a046f 100644 --- a/apps/sykemelding-api/src/main/resources/application.yml +++ b/apps/sykemelding-api/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - syfo: queue: name: "QA.Q1_SYFOSMMOTTAK.INPUT" @@ -13,8 +11,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api://${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/synt-sykemelding-api/src/main/resources/application.yml b/apps/synt-sykemelding-api/src/main/resources/application.yml index 70e49cef899..35ae5113dae 100644 --- a/apps/synt-sykemelding-api/src/main/resources/application.yml +++ b/apps/synt-sykemelding-api/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java index da2d3262e83..95d23517546 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java @@ -15,19 +15,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Mono; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestArbeidsforholdDTO; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @RunWith(SpringRunner.class) @@ -36,9 +32,6 @@ @AutoConfigureWireMock(port = 0) public class ArbeidsforholdConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenService; @@ -48,10 +41,10 @@ public class ArbeidsforholdConsumerTest { @Autowired private ArbeidsforholdConsumer arbeidsforholdConsumer; - private static final String ident = "01019049945"; - private static final String orgnr = "123456789"; - private static final String arbeidsforholdId = "1"; - private static final String arbeidsforholdUrl = "(.*)/arbeidsforhold/api/v1/arbeidsforhold/" + ident + "/" + orgnr + "/" + arbeidsforholdId; + private static final String IDENT = "01019049945"; + private static final String ORGNR = "123456789"; + private static final String ARBEIDSFORHOLD_ID = "1"; + private static final String ARBEIDSFORHOLD_URL = "(.*)/arbeidsforhold/api/v1/arbeidsforhold/" + IDENT + "/" + ORGNR + "/" + ARBEIDSFORHOLD_ID; private ArbeidsforholdDTO arbeidsforholdResponse; @@ -59,20 +52,20 @@ public class ArbeidsforholdConsumerTest { public void before() { WireMock.reset(); when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); - arbeidsforholdResponse = getTestArbeidsforholdDTO(arbeidsforholdId, orgnr); + arbeidsforholdResponse = getTestArbeidsforholdDTO(ARBEIDSFORHOLD_ID, ORGNR); } @Test public void shouldGetArbeidsforhold() throws JsonProcessingException { stubArbeidsforhold(); - var response = arbeidsforholdConsumer.getArbeidsforhold(ident, orgnr, arbeidsforholdId); + var response = arbeidsforholdConsumer.getArbeidsforhold(IDENT, ORGNR, ARBEIDSFORHOLD_ID); assertThat(response).isNotNull().isEqualTo(arbeidsforholdResponse); } private void stubArbeidsforhold() throws JsonProcessingException { - stubFor(get(urlPathMatching(arbeidsforholdUrl)) + stubFor(get(urlPathMatching(ARBEIDSFORHOLD_URL)) .willReturn(ok() .withHeader("Content-Type", "application/json") .withBody(objectMapper.writeValueAsString(arbeidsforholdResponse)))); diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java index 06e4636c8d3..8d34fe99ca2 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java @@ -15,19 +15,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Mono; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestLegeListeDTO; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @RunWith(SpringRunner.class) @@ -36,9 +32,6 @@ @AutoConfigureWireMock(port = 0) public class HelsepersonellConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenService; @@ -48,7 +41,7 @@ public class HelsepersonellConsumerTest { @Autowired private HelsepersonellConsumer helsepersonellConsumer; - private static final String helsepersonellUrl = "(.*)/testnav-helsepersonell/api/v1/helsepersonell"; + private static final String HELSEPERSONELL_URL = "(.*)/testnav-helsepersonell/api/v1/helsepersonell"; private HelsepersonellListeDTO helsepersonellResponse; @@ -67,11 +60,11 @@ public void shouldGetHelsepersonell() throws JsonProcessingException { assertThat(response).isNotNull(); assertThat(response.getList()).isNotNull().hasSize(1); - assertThat(response.getList().get(0).getIdent()).isNotNull().isEqualTo(helsepersonellResponse.getHelsepersonell().get(0).getFnr()); + assertThat(response.getList().getFirst().getIdent()).isNotNull().isEqualTo(helsepersonellResponse.getHelsepersonell().getFirst().getFnr()); } private void stubHelsepersonell() throws JsonProcessingException { - stubFor(get(urlPathMatching(helsepersonellUrl)) + stubFor(get(urlPathMatching(HELSEPERSONELL_URL)) .willReturn(ok() .withHeader("Content-Type", "application/json") .withBody(objectMapper.writeValueAsString(helsepersonellResponse)))); diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java index c4d5863f604..7245c153b1c 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java @@ -15,19 +15,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Mono; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestOrganisasjonDTO; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @RunWith(SpringRunner.class) @@ -36,9 +32,6 @@ @AutoConfigureWireMock(port = 0) public class OrganisasjonConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenService; @@ -48,28 +41,28 @@ public class OrganisasjonConsumerTest { @Autowired private OrganisasjonConsumer organisasjonConsumer; - private static final String orgnr = "123456789"; - private static final String organisasjonUrl = "(.*)/organisasjon/api/v1/organisasjoner/" + orgnr; + private static final String ORGNR = "123456789"; + private static final String ORGANISASJON_URL = "(.*)/organisasjon/api/v1/organisasjoner/" + ORGNR; private OrganisasjonDTO organisasjonResponse; @Before public void before() { WireMock.reset(); when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); - organisasjonResponse = getTestOrganisasjonDTO(orgnr); + organisasjonResponse = getTestOrganisasjonDTO(ORGNR); } @Test public void shouldGetOrgansiasjon() throws JsonProcessingException { stubOrgansisasjon(); - var response = organisasjonConsumer.getOrganisasjon(orgnr); + var response = organisasjonConsumer.getOrganisasjon(ORGNR); assertThat(response).isNotNull().isEqualTo(organisasjonResponse); } private void stubOrgansisasjon() throws JsonProcessingException { - stubFor(get(urlPathMatching(organisasjonUrl)) + stubFor(get(urlPathMatching(ORGANISASJON_URL)) .willReturn(ok() .withHeader("Content-Type", "application/json") .withBody(objectMapper.writeValueAsString(organisasjonResponse)))); diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java index e41ca52e23e..9056e2202c7 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java @@ -15,19 +15,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Mono; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestPdlPerson; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @RunWith(SpringRunner.class) @@ -36,9 +32,6 @@ @AutoConfigureWireMock(port = 0) public class PdlProxyConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenService; @@ -48,22 +41,22 @@ public class PdlProxyConsumerTest { @Autowired private PdlProxyConsumer pdlProxyConsumer; - private static final String ident = "01019049945"; - private static final String pdlProxyUrl = "(.*)/pdl/pdl-api/graphql"; + private static final String IDENT = "01019049945"; + private static final String PDL_PROXY_URL = "(.*)/pdl/pdl-api/graphql"; private PdlPerson pdlResponse; @Before public void before() { WireMock.reset(); when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); - pdlResponse = getTestPdlPerson(ident); + pdlResponse = getTestPdlPerson(IDENT); } @Test public void shouldGetArbeidsforhold() throws JsonProcessingException { stubPdlProxy(); - var response = pdlProxyConsumer.getPdlPerson(ident); + var response = pdlProxyConsumer.getPdlPerson(IDENT); assertThat(response).isNotNull(); assertThat(response.getErrors()).isEmpty(); @@ -71,11 +64,11 @@ public void shouldGetArbeidsforhold() throws JsonProcessingException { assertThat(response.getData().getHentPerson().getFoedsel()).isEmpty(); assertThat(response.getData().getHentPerson().getNavn()).hasSize(1); assertThat(response.getData().getHentIdenter().getIdenter()).hasSize(1); - assertThat(response.getData().getHentIdenter().getIdenter().get(0).getIdent()).isEqualTo(ident); + assertThat(response.getData().getHentIdenter().getIdenter().getFirst().getIdent()).isEqualTo(IDENT); } private void stubPdlProxy() throws JsonProcessingException { - stubFor(post(urlPathMatching(pdlProxyUrl)) + stubFor(post(urlPathMatching(PDL_PROXY_URL)) .willReturn(ok() .withHeader("Content-Type", "application/json") .withBody(objectMapper.writeValueAsString(pdlResponse)))); diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java index 9ba6c0c1b47..60efa10fca7 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java @@ -1,6 +1,5 @@ package no.nav.testnav.apps.syntsykemeldingapi.consumer; -import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; import no.nav.testnav.apps.syntsykemeldingapi.consumer.dto.SyntSykemeldingHistorikkDTO; import no.nav.testnav.apps.syntsykemeldingapi.domain.Arbeidsforhold; @@ -25,7 +24,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; @@ -35,16 +33,8 @@ import java.time.LocalDate; import java.util.Map; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestArbeidsforholdDTO; -import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestHistorikk; -import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestLegeListeDTO; -import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestOrganisasjonDTO; -import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestPdlPerson; +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.*; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; @@ -56,59 +46,47 @@ @AutoConfigureWireMock(port = 0) public class SykemeldingConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenService; - @Autowired - private ObjectMapper objectMapper; - @Autowired private SykemeldingConsumer sykemeldingConsumer; - private static final String ident = "12345678910"; - private static final String orgnr = "123456789"; - private static final String arbeidsforholdId = "1"; - private static final String sykemeldingUrl = "(.*)/sykemelding/sykemelding/api/v1/sykemeldinger"; - - private SyntSykemeldingDTO dto; - private PdlPerson pdlResponse; - private ArbeidsforholdDTO arbeidsforholdResponse; - private OrganisasjonDTO organisasjonResponse; - private Map syntResponse; - private HelsepersonellListeDTO helsepersonellResponse; + private static final String IDENT = "12345678910"; + private static final String ORGNR = "123456789"; + private static final String ARBEIDSFORHOLD_ID = "1"; + private static final String SYKEMELDING_URL = "(.*)/sykemelding/sykemelding/api/v1/sykemeldinger"; + private SykemeldingDTO sykemeldingRequest; @Before public void setUp() { when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); - dto = SyntSykemeldingDTO.builder() - .arbeidsforholdId(arbeidsforholdId) - .ident(ident) - .orgnummer(orgnr) + SyntSykemeldingDTO dto = SyntSykemeldingDTO.builder() + .arbeidsforholdId(ARBEIDSFORHOLD_ID) + .ident(IDENT) + .orgnummer(ORGNR) .startDato(LocalDate.now()) .build(); - pdlResponse = getTestPdlPerson(ident); - arbeidsforholdResponse = getTestArbeidsforholdDTO(arbeidsforholdId, orgnr); - organisasjonResponse = getTestOrganisasjonDTO(orgnr); + PdlPerson pdlResponse = getTestPdlPerson(IDENT); + ArbeidsforholdDTO arbeidsforholdResponse = getTestArbeidsforholdDTO(ARBEIDSFORHOLD_ID, ORGNR); + OrganisasjonDTO organisasjonResponse = getTestOrganisasjonDTO(ORGNR); var arbeidsforhold = new Arbeidsforhold( arbeidsforholdResponse, organisasjonResponse ); - syntResponse = getTestHistorikk(ident); - helsepersonellResponse = getTestLegeListeDTO(); + Map syntResponse = getTestHistorikk(IDENT); + HelsepersonellListeDTO helsepersonellResponse = getTestLegeListeDTO(); sykemeldingRequest = new Sykemelding( new Person(pdlResponse), - syntResponse.get(ident), + syntResponse.get(IDENT), dto, - new Helsepersonell(helsepersonellResponse.getHelsepersonell().get(0)), + new Helsepersonell(helsepersonellResponse.getHelsepersonell().getFirst()), arbeidsforhold).toDTO(); } @@ -130,11 +108,11 @@ public void shouldGetFeil() { } private void stubSykemelding() { - stubFor(post(urlPathMatching(sykemeldingUrl)).willReturn(ok())); + stubFor(post(urlPathMatching(SYKEMELDING_URL)).willReturn(ok())); } private void stubSykemeldingError() { - stubFor(post(urlPathMatching(sykemeldingUrl)).willReturn(aResponse().withStatus(500))); + stubFor(post(urlPathMatching(SYKEMELDING_URL)).willReturn(aResponse().withStatus(500))); } } diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java index e568818dcc9..517b90fa35c 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java @@ -15,7 +15,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; @@ -24,13 +23,10 @@ import java.time.LocalDate; import java.util.Map; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestHistorikk; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @RunWith(SpringRunner.class) @@ -39,9 +35,6 @@ @AutoConfigureWireMock(port = 0) public class SyntElsamConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenService; @@ -51,28 +44,28 @@ public class SyntElsamConsumerTest { @Autowired private SyntElsamConsumer syntElsamConsumer; - private static final String ident = "01019049945"; - private static final String syntUrl = "(.*)/synt/api/v1/generate_sykmeldings_history_json"; + private static final String IDENT = "01019049945"; + private static final String SYNT_URL = "(.*)/synt/api/v1/generate_sykmeldings_history_json"; private Map syntResponse; @Before public void before() { WireMock.reset(); when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); - syntResponse = getTestHistorikk(ident); + syntResponse = getTestHistorikk(IDENT); } @Test public void shouldGetSyntSykemelding() throws JsonProcessingException { stubSynt(); - var response = syntElsamConsumer.genererSykemeldinger(ident, LocalDate.now()); + var response = syntElsamConsumer.genererSykemeldinger(IDENT, LocalDate.now()); - assertThat(response).isNotNull().isEqualTo(syntResponse.get(ident)); + assertThat(response).isNotNull().isEqualTo(syntResponse.get(IDENT)); } private void stubSynt() throws JsonProcessingException { - stubFor(post(urlPathMatching(syntUrl)) + stubFor(post(urlPathMatching(SYNT_URL)) .willReturn(ok() .withHeader("Content-Type", "application/json") .withBody(objectMapper.writeValueAsString(syntResponse)))); diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingControllerIntegrationTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingControllerIntegrationTest.java index 21bf2d37dc4..d2d18811d25 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingControllerIntegrationTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingControllerIntegrationTest.java @@ -18,7 +18,6 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; import reactor.core.publisher.Mono; @@ -41,10 +40,6 @@ @AutoConfigureWireMock(port = 0) class SyntSykemeldingControllerIntegrationTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Autowired private MockMvc mockMvc; diff --git a/apps/synt-sykemelding-api/src/test/resources/application-test.yml b/apps/synt-sykemelding-api/src/test/resources/application-test.yml index 0c8f756eae8..25d79707ee9 100644 --- a/apps/synt-sykemelding-api/src/test/resources/application-test.yml +++ b/apps/synt-sykemelding-api/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy wiremock: diff --git a/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml b/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml index 3ab20446b84..77bbd69bd56 100644 --- a/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml +++ b/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java deleted file mode 100644 index 80ae5ae509b..00000000000 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.testnav.apps.syntvedtakshistorikkservice; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; - - @Test - @SuppressWarnings("java:S2699") - void load_app_context() { - } -} - diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java index a37b8a6e2f3..0131865be90 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/ArenaForvalterConsumerTest.java @@ -5,7 +5,6 @@ import no.nav.testnav.libs.securitycore.domain.AccessToken; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -14,8 +13,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.Arrays; @@ -23,14 +23,10 @@ import java.util.List; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; import static org.junit.jupiter.api.Assertions.assertThrows; - -import org.springframework.test.context.junit.jupiter.SpringExtension; -import reactor.core.publisher.Mono; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -38,9 +34,6 @@ @AutoConfigureWireMock(port = 0) class ArenaForvalterConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -58,9 +51,7 @@ public void setup() { @Test void checkExceptionOccursOnBadSentTilArenaForvalterRequest() { stubOpprettErrorResponse(); - assertThrows(Exception.class, () -> { - arenaForvalterConsumer.sendBrukereTilArenaForvalter(null); - }); + assertThrows(Exception.class, () -> arenaForvalterConsumer.sendBrukereTilArenaForvalter(null)); } @@ -235,7 +226,7 @@ void shouldOppretteRettighetTillegg() { var response = arenaForvalterConsumer.opprettRettighet(rettigheter); - assertThat(response.get(fnr).get(0).getNyeRettigheterTillegg()).hasSize(1); + assertThat(response.get(fnr).getFirst().getNyeRettigheterTillegg()).hasSize(1); } private void stubArenaForvalterOpprettTilleggRettighet() { diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java index bf6f7fe9a56..f5fb7a98982 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PdlConsumerTest.java @@ -11,25 +11,17 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import reactor.core.publisher.Mono; import java.util.Collections; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static no.nav.testnav.apps.syntvedtakshistorikkservice.service.TagsService.SYNT_TAGS; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; - -import static no.nav.testnav.apps.syntvedtakshistorikkservice.service.TagsService.SYNT_TAGS; - +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -37,9 +29,6 @@ @AutoConfigureWireMock(port = 0) class PdlConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -57,7 +46,7 @@ void shouldGetPdlPerson() { var response = pdlProxyConsumer.getPdlPerson(IDENT).getData(); var ident = response.getHentIdenter().getIdenter().stream() .filter(identer -> identer.getGruppe().equals(PdlPerson.Gruppe.FOLKEREGISTERIDENT)) - .toList().get(0).getIdent(); + .toList().getFirst().getIdent(); assertThat(ident).isEqualTo(IDENT); assertThat(response.getHentPerson().getBostedsadresse()).hasSize(1); @@ -85,7 +74,7 @@ void shouldGetPdlPersoner() { var response = pdlProxyConsumer.getPdlPersoner(Collections.singletonList(IDENT)).getData(); var bolk = response.getHentPersonBolk(); - var ident = bolk.get(0).getIdent(); + var ident = bolk.getFirst().getIdent(); assertThat(ident).isEqualTo(IDENT); assertThat(bolk).hasSize(1); diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java index 0469281914c..a8d489e3625 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PensjonTestdataFacadeConsumerTest.java @@ -13,16 +13,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import reactor.core.publisher.Mono; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -30,9 +28,6 @@ @AutoConfigureWireMock(port = 0) class PensjonTestdataFacadeConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -59,7 +54,7 @@ void shouldOpprettPerson() { var response = pensjonConsumer.opprettPerson(PERSON); assertThat(response.getStatus()).hasSize(1); - assertThat(response.getStatus().get(0).getMiljo()).isEqualTo("q2"); + assertThat(response.getStatus().getFirst().getMiljo()).isEqualTo("q2"); } private void stubOpprettPerson() { @@ -90,7 +85,7 @@ void shouldOpprettInntetk() { var response = pensjonConsumer.opprettInntekt(INNTEKT); assertThat(response.getStatus()).hasSize(1); - assertThat(response.getStatus().get(0).getMiljo()).isEqualTo("q2"); + assertThat(response.getStatus().getFirst().getMiljo()).isEqualTo("q2"); } private void stubOpprettInntekt() { diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java index 6c751b0220b..051f2a48f00 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/PersonSearchConsumerTest.java @@ -4,6 +4,7 @@ import no.nav.testnav.libs.dto.personsearchservice.v1.search.PersonSearch; import no.nav.testnav.libs.securitycore.domain.AccessToken; import no.nav.testnav.libs.securitycore.domain.ServerProperties; +import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -12,18 +13,16 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; -import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange; import reactor.core.publisher.Mono; import java.util.Arrays; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.mockito.Mockito.when; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -31,9 +30,6 @@ @AutoConfigureWireMock(port = 0) class PersonSearchConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -67,7 +63,7 @@ void shouldGetSearchResult() { var response = personSearchConsumer.search(REQUEST); assertThat(response.getItems()).hasSize(1); assertThat(response.getNumberOfItems()).isEqualTo(1); - assertThat(response.getItems().get(0).getIdent()).isEqualTo("11866800000"); + assertThat(response.getItems().getFirst().getIdent()).isEqualTo("11866800000"); } private void stubPostPersonSearch() { diff --git a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java index fe0a771cac3..878296f25fd 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java +++ b/apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/consumer/SyntVedtakshistorikkConsumerTest.java @@ -11,17 +11,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import reactor.core.publisher.Mono; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static no.nav.testnav.apps.syntvedtakshistorikkservice.utils.ResourceUtils.getResourceFileContent; -import static org.mockito.Mockito.when; import static org.assertj.core.api.Assertions.assertThat; - +import static org.mockito.Mockito.when; @ActiveProfiles("test") @ExtendWith(SpringExtension.class) @@ -29,9 +26,6 @@ @AutoConfigureWireMock(port = 0) class SyntVedtakshistorikkConsumerTest { - @MockBean - private JwtDecoder jwtDecoder; - @MockBean private TokenExchange tokenExchange; @@ -50,7 +44,7 @@ void shouldGetVedtakshistorikk(){ assertThat(response).hasSize(2); - var historikk1 = response.get(0); + var historikk1 = response.getFirst(); assertThat(historikk1.getAap115()).hasSize(1); assertThat(historikk1.getAap()).hasSize(5); assertThat(historikk1.getAlleVedtak()).hasSize(6); diff --git a/apps/synt-vedtakshistorikk-service/src/test/resources/application-test.yml b/apps/synt-vedtakshistorikk-service/src/test/resources/application-test.yml index b9cb22f75c1..73cbea09d9e 100644 --- a/apps/synt-vedtakshistorikk-service/src/test/resources/application-test.yml +++ b/apps/synt-vedtakshistorikk-service/src/test/resources/application-test.yml @@ -1,5 +1,7 @@ -AAD_ISSUER_URI: http://localhost:${wiremock.server.port:0}/token -TOKEN_X_ISSUER: dummy +AZURE_OPENID_CONFIG_ISSUER: http://localhost:${wiremock.server.port:0}/token/v2.0 +AZURE_OPENID_CONFIG_JWKS_URI: http://localhost:${wiremock.server.port:0}/token/discovery/v2.0/keys +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: placeholder +TOKEN_X_ISSUER: placeholder spring: cloud: @@ -10,27 +12,17 @@ spring: consumers: synt-vedtakshistorikk: url: http://localhost:${wiremock.server.port:0}/synt - cluster: dummy - namespace: dolly name: synthdata-arena-vedtakshistorikk testnav-arena-forvalteren-proxy: - cluster: dummy - namespace: dolly name: testnav-arena-forvalteren-proxy url: http://localhost:${wiremock.server.port:0}/arena testnav-pensjon-testdata-facade-proxy: - cluster: dummy - namespace: dolly name: testnav-pensjon-testdata-facade-proxy url: http://localhost:${wiremock.server.port:0}/pensjon testnav-person-search-service: - cluster: dummy - namespace: dolly name: testnav-person-search-service url: http://localhost:${wiremock.server.port:0}/search pdl-api-proxy: - cluster: dummy - namespace: dolly name: testnav-pdl-proxy url: http://localhost:${wiremock.server.port:0}/pdl diff --git a/apps/tenor-search-service/src/main/resources/application.yml b/apps/tenor-search-service/src/main/resources/application.yml index 72f6aa800c2..6998c13d9d0 100644 --- a/apps/tenor-search-service/src/main/resources/application.yml +++ b/apps/tenor-search-service/src/main/resources/application.yml @@ -1,4 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b spring: application: version: 1 @@ -8,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/tenor-search-service/src/test/resources/application-test.yml b/apps/tenor-search-service/src/test/resources/application-test.yml index c9e2e70764b..843cea2a0f3 100644 --- a/apps/tenor-search-service/src/test/resources/application-test.yml +++ b/apps/tenor-search-service/src/test/resources/application-test.yml @@ -1,8 +1,9 @@ -TOKEN_X_ISSUER: dummy +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder MASKINPORTEN_CLIENT_ID: dummy MASKINPORTEN_CLIENT_JWK: dummy MASKINPORTEN_SCOPES: dummy MASKINPORTEN_WELL_KNOWN_URL: dummy +TOKEN_X_ISSUER: dummy spring: cloud: diff --git a/apps/testnav-ident-pool/src/main/resources/application.yml b/apps/testnav-ident-pool/src/main/resources/application.yml index 50680851ade..978dd607a5a 100644 --- a/apps/testnav-ident-pool/src/main/resources/application.yml +++ b/apps/testnav-ident-pool/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - application: name: testnav-ident-pool version: 1.0.0 diff --git a/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/ComponentTestConfig.java b/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/ComponentTestConfig.java index c8b8c1e41c8..6342cf543d7 100644 --- a/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/ComponentTestConfig.java +++ b/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/ComponentTestConfig.java @@ -4,15 +4,13 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.security.oauth2.jwt.JwtDecoder; @Configuration @ComponentScan(basePackages = "no.nav.testnav.identpool") public class ComponentTestConfig { @MockBean - protected JwtDecoder jwtDecoder; - - @MockBean + @SuppressWarnings("unused") protected CronJobService cronJobService; + } diff --git a/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/providers/v1/FinnesHosSkattComponentTest.java b/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/providers/v1/FinnesHosSkattComponentTest.java index 24b68d3f67f..c22c8b52f0e 100644 --- a/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/providers/v1/FinnesHosSkattComponentTest.java +++ b/apps/testnav-ident-pool/src/test/java/no/nav/testnav/identpool/providers/v1/FinnesHosSkattComponentTest.java @@ -12,8 +12,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -import java.net.URISyntaxException; - import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -26,8 +24,7 @@ class FinnesHosSkattComponentTest extends ComponentTestbase { private static final String FNR = "10108000398"; @BeforeEach - void populerDatabaseMedTestidenter() throws URISyntaxException { - + void populerDatabaseMedTestidenter() { identRepository.deleteAll(); identRepository.save( createIdentEntity(Identtype.FNR, DNR, Rekvireringsstatus.LEDIG, 10) diff --git a/apps/testnav-ident-pool/src/test/resources/application-test.yml b/apps/testnav-ident-pool/src/test/resources/application-test.yml index bea909f59d4..14d3f1658c1 100644 --- a/apps/testnav-ident-pool/src/test/resources/application-test.yml +++ b/apps/testnav-ident-pool/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder TOKEN_X_ISSUER: dummy ### DATABASE ### diff --git a/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml b/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml index 52b818eb1db..5b21e3a7e18 100644 --- a/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml +++ b/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo @@ -14,8 +12,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java deleted file mode 100644 index 0114dc57053..00000000000 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package no.nav.registre.sdforvalter; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.oauth2.jwt.JwtDecoder; - -@Configuration -@Slf4j -public class JwtDecoderConfig { - - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - - @Bean - public JwtDecoder jwtDecoder() { - log.info("Using a mocked JwtDecoder"); - return jwtDecoder; - } - -} diff --git a/apps/testnorge-statisk-data-forvalter/src/test/resources/application-test.yml b/apps/testnorge-statisk-data-forvalter/src/test/resources/application-test.yml index db527311ba3..05620f8a7ff 100644 --- a/apps/testnorge-statisk-data-forvalter/src/test/resources/application-test.yml +++ b/apps/testnorge-statisk-data-forvalter/src/test/resources/application-test.yml @@ -1,3 +1,6 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost:${wiremock.server.port:0}/token/v2.0 +AZURE_OPENID_CONFIG_JWKS_URI: http://localhost:${wiremock.server.port:0}/token/discovery/v2.0/keys + spring: datasource: url: jdbc:h2:mem:testdb @@ -18,8 +21,6 @@ spring: vault: enabled: false -AAD_ISSUER_URI: http://localhost:${wiremock.server.port:0}/token - consumers: generer-navn-service: url: http://localhost:${wiremock.server.port:0}/generer-navn diff --git a/apps/tilbakemelding-api/src/main/resources/application.yml b/apps/tilbakemelding-api/src/main/resources/application.yml index fdf868899a9..90214f53c9b 100644 --- a/apps/tilbakemelding-api/src/main/resources/application.yml +++ b/apps/tilbakemelding-api/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: version: application.version.todo #TODO Finn ut hvordan denne kan settes fra gradle @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java b/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java index e4e96cffc49..7027714d06b 100644 --- a/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java +++ b/apps/tilbakemelding-api/src/test/java/no/nav/registre/testnorge/tilbakemeldingapi/ApplicationContextTest.java @@ -2,8 +2,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -12,12 +10,7 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test - @SuppressWarnings("java:S2699") void loadAppContext() { assertThat(true).isTrue(); } diff --git a/apps/tilbakemelding-api/src/test/resources/application-test.yml b/apps/tilbakemelding-api/src/test/resources/application-test.yml index 70b69dfb28a..37b58b04163 100644 --- a/apps/tilbakemelding-api/src/test/resources/application-test.yml +++ b/apps/tilbakemelding-api/src/test/resources/application-test.yml @@ -1,5 +1,6 @@ -SLACK_TOKEN: dummy +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder SLACK_CHANNEL: dummy +SLACK_TOKEN: dummy TOKEN_X_ISSUER: dummy spring: diff --git a/apps/tps-messaging-service/src/main/resources/application.yml b/apps/tps-messaging-service/src/main/resources/application.yml index b7c23264167..caf45e35e9d 100644 --- a/apps/tps-messaging-service/src/main/resources/application.yml +++ b/apps/tps-messaging-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-tps-messaging-service @@ -13,8 +11,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api://${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/tps-messaging-service/src/test/Resources/application-test.yml b/apps/tps-messaging-service/src/test/Resources/application-test.yml index b44dd04c473..8f5d0691071 100644 --- a/apps/tps-messaging-service/src/test/Resources/application-test.yml +++ b/apps/tps-messaging-service/src/test/Resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy config: diff --git a/apps/tps-messaging-service/src/test/java/no/nav/testnav/apps/tpsmessagingservice/ApplicationContextTest.java b/apps/tps-messaging-service/src/test/java/no/nav/testnav/apps/tpsmessagingservice/ApplicationContextTest.java index 90ed768d9e0..6ed2956beba 100644 --- a/apps/tps-messaging-service/src/test/java/no/nav/testnav/apps/tpsmessagingservice/ApplicationContextTest.java +++ b/apps/tps-messaging-service/src/test/java/no/nav/testnav/apps/tpsmessagingservice/ApplicationContextTest.java @@ -2,8 +2,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -12,10 +10,6 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test void loadAppContext() { assertThat(true).isTrue(); diff --git a/apps/udi-stub/src/main/resources/application.yml b/apps/udi-stub/src/main/resources/application.yml index 6d4f4085497..1a3c2b93589 100644 --- a/apps/udi-stub/src/main/resources/application.yml +++ b/apps/udi-stub/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: Testnav-UDI-stub @@ -19,8 +17,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} springdoc: diff --git a/apps/udi-stub/src/test/java/no/nav/udistub/converter/itest/UdiStubITest.java b/apps/udi-stub/src/test/java/no/nav/udistub/converter/itest/UdiStubITest.java index 54170daf2a5..72245e4329a 100644 --- a/apps/udi-stub/src/test/java/no/nav/udistub/converter/itest/UdiStubITest.java +++ b/apps/udi-stub/src/test/java/no/nav/udistub/converter/itest/UdiStubITest.java @@ -14,7 +14,6 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.core.io.ClassPathResource; import org.springframework.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; @@ -54,9 +53,7 @@ class UdiStubITest { protected static final UdiPerson TESTPERSON_UDI = createPersonTo(); - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; + @Autowired private PersonRepository personRepository; @Autowired diff --git a/apps/udi-stub/src/test/resources/application-test.yml b/apps/udi-stub/src/test/resources/application-test.yml index fe24f5b2071..585b27493c3 100644 --- a/apps/udi-stub/src/test/resources/application-test.yml +++ b/apps/udi-stub/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/apps/varslinger-service/src/main/resources/application.yml b/apps/varslinger-service/src/main/resources/application.yml index 55331eeaa37..7b243261aa5 100644 --- a/apps/varslinger-service/src/main/resources/application.yml +++ b/apps/varslinger-service/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: main: banner-mode: off @@ -11,8 +9,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java index 3a823bfb95b..261b6a62b8e 100644 --- a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java +++ b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerControllerTest.java @@ -9,9 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; @@ -24,9 +22,6 @@ @ActiveProfiles("test") class VarslingerControllerTest { - @MockBean - public JwtDecoder jwtDecoder; - @Autowired private MockMvc mvc; diff --git a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java index 67839a20d53..6664136d0be 100644 --- a/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java +++ b/apps/varslinger-service/src/test/java/no/nav/registre/varslingerservice/controller/VarslingerPersonControllerTest.java @@ -12,14 +12,12 @@ import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedId; import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedToken; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.web.servlet.MockMvc; @@ -35,9 +33,6 @@ @ActiveProfiles("test") class VarslingerPersonControllerTest { - @MockBean - public JwtDecoder jwtDecoder; - @MockBean public GetAuthenticatedToken getAuthenticatedToken; @@ -59,13 +54,6 @@ class VarslingerPersonControllerTest { @Autowired private ObjectMapper objectMapper; - @BeforeEach - public void beforeEach() { - mottattVarslingRepository.deleteAll(); - brukerRepository.deleteAll(); - varslingRepository.deleteAll(); - } - @AfterEach public void afterEach() { mottattVarslingRepository.deleteAll(); diff --git a/apps/varslinger-service/src/test/resources/application-test.yml b/apps/varslinger-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 100644 --- a/apps/varslinger-service/src/test/resources/application-test.yml +++ b/apps/varslinger-service/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: diff --git a/docker-compose.yml b/docker-compose.yml index f20d218d0a0..55e9428599f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: - TOKEN_X_PRIVATE_JWK=${JWK} - MASKINPORTEN_CLIENT_JWK=${JWK} build: - context: ./apps/testnav-altinn3-tilgang-service + context: ./apps/altinn3-tilgang-service depends_on: - tokendings - maskinporten diff --git a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/TokenServiceAutoConfiguration.java b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/TokenServiceAutoConfiguration.java index 007f512f24f..3ec49ef0b6a 100644 --- a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/TokenServiceAutoConfiguration.java +++ b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/TokenServiceAutoConfiguration.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import no.nav.testnav.libs.reactivesecurity.action.GetAuthenticatedToken; import no.nav.testnav.libs.reactivesecurity.action.GetAuthenticatedUserId; -import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTokenService; import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureNavTokenService; +import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTokenService; import no.nav.testnav.libs.reactivesecurity.exchange.azuread.AzureTrygdeetatenTokenService; import no.nav.testnav.libs.securitycore.domain.azuread.*; import org.springframework.beans.factory.annotation.Value; @@ -13,7 +13,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; -import org.springframework.util.Assert; @AutoConfiguration(after = ClientCredentialAutoConfiguration.class) public class TokenServiceAutoConfiguration { @@ -28,19 +27,17 @@ AzureTokenService azureAdTokenServiceTest( AzureClientCredential clientCredential, GetAuthenticatedToken getAuthenticatedToken ) { - return new AzureTokenService(null, null, clientCredential, getAuthenticatedToken); + return new AzureTokenService(null, clientCredential, getAuthenticatedToken); } @Bean @ConditionalOnDollyApplicationConfiguredForAzure @ConditionalOnMissingBean(AzureTokenService.class) AzureTokenService azureAdTokenService( - @Value("${AAD_ISSUER_URI:#{null}}") String issuerUrl, AzureClientCredential clientCredential, GetAuthenticatedToken getAuthenticatedToken ) { - Assert.notNull(issuerUrl, "AAD_ISSUER_URI must be set"); - return new AzureTokenService(httpProxy, issuerUrl, clientCredential, getAuthenticatedToken); + return new AzureTokenService(httpProxy, clientCredential, getAuthenticatedToken); } @Primary diff --git a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/azuread/AzureTokenService.java b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/azuread/AzureTokenService.java index 438dab7256a..e2a93dd9abf 100644 --- a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/azuread/AzureTokenService.java +++ b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/exchange/azuread/AzureTokenService.java @@ -33,7 +33,6 @@ public class AzureTokenService implements TokenService { public AzureTokenService( String proxyHost, - String issuerUrl, AzureClientCredential azureClientCredential, GetAuthenticatedToken getAuthenticatedToken ) { @@ -41,7 +40,7 @@ public AzureTokenService( WebClient.Builder builder = WebClient .builder() - .baseUrl(issuerUrl + "/oauth2/v2.0/token") + .baseUrl(azureClientCredential.getTokenEndpoint()) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); if (proxyHost != null) { diff --git a/libs/reactive-session-security/src/main/java/no/nav/testnav/libs/reactivesessionsecurity/exchange/AzureAdTokenExchange.java b/libs/reactive-session-security/src/main/java/no/nav/testnav/libs/reactivesessionsecurity/exchange/AzureAdTokenExchange.java index e3d73c62bd4..dfa1008594e 100644 --- a/libs/reactive-session-security/src/main/java/no/nav/testnav/libs/reactivesessionsecurity/exchange/AzureAdTokenExchange.java +++ b/libs/reactive-session-security/src/main/java/no/nav/testnav/libs/reactivesessionsecurity/exchange/AzureAdTokenExchange.java @@ -7,7 +7,6 @@ import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.securitycore.domain.azuread.AzureClientCredential; import no.nav.testnav.libs.securitycore.domain.azuread.ClientCredential; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; @@ -23,13 +22,12 @@ public class AzureAdTokenExchange implements ExchangeToken { private final ClientCredential clientCredential; public AzureAdTokenExchange( - @Value("${AAD_ISSUER_URI}") String issuerUrl, TokenResolver tokenResolver, AzureClientCredential clientCredential) { this.webClient = WebClient .builder() - .baseUrl(issuerUrl + "/oauth2/v2.0/token") + .baseUrl(clientCredential.getTokenEndpoint()) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE) .build(); this.tokenResolver = tokenResolver; @@ -47,4 +45,5 @@ public Mono exchange(ServerProperties serverProperties, ServerWebEx token ).call()); } + } diff --git a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ClientCredentialAutoConfiguration.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ClientCredentialAutoConfiguration.java index 581db32964e..6b084df6d42 100644 --- a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ClientCredentialAutoConfiguration.java +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ClientCredentialAutoConfiguration.java @@ -6,7 +6,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; -import org.springframework.util.Assert; @AutoConfiguration public class ClientCredentialAutoConfiguration { @@ -26,7 +25,7 @@ AzureClientCredential azureClientCredentialTest() { @ConditionalOnDollyApplicationConfiguredForAzure @ConditionalOnMissingBean(AzureClientCredential.class) AzureClientCredential azureClientCredential( - @Value("${AAD_ISSUER_URI}") String azureTokenEndpoint, // TODO: Not currently used, AAD_ISSUER_URI is hardcoded elsewhere; should be refactored to use AZURE_OPENID_CONFIG_TOKEN_ENDPOINT instead. + @Value("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}") String azureTokenEndpoint, @Value("${AZURE_APP_CLIENT_ID}") String azureClientId, @Value("${AZURE_APP_CLIENT_SECRET}") String azureClientSecret ) { diff --git a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ConditionalOnDollyApplicationConfiguredForAzure.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ConditionalOnDollyApplicationConfiguredForAzure.java index 31c111db587..9bd1d5f79f8 100644 --- a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ConditionalOnDollyApplicationConfiguredForAzure.java +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/azuread/ConditionalOnDollyApplicationConfiguredForAzure.java @@ -19,7 +19,7 @@ * Conditional that matches if the application is configured for Nav. * Requires the following properties set: *
    - *
  • AAD_ISSUER_URI
  • + *
  • AZURE_OPENID_CONFIG_TOKEN_ENDPOINT
  • *
  • AZURE_APP_CLIENT_ID
  • *
  • AZURE_APP_CLIENT_SECRET
  • *
@@ -33,7 +33,7 @@ class OnDollyApplicationConfiguredForAzureCondition extends SpringBootCondition { private static final List REQUIRED = Arrays.asList( - "AAD_ISSUER_URI", + "AZURE_OPENID_CONFIG_TOKEN_ENDPOINT", "AZURE_APP_CLIENT_ID", "AZURE_APP_CLIENT_SECRET" ); diff --git a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopOidcReactiveOAuth2UserService.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopOidcReactiveOAuth2UserService.java new file mode 100644 index 00000000000..7f059a7c6da --- /dev/null +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopOidcReactiveOAuth2UserService.java @@ -0,0 +1,55 @@ +package no.nav.testnav.libs.securitycore.oauth2.client.userinfo; + +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.oauth2.client.oidc.userinfo.OidcReactiveOAuth2UserService; +import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest; +import org.springframework.security.oauth2.core.OAuth2AuthenticationException; +import org.springframework.security.oauth2.core.oidc.OidcUserInfo; +import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser; +import org.springframework.security.oauth2.core.oidc.user.OidcUser; +import org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority; +import org.springframework.util.StringUtils; +import reactor.core.publisher.Mono; + +import java.util.LinkedHashSet; + +import static lombok.AccessLevel.PACKAGE; + +@RequiredArgsConstructor(access = PACKAGE) +class NoopOidcReactiveOAuth2UserService extends OidcReactiveOAuth2UserService { + + /** + * Stripped from {@code org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequestUtils#getUser(OidcUserRequest, OidcUserInfo)}. + * + * @param userRequest OIDC user request. + * @return OIDC user. + */ + private static OidcUser getUser(OidcUserRequest userRequest) { + + var authorities = new LinkedHashSet(); + authorities.add(new OidcUserAuthority(userRequest.getIdToken(), null)); + userRequest + .getAccessToken() + .getScopes() + .forEach(scope -> authorities.add(new SimpleGrantedAuthority("SCOPE_" + scope))); + var providerDetails = userRequest + .getClientRegistration() + .getProviderDetails(); + var userNameAttributeName = providerDetails + .getUserInfoEndpoint() + .getUserNameAttributeName(); + if (StringUtils.hasText(userNameAttributeName)) { + return new DefaultOidcUser(authorities, userRequest.getIdToken(), null, userNameAttributeName); + } + return new DefaultOidcUser(authorities, userRequest.getIdToken(), (OidcUserInfo) null); + + } + + @Override + public Mono loadUser(OidcUserRequest userRequest) throws OAuth2AuthenticationException { + return Mono.just(getUser(userRequest)); + } + +} diff --git a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOAuth2UserService.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOAuth2UserService.java new file mode 100644 index 00000000000..015b48b8491 --- /dev/null +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOAuth2UserService.java @@ -0,0 +1,20 @@ +package no.nav.testnav.libs.securitycore.oauth2.client.userinfo; + +import lombok.RequiredArgsConstructor; +import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; +import org.springframework.security.oauth2.client.userinfo.ReactiveOAuth2UserService; +import org.springframework.security.oauth2.core.OAuth2AuthenticationException; +import org.springframework.security.oauth2.core.user.OAuth2User; +import reactor.core.publisher.Mono; + +import static lombok.AccessLevel.PACKAGE; + +@RequiredArgsConstructor(access = PACKAGE) +class NoopReactiveOAuth2UserService implements ReactiveOAuth2UserService { + + @Override + public Mono loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { + return Mono.empty(); + } + +} diff --git a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOauth2AutoConfiguration.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOauth2AutoConfiguration.java new file mode 100644 index 00000000000..76d1dd6ef08 --- /dev/null +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOauth2AutoConfiguration.java @@ -0,0 +1,23 @@ +package no.nav.testnav.libs.securitycore.oauth2.client.userinfo; + +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.security.oauth2.client.oidc.userinfo.OidcReactiveOAuth2UserService; +import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; +import org.springframework.security.oauth2.client.userinfo.ReactiveOAuth2UserService; +import org.springframework.security.oauth2.core.user.OAuth2User; + +@AutoConfiguration +public class NoopReactiveOauth2AutoConfiguration { + + @Bean + public ReactiveOAuth2UserService reactiveOAuth2UserService() { + return new NoopReactiveOAuth2UserService(); + } + + @Bean + public OidcReactiveOAuth2UserService oidcReactiveOAuth2UserService() { + return new NoopOidcReactiveOAuth2UserService(); + } + +} diff --git a/libs/security-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/libs/security-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index c752f84a7da..2766868fe26 100644 --- a/libs/security-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/libs/security-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1,2 @@ -no.nav.testnav.libs.securitycore.domain.azuread.ClientCredentialAutoConfiguration \ No newline at end of file +no.nav.testnav.libs.securitycore.domain.azuread.ClientCredentialAutoConfiguration +no.nav.testnav.libs.securitycore.oauth2.client.userinfo.NoopReactiveOauth2AutoConfiguration \ No newline at end of file diff --git a/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/config/InsecureJwtServerToServerConfiguration.java b/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/config/InsecureJwtServerToServerConfiguration.java index 7f12945ced7..633135c22cf 100644 --- a/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/config/InsecureJwtServerToServerConfiguration.java +++ b/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/config/InsecureJwtServerToServerConfiguration.java @@ -7,9 +7,7 @@ import no.nav.testnav.libs.standalone.servletsecurity.properties.ResourceServerProperties; import no.nav.testnav.libs.standalone.servletsecurity.properties.TokenXResourceServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.*; import org.springframework.security.oauth2.jwt.JwtDecoder; import java.util.List; @@ -24,8 +22,17 @@ public class InsecureJwtServerToServerConfiguration { @Bean + @Profile("!test") @ConditionalOnMissingBean - public JwtDecoder jwtDecoder(List properties) { + JwtDecoder jwtDecoder(List properties) { return new MultipleIssuersJwtDecoder(properties); } + + @Bean + @Profile("test") + @ConditionalOnMissingBean + JwtDecoder jwtDecoderForTesting() { + return token -> null; + } + } \ No newline at end of file diff --git a/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/exchange/AzureAdTokenService.java b/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/exchange/AzureAdTokenService.java index ed6e1851df4..952f8451945 100644 --- a/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/exchange/AzureAdTokenService.java +++ b/libs/servlet-insecure-security/src/main/java/no/nav/testnav/libs/standalone/servletsecurity/exchange/AzureAdTokenService.java @@ -27,13 +27,13 @@ public class AzureAdTokenService implements ExchangeToken { public AzureAdTokenService( @Value("${http.proxy:#{null}}") String proxyHost, - @Value("${AAD_ISSUER_URI}") String issuerUrl, + @Value("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}") String tokenEndpoint, AzureClientCredential clientCredential ) { log.info("Init AzureAd token exchange."); WebClient.Builder builder = WebClient .builder() - .baseUrl(issuerUrl + "/oauth2/v2.0/token") + .baseUrl(tokenEndpoint) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); if (proxyHost != null) { diff --git a/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/config/SecureOAuth2ServerToServerConfiguration.java b/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/config/SecureOAuth2ServerToServerConfiguration.java index ffb286d1cfb..815ecd2be7e 100644 --- a/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/config/SecureOAuth2ServerToServerConfiguration.java +++ b/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/config/SecureOAuth2ServerToServerConfiguration.java @@ -1,11 +1,7 @@ package no.nav.testnav.libs.servletsecurity.config; import no.nav.testnav.libs.securitycore.domain.tokenx.TokenXProperties; -import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedId; -import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedResourceServerType; -import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedToken; -import no.nav.testnav.libs.servletsecurity.action.GetUserInfo; -import no.nav.testnav.libs.servletsecurity.action.GetUserJwt; +import no.nav.testnav.libs.servletsecurity.action.*; import no.nav.testnav.libs.servletsecurity.decoder.MultipleIssuersJwtDecoder; import no.nav.testnav.libs.servletsecurity.exchange.AzureAdTokenService; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; @@ -14,9 +10,7 @@ import no.nav.testnav.libs.servletsecurity.properties.ResourceServerProperties; import no.nav.testnav.libs.servletsecurity.properties.TokenXResourceServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.*; import org.springframework.security.oauth2.jwt.JwtDecoder; import java.util.List; @@ -37,10 +31,19 @@ }) public class SecureOAuth2ServerToServerConfiguration { + // TODO: There's also one in no.nav.testnav.libs.standalone.servletsecurity.config.SecureOAuth2ServerToServerConfiguration. testnav-ident-pool (and possibly others) includes both libraries. This should be fixed. @Bean + @Profile("!test") @ConditionalOnMissingBean - public JwtDecoder jwtDecoder(List properties) { + JwtDecoder jwtDecoder(List properties) { return new MultipleIssuersJwtDecoder(properties); } + @Bean + @Profile("test") + @ConditionalOnMissingBean + JwtDecoder jwtDecoderForTesting() { + return token -> null; + } + } \ No newline at end of file diff --git a/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/exchange/AzureAdTokenService.java b/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/exchange/AzureAdTokenService.java index 27b304895b0..a31f1e12107 100644 --- a/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/exchange/AzureAdTokenService.java +++ b/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/exchange/AzureAdTokenService.java @@ -23,6 +23,7 @@ import java.net.URI; +// TODO: Check no.nav.testnav.libs.standalone.servletsecurity.exchange.AzureAdTokenService and others. These behave differently. Note difference in issuerUri usage. @Slf4j @Service @ConditionalOnProperty("spring.security.oauth2.resourceserver.aad.issuer-uri") @@ -33,7 +34,7 @@ public class AzureAdTokenService implements TokenService { public AzureAdTokenService( @Value("${http.proxy:#{null}}") String proxyHost, - @Value("${AAD_ISSUER_URI}") String issuerUrl, + @Value("${spring.security.oauth2.resourceserver.aad.issuer-uri}") String issuerUri, AzureClientCredential clientCredential, GetAuthenticatedToken getAuthenticatedToken ) { @@ -41,7 +42,7 @@ public AzureAdTokenService( this.getAuthenticatedToken = getAuthenticatedToken; WebClient.Builder builder = WebClient .builder() - .baseUrl(issuerUrl + "/oauth2/v2.0/token") + .baseUrl(issuerUri) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); if (proxyHost != null) { diff --git a/proxies/aareg-proxy/src/main/resources/application.yml b/proxies/aareg-proxy/src/main/resources/application.yml index 33bcb2490dd..6fe0a3281fd 100644 --- a/proxies/aareg-proxy/src/main/resources/application.yml +++ b/proxies/aareg-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-aareg-proxy @@ -9,8 +7,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/aareg-proxy/src/test/resources/application-test.yml b/proxies/aareg-proxy/src/test/resources/application-test.yml index f05debbd219..23ddd58e63f 100644 --- a/proxies/aareg-proxy/src/test/resources/application-test.yml +++ b/proxies/aareg-proxy/src/test/resources/application-test.yml @@ -1 +1,2 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/proxies/aareg-synt-services-proxy/src/main/resources/application.yml b/proxies/aareg-synt-services-proxy/src/main/resources/application.yml index daa83573144..583e454396b 100644 --- a/proxies/aareg-synt-services-proxy/src/main/resources/application.yml +++ b/proxies/aareg-synt-services-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: aareg-synt-services-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/altinn3-tilgang-proxy/src/main/resources/application.yml b/proxies/altinn3-tilgang-proxy/src/main/resources/application.yml index b15c0a9538d..acb9317eb12 100644 --- a/proxies/altinn3-tilgang-proxy/src/main/resources/application.yml +++ b/proxies/altinn3-tilgang-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-altinn3-tilgang-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/altinn3-tilgang-proxy/src/test/java/no/nav/testnav/altinn3tilgangproxy/ApplicationContextTest.java b/proxies/altinn3-tilgang-proxy/src/test/java/no/nav/testnav/altinn3tilgangproxy/ApplicationContextTest.java index e630af4e0f0..430b4541772 100644 --- a/proxies/altinn3-tilgang-proxy/src/test/java/no/nav/testnav/altinn3tilgangproxy/ApplicationContextTest.java +++ b/proxies/altinn3-tilgang-proxy/src/test/java/no/nav/testnav/altinn3tilgangproxy/ApplicationContextTest.java @@ -2,8 +2,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.test.context.ActiveProfiles; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -12,10 +10,6 @@ @ActiveProfiles("test") class ApplicationContextTest { - @MockBean - @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; - @Test void load_app_context() { assertThat(true).isTrue(); diff --git a/proxies/altinn3-tilgang-proxy/src/test/resources/application-test.yml b/proxies/altinn3-tilgang-proxy/src/test/resources/application-test.yml index f05debbd219..73db9cfd898 100644 --- a/proxies/altinn3-tilgang-proxy/src/test/resources/application-test.yml +++ b/proxies/altinn3-tilgang-proxy/src/test/resources/application-test.yml @@ -1 +1,3 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/proxies/arbeidsplassencv-proxy/src/main/resources/application.yml b/proxies/arbeidsplassencv-proxy/src/main/resources/application.yml index 8502bac6bce..c2cab94969f 100644 --- a/proxies/arbeidsplassencv-proxy/src/main/resources/application.yml +++ b/proxies/arbeidsplassencv-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-arbeidsplassencv-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/arbeidsplassencv-proxy/src/test/resources/application-test.yml b/proxies/arbeidsplassencv-proxy/src/test/resources/application-test.yml index f00334410e1..8526ed1cd1d 100644 --- a/proxies/arbeidsplassencv-proxy/src/test/resources/application-test.yml +++ b/proxies/arbeidsplassencv-proxy/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy consumers: diff --git a/proxies/arena-forvalteren-proxy/src/main/resources/application.yml b/proxies/arena-forvalteren-proxy/src/main/resources/application.yml index 9e9ba088180..b05463d7e64 100644 --- a/proxies/arena-forvalteren-proxy/src/main/resources/application.yml +++ b/proxies/arena-forvalteren-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-arena-forvalteren-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/batch-adeo-proxy/src/main/resources/application.yml b/proxies/batch-adeo-proxy/src/main/resources/application.yml index 0a0c0e11f2d..a72b4042fb3 100644 --- a/proxies/batch-adeo-proxy/src/main/resources/application.yml +++ b/proxies/batch-adeo-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnorge-batch-adeo-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/brregstub-proxy/src/main/resources/application.yml b/proxies/brregstub-proxy/src/main/resources/application.yml index 95d8e31193b..ba1ebde6476 100644 --- a/proxies/brregstub-proxy/src/main/resources/application.yml +++ b/proxies/brregstub-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-brregstub-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/dokarkiv-proxy/src/main/resources/application.yml b/proxies/dokarkiv-proxy/src/main/resources/application.yml index 54adda5c8c0..14f7230c5ea 100644 --- a/proxies/dokarkiv-proxy/src/main/resources/application.yml +++ b/proxies/dokarkiv-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-dokarkiv-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/dokarkiv-proxy/src/test/resources/application-test.yml b/proxies/dokarkiv-proxy/src/test/resources/application-test.yml index 24e4a7df170..64fb5fcfd6e 100644 --- a/proxies/dokarkiv-proxy/src/test/resources/application-test.yml +++ b/proxies/dokarkiv-proxy/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy consumers: diff --git a/proxies/ereg-proxy/src/main/resources/application.yml b/proxies/ereg-proxy/src/main/resources/application.yml index ef711ef083a..7c16ec0372c 100644 --- a/proxies/ereg-proxy/src/main/resources/application.yml +++ b/proxies/ereg-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-ereg-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/fullmakt-proxy/src/main/resources/application.yml b/proxies/fullmakt-proxy/src/main/resources/application.yml index da6230fc5bd..01a0a8cd7ba 100644 --- a/proxies/fullmakt-proxy/src/main/resources/application.yml +++ b/proxies/fullmakt-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-fullmakt-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/fullmakt-proxy/src/test/resources/application-test.yml b/proxies/fullmakt-proxy/src/test/resources/application-test.yml index f05debbd219..23ddd58e63f 100644 --- a/proxies/fullmakt-proxy/src/test/resources/application-test.yml +++ b/proxies/fullmakt-proxy/src/test/resources/application-test.yml @@ -1 +1,2 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/proxies/histark-proxy/src/main/resources/application.yml b/proxies/histark-proxy/src/main/resources/application.yml index a7fe5e1b935..d46e9f3b3b4 100644 --- a/proxies/histark-proxy/src/main/resources/application.yml +++ b/proxies/histark-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-histark-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/inntektstub-proxy/src/main/resources/application.yml b/proxies/inntektstub-proxy/src/main/resources/application.yml index 95e755ce129..b5f3745c83f 100644 --- a/proxies/inntektstub-proxy/src/main/resources/application.yml +++ b/proxies/inntektstub-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-inntektstub-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/inst-proxy/src/main/resources/application.yml b/proxies/inst-proxy/src/main/resources/application.yml index 59199e982f5..c3b2f55bce1 100644 --- a/proxies/inst-proxy/src/main/resources/application.yml +++ b/proxies/inst-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-inst-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/kontoregister-person-proxy/src/main/resources/application.yml b/proxies/kontoregister-person-proxy/src/main/resources/application.yml index 1a9a7c4764f..664ba9bcd28 100644 --- a/proxies/kontoregister-person-proxy/src/main/resources/application.yml +++ b/proxies/kontoregister-person-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-kontoregister-person-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/kontoregister-person-proxy/src/test/resources/application-test.yml b/proxies/kontoregister-person-proxy/src/test/resources/application-test.yml index f05debbd219..23ddd58e63f 100644 --- a/proxies/kontoregister-person-proxy/src/test/resources/application-test.yml +++ b/proxies/kontoregister-person-proxy/src/test/resources/application-test.yml @@ -1 +1,2 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/proxies/krrstub-proxy/src/main/resources/application.yml b/proxies/krrstub-proxy/src/main/resources/application.yml index 0316918759f..59b851fc383 100644 --- a/proxies/krrstub-proxy/src/main/resources/application.yml +++ b/proxies/krrstub-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-krrstub-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/krrstub-proxy/src/test/resources/application-test.yml b/proxies/krrstub-proxy/src/test/resources/application-test.yml index f05debbd219..23ddd58e63f 100644 --- a/proxies/krrstub-proxy/src/test/resources/application-test.yml +++ b/proxies/krrstub-proxy/src/test/resources/application-test.yml @@ -1 +1,2 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/proxies/medl-proxy/src/main/resources/application.yml b/proxies/medl-proxy/src/main/resources/application.yml index 733b6839ef3..a4d9a44db4f 100644 --- a/proxies/medl-proxy/src/main/resources/application.yml +++ b/proxies/medl-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-medl-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/medl-proxy/src/test/resources/application-test.yml b/proxies/medl-proxy/src/test/resources/application-test.yml index f05debbd219..23ddd58e63f 100644 --- a/proxies/medl-proxy/src/test/resources/application-test.yml +++ b/proxies/medl-proxy/src/test/resources/application-test.yml @@ -1 +1,2 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/proxies/norg2-proxy/src/main/resources/application.yml b/proxies/norg2-proxy/src/main/resources/application.yml index bc9ce452a8f..8fbbfb6f768 100644 --- a/proxies/norg2-proxy/src/main/resources/application.yml +++ b/proxies/norg2-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-norg2-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/pdl-proxy/src/main/resources/application-local.yml b/proxies/pdl-proxy/src/main/resources/application-local.yml index 97c5228e923..9f20ea44a96 100644 --- a/proxies/pdl-proxy/src/main/resources/application-local.yml +++ b/proxies/pdl-proxy/src/main/resources/application-local.yml @@ -1,9 +1,11 @@ AZURE_APP_CLIENT_ID: ${sm://azure-app-client-id} AZURE_APP_CLIENT_SECRET: ${sm://azure-app-client-secret} +AZURE_OPENID_CONFIG_ISSUER: ${sm://azure-openid-config-issuer} +AZURE_OPENID_CONFIG_JWKS_URI: ${sm://azure-openid-config-jwks-uri} AZURE_TRYGDEETATEN_APP_CLIENT_ID: placeholder AZURE_TRYGDEETATEN_APP_CLIENT_SECRET: placeholder -AZURE_TRYGDEETATEN_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder -TOKEN_X_ISSUER: dummy +AZURE_TRYGDEETATEN_OPENID_CONFIG_TOKEN_ENDPOINT: ${sm://azure-trygdeetaten-openid-config-token-endpoint} +TOKEN_X_ISSUER: ${sm://token-x-issuer} spring: cloud: diff --git a/proxies/pdl-proxy/src/main/resources/application.yml b/proxies/pdl-proxy/src/main/resources/application.yml index 853643daed8..0d5136ebc4e 100644 --- a/proxies/pdl-proxy/src/main/resources/application.yml +++ b/proxies/pdl-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-pdl-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/pdl-proxy/src/test/resources/application-test.yml b/proxies/pdl-proxy/src/test/resources/application-test.yml index 8c7464c31b9..c0691176123 100644 --- a/proxies/pdl-proxy/src/test/resources/application-test.yml +++ b/proxies/pdl-proxy/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: placeholder app: diff --git a/proxies/pensjon-testdata-facade-proxy/src/main/resources/application.yml b/proxies/pensjon-testdata-facade-proxy/src/main/resources/application.yml index 3d4b23beb61..2b1ba12b46d 100644 --- a/proxies/pensjon-testdata-facade-proxy/src/main/resources/application.yml +++ b/proxies/pensjon-testdata-facade-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: pensjon-testdata-facade-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} cloud: gateway: diff --git a/proxies/pensjon-testdata-facade-proxy/src/test/resources/application-test.yml b/proxies/pensjon-testdata-facade-proxy/src/test/resources/application-test.yml index 2deeda02e69..de6c588aba5 100644 --- a/proxies/pensjon-testdata-facade-proxy/src/test/resources/application-test.yml +++ b/proxies/pensjon-testdata-facade-proxy/src/test/resources/application-test.yml @@ -1,3 +1,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder + consumers: samboer-testdata: name: pensjon-dummy diff --git a/proxies/saf-proxy/src/main/resources/application.yml b/proxies/saf-proxy/src/main/resources/application.yml index acd7c3e6046..bebe5488c86 100644 --- a/proxies/saf-proxy/src/main/resources/application.yml +++ b/proxies/saf-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-saf-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/saf-proxy/src/test/resources/application-test.yml b/proxies/saf-proxy/src/test/resources/application-test.yml index d9e6fdf44ba..a1986783a53 100644 --- a/proxies/saf-proxy/src/test/resources/application-test.yml +++ b/proxies/saf-proxy/src/test/resources/application-test.yml @@ -1,3 +1,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy consumers: diff --git a/proxies/sigrunstub-proxy/src/main/resources/application.yml b/proxies/sigrunstub-proxy/src/main/resources/application.yml index 27bfb2e6c35..282565ead17 100644 --- a/proxies/sigrunstub-proxy/src/main/resources/application.yml +++ b/proxies/sigrunstub-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-sigrunstub-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/skjermingsregister-proxy/src/main/resources/application.yml b/proxies/skjermingsregister-proxy/src/main/resources/application.yml index 4db5b00c8b2..eb934347219 100644 --- a/proxies/skjermingsregister-proxy/src/main/resources/application.yml +++ b/proxies/skjermingsregister-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-skjermingsregister-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/sykemelding-proxy/src/main/resources/application.yml b/proxies/sykemelding-proxy/src/main/resources/application.yml index 1d29c30041d..ae092b2b6a5 100644 --- a/proxies/sykemelding-proxy/src/main/resources/application.yml +++ b/proxies/sykemelding-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-sykemelding-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/udistub-proxy/src/main/resources/application.yml b/proxies/udistub-proxy/src/main/resources/application.yml index 04caa6c4b90..05d8367e905 100644 --- a/proxies/udistub-proxy/src/main/resources/application.yml +++ b/proxies/udistub-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-udistub-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} tokenx: issuer-uri: ${TOKEN_X_ISSUER} diff --git a/proxies/udistub-proxy/src/test/resources/application-test.yml b/proxies/udistub-proxy/src/test/resources/application-test.yml index f05debbd219..23ddd58e63f 100644 --- a/proxies/udistub-proxy/src/test/resources/application-test.yml +++ b/proxies/udistub-proxy/src/test/resources/application-test.yml @@ -1 +1,2 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/proxies/yrkesskade-proxy/src/main/resources/application.yml b/proxies/yrkesskade-proxy/src/main/resources/application.yml index 49de1dcebe7..12952ea6e51 100644 --- a/proxies/yrkesskade-proxy/src/main/resources/application.yml +++ b/proxies/yrkesskade-proxy/src/main/resources/application.yml @@ -1,5 +1,3 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - spring: application: name: testnav-pdl-proxy @@ -8,8 +6,8 @@ spring: oauth2: resourceserver: aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} accepted-audience: ${AZURE_APP_CLIENT_ID}, api:// ${AZURE_APP_CLIENT_ID} cloud: gateway: