From 46659116a4e757a2d21027d7463aeaeb8502bee1 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 19 Dec 2024 12:39:32 +0100 Subject: [PATCH 01/28] Remove explicit reference to AAD_ISSUER_URI - already in received AzureClientCredential and verified by ConditionalOnDollyApplicationConfiguredForAzure. --- .../exchange/TokenServiceAutoConfiguration.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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..f6a7f4dd299 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 { @@ -35,11 +34,10 @@ AzureTokenService azureAdTokenServiceTest( @ConditionalOnDollyApplicationConfiguredForAzure @ConditionalOnMissingBean(AzureTokenService.class) AzureTokenService azureAdTokenService( - @Value("${AAD_ISSUER_URI:#{null}}") String issuerUrl, + String issuerUrl, AzureClientCredential clientCredential, GetAuthenticatedToken getAuthenticatedToken ) { - Assert.notNull(issuerUrl, "AAD_ISSUER_URI must be set"); return new AzureTokenService(httpProxy, issuerUrl, clientCredential, getAuthenticatedToken); } From 0b75b21b626d4a00f43a051a9810f83026ce87ef Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 19 Dec 2024 13:21:01 +0100 Subject: [PATCH 02/28] Removed usage of AAD_ISSUER_URI for pdl-proxy, for initial sanity check. --- .../exchange/TokenServiceAutoConfiguration.java | 5 ++--- .../exchange/azuread/AzureTokenService.java | 3 +-- .../domain/azuread/ClientCredentialAutoConfiguration.java | 3 +-- .../ConditionalOnDollyApplicationConfiguredForAzure.java | 4 ++-- proxies/pdl-proxy/src/main/resources/application-local.yml | 6 ++++-- proxies/pdl-proxy/src/main/resources/application.yml | 6 ++---- 6 files changed, 12 insertions(+), 15 deletions(-) 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 f6a7f4dd299..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 @@ -27,18 +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( - String issuerUrl, AzureClientCredential clientCredential, GetAuthenticatedToken getAuthenticatedToken ) { - 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/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: * @@ -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/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} From 8cb87b9cd4a9c4145004bb2542f4d84b8adc9cec Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 11:24:34 +0100 Subject: [PATCH 03/28] - Setting issuer-uri from AZURE_OPENID_CONFIG_ISSUER. - Setting jwk-set-uri from AZURE_OPENID_CONFIG_JWKS_URI. - Setting token-uri from AZURE_OPENID_CONFIG_TOKEN_ENDPOINT. - Setting authorization-uri from an unholy use of SpEL and AZURE_OPENID_CONFIG_TOKEN_ENDPOINT (tentatively). - Removed hardcoded AAD_ISSUER_URI from YAML config. - Replaced usage of AAD_ISSUER_URI in no.nav.testnav.libs.standalone.servletsecurity.exchange.AzureAdTokenService with AZURE_OPENID_CONFIG_TOKEN_ENDPOINT. - Replaced usage of AAD_ISSUER_URI in no.nav.testnav.libs.servletsecurity.exchange.AzureAdTokenService with spring.security.oauth2.resourceserver.aad.issuer-uri (to match @ConditionalOnProperty; note difference between above AzureAdTokenService). --- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application-local.yml | 6 +++--- .../src/main/resources/application.yml | 5 ++--- .../src/main/resources/application.yml | 8 +++----- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 8 +++----- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/test/resources/application-test.yml | 3 ++- .../src/main/resources/application.yml | 5 ++--- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 5 ++--- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/test/resources/application-test.yml | 16 ++++------------ .../src/main/resources/application.yml | 5 ++--- .../src/main/resources/application.yml | 2 -- .../src/main/resources/application.yml | 6 ++---- .../src/test/resources/application-test.yml | 5 +++-- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- apps/udi-stub/src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../exchange/AzureAdTokenService.java | 4 ++-- .../exchange/AzureAdTokenService.java | 5 +++-- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../saf-proxy/src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- .../src/main/resources/application.yml | 6 ++---- 82 files changed, 169 insertions(+), 322 deletions(-) diff --git a/apps/adresse-service/src/main/resources/application.yml b/apps/adresse-service/src/main/resources/application.yml index 5b96088b72e..317c9b3707d 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/altinn3-tilgang-service/src/main/resources/application.yml b/apps/altinn3-tilgang-service/src/main/resources/application.yml index 70a799743f3..5b09a8f5c36 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/amelding-service/src/main/resources/application.yml b/apps/amelding-service/src/main/resources/application.yml index e90182fd21e..983d3010b43 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/app-tilgang-analyse-service/src/main/resources/application.yml b/apps/app-tilgang-analyse-service/src/main/resources/application.yml index ebf58a884c3..289bfc019c6 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/arbeidsforhold-service/src/main/resources/application.yml b/apps/arbeidsforhold-service/src/main/resources/application.yml index 9e816896986..2d9ac3d71de 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/batch-bestilling-service/src/main/resources/application.yml b/apps/batch-bestilling-service/src/main/resources/application.yml index 5e056d09e77..6ff3db40800 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/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 6caad4f8bde..367885d9138 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-frontend/src/main/resources/application-local.yml b/apps/dolly-frontend/src/main/resources/application-local.yml index 8cb8c235ba2..82991790759 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: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. + 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 69f5d0d1672..1891ad1a05e 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/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 38f3e2e9a89..209aa841a9f 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 @@ -18,9 +16,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: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. + token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} consumers: endringsmelding-service: diff --git a/apps/endringsmelding-service/src/main/resources/application.yml b/apps/endringsmelding-service/src/main/resources/application.yml index d7cdb8c63fc..e6be0445911 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/faste-data-frontend/src/main/resources/application.yml b/apps/faste-data-frontend/src/main/resources/application.yml index 47faf21eb99..ff07d0a422e 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: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. + token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} + jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} consumers: testnorge-profil-api: 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 3c4d2f1263e..1f30f24d1f7 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-navn-service/src/main/resources/application.yml b/apps/generer-navn-service/src/main/resources/application.yml index 5777e19d691..afe56aad2ae 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-organisasjon-populasjon-service/src/main/resources/application.yml b/apps/generer-organisasjon-populasjon-service/src/main/resources/application.yml index 241b6cc21ef..c3083fdbacb 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-synt-amelding-service/src/main/resources/application.yml b/apps/generer-synt-amelding-service/src/main/resources/application.yml index e50b841c107..c23ea5adbb6 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/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 43f90ed6aca..d08001b711a 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/inntektsmelding-generator-service/src/main/resources/application.yml b/apps/inntektsmelding-generator-service/src/main/resources/application.yml index 593df4d3e10..4fa0ef7e06e 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-service/src/main/resources/application.yml b/apps/inntektsmelding-service/src/main/resources/application.yml index dc654d232cf..2345515a7bf 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/jenkins-batch-status-service/src/main/resources/application.yml b/apps/jenkins-batch-status-service/src/main/resources/application.yml index 12bda26837d..7fa544d0cb2 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/joark-dokument-service/src/main/resources/application.yml b/apps/joark-dokument-service/src/main/resources/application.yml index 50215c47d64..f0aa2439762 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/kodeverk-service/src/main/resources/application.yml b/apps/kodeverk-service/src/main/resources/application.yml index 824b314a535..139e299eefd 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/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml b/apps/levende-arbeidsforhold-ansettelse/src/main/resources/application.yml index 29a6a0e10d4..6089a8e39b3 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-scheduler/src/main/resources/application.yml b/apps/levende-arbeidsforhold-scheduler/src/main/resources/application.yml index e1281b264c9..81a864265d5 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-service/src/main/resources/application.yml b/apps/levende-arbeidsforhold-service/src/main/resources/application.yml index bd6d7946969..2c40dd47f80 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/miljoer-service/src/main/resources/application.yml b/apps/miljoer-service/src/main/resources/application.yml index 41fae00bc00..f6782b318d6 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/oppsummeringsdokument-service/src/main/resources/application.yml b/apps/oppsummeringsdokument-service/src/main/resources/application.yml index a3800a156d5..61cbe3a9a0b 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 5d10b138922..da939b97b5e 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-faste-data-service/src/main/resources/application.yml b/apps/organisasjon-faste-data-service/src/main/resources/application.yml index b35c5e82706..5c677b6799d 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-forvalter/src/main/resources/application.yml b/apps/organisasjon-forvalter/src/main/resources/application.yml index 095c0107efa..d87567e37b6 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-mottak-service/src/main/resources/application.yml b/apps/organisasjon-mottak-service/src/main/resources/application.yml index f5454299df6..5e354e4dff3 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-service/src/main/resources/application.yml b/apps/organisasjon-service/src/main/resources/application.yml index 9f897c11c45..71042e0a784 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-tilgang-service/src/main/resources/application.yml b/apps/organisasjon-tilgang-service/src/main/resources/application.yml index 543d3d30f23..f3d12a775d1 100644 --- a/apps/organisasjon-tilgang-service/src/main/resources/application.yml +++ b/apps/organisasjon-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/orgnummer-service/src/main/resources/application.yml b/apps/orgnummer-service/src/main/resources/application.yml index 7928e2c4f00..13a524755b0 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/oversikt-frontend/src/main/resources/application.yml b/apps/oversikt-frontend/src/main/resources/application.yml index cab26a3240a..d1327f9d292 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 e2b6c90f4ca..a1f39fdd336 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 96c6b85b36e..1d090804eed 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-organisasjon-tilgang-service/src/main/resources/application.yml b/apps/person-organisasjon-tilgang-service/src/main/resources/application.yml index 1da5b3b1184..349fb8f28ad 100644 --- a/apps/person-organisasjon-tilgang-service/src/main/resources/application.yml +++ b/apps/person-organisasjon-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/person-search-service/src/main/resources/application.yml b/apps/person-search-service/src/main/resources/application.yml index 1aecee96702..70ea8adfb90 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-service/src/main/resources/application.yml b/apps/person-service/src/main/resources/application.yml index 6a61ab08e39..5a1ba6e80e9 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/profil-api/src/main/resources/application.yml b/apps/profil-api/src/main/resources/application.yml index 4c9b6cac076..ba09230e7db 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/skattekort-service/src/main/resources/application.yml b/apps/skattekort-service/src/main/resources/application.yml index 51e2bcada96..27345c0d139 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/sykemelding-api/src/main/resources/application.yml b/apps/sykemelding-api/src/main/resources/application.yml index f1e9d0240b5..efb1aca5e9f 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 a9ff3f6ba65..eb49d1d325e 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-vedtakshistorikk-service/src/main/resources/application.yml b/apps/synt-vedtakshistorikk-service/src/main/resources/application.yml index 12285d7ae0a..1f3335ff0d2 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/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 765f641ea55..3e245155a57 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/testnav-ident-pool/src/main/resources/application.yml b/apps/testnav-ident-pool/src/main/resources/application.yml index eec84e92cc7..7fad34ab218 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/testnorge-statisk-data-forvalter/src/main/resources/application.yml b/apps/testnorge-statisk-data-forvalter/src/main/resources/application.yml index fb9d79b9227..d4d263223da 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/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 f90336663c1..379ca481ab0 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/tps-messaging-service/src/main/resources/application.yml b/apps/tps-messaging-service/src/main/resources/application.yml index c36f3d7945a..bdb161c0dd4 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/udi-stub/src/main/resources/application.yml b/apps/udi-stub/src/main/resources/application.yml index 0072dcc00e8..cabce0a320a 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/varslinger-service/src/main/resources/application.yml b/apps/varslinger-service/src/main/resources/application.yml index 2308249ef43..d572f32fb14 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/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/exchange/AzureAdTokenService.java b/libs/servlet-security/src/main/java/no/nav/testnav/libs/servletsecurity/exchange/AzureAdTokenService.java index 27b304895b0..0ef59a84b9d 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 @@ -25,6 +25,7 @@ @Slf4j @Service +// TODO: Check no.nav.testnav.libs.servletsecurity.exchange.AzureAdTokenService. These behave differently. @ConditionalOnProperty("spring.security.oauth2.resourceserver.aad.issuer-uri") public class AzureAdTokenService implements TokenService { private final WebClient webClient; @@ -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-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/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/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/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/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/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/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/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/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/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/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/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: From 349c2930a553a528ab8686ade7f7b1e0d28f412b Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 11:45:34 +0100 Subject: [PATCH 04/28] Used AAD_ISSUER_URI directly to resolve token endpoint. Now using token endpoint from config. --- .../exchange/AzureAdTokenExchange.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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()); } + } From 1128e922ca57269ae5e796bcc08585dfe673e5b4 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 11:46:42 +0100 Subject: [PATCH 05/28] Test cleanup. --- .../endringsmeldingfrontend/ApplicationContextTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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..ed254dcdb34 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 @@ -6,15 +6,19 @@ 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; + @SuppressWarnings("unused") + private JwtDecoder jwtDecoder; @Test @SuppressWarnings("java:S2699") void load_app_context() { + assertThat(true).isTrue(); } } From afac2312e006080310af4119eda7e6ed9ee9f517 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 12:56:40 +0100 Subject: [PATCH 06/28] Testing use of issuer-uri instead of authorization-uri. --- .../src/main/resources/application-local.yml | 3 +++ .../src/main/resources/application.yml | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/endringsmelding-frontend/src/main/resources/application-local.yml b/apps/endringsmelding-frontend/src/main/resources/application-local.yml index baa3afe677c..b26d7b4a5c3 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_OPENID_CONFIG_TOKEN_ENDPOINT: ${sm://azure-openid-config-token-endpoint} +AZURE_OPENID_CONFIG_JWKS_URI: ${sm://azure-openid-config-jwks-uri} +AZURE_OPENID_CONFIG_ISSUER: ${sm://azure-openid-config-issuer} spring: config: diff --git a/apps/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 209aa841a9f..99247f45d56 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -9,16 +9,16 @@ 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 provider: aad: - authorization-uri: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. - token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} + token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} consumers: endringsmelding-service: From a10f9f0f6d04061cb0cdd67c8221a00a39fe11fd Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 13:13:19 +0100 Subject: [PATCH 07/28] Fixed test by mocking ReactiveClientRegistrationRepository. --- .../apps/endringsmeldingfrontend/ApplicationContextTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 ed254dcdb34..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,7 +3,7 @@ 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; @@ -14,11 +14,12 @@ class ApplicationContextTest { @MockBean @SuppressWarnings("unused") - private JwtDecoder jwtDecoder; + private ReactiveClientRegistrationRepository reactiveClientRegistrationRepository; @Test @SuppressWarnings("java:S2699") void load_app_context() { assertThat(true).isTrue(); } + } From 7dfe0003843317a1e2805d13cc1911db6d076048 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 14:07:49 +0100 Subject: [PATCH 08/28] Testing with only issuer-uri (relying on well-known). --- apps/dolly-frontend/src/main/resources/application-local.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dolly-frontend/src/main/resources/application-local.yml b/apps/dolly-frontend/src/main/resources/application-local.yml index 82991790759..5ea0d8c34df 100644 --- a/apps/dolly-frontend/src/main/resources/application-local.yml +++ b/apps/dolly-frontend/src/main/resources/application-local.yml @@ -22,7 +22,7 @@ spring: client-secret: ${AZURE_APP_CLIENT_SECRET} provider: aad: - authorization-uri: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. + 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} From ad21b6c828499511fe8b0da2f9b76230442078fb Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 14:11:50 +0100 Subject: [PATCH 09/28] Revert "Testing with only issuer-uri (relying on well-known)." This reverts commit 7dfe0003843317a1e2805d13cc1911db6d076048. --- apps/dolly-frontend/src/main/resources/application-local.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dolly-frontend/src/main/resources/application-local.yml b/apps/dolly-frontend/src/main/resources/application-local.yml index 5ea0d8c34df..82991790759 100644 --- a/apps/dolly-frontend/src/main/resources/application-local.yml +++ b/apps/dolly-frontend/src/main/resources/application-local.yml @@ -22,7 +22,7 @@ spring: client-secret: ${AZURE_APP_CLIENT_SECRET} provider: aad: - 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. + authorization-uri: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} From bf6f263effc1e9ca765bb03d9911dc1e0c7d1e68 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 14:14:35 +0100 Subject: [PATCH 10/28] Removes SpEL magic with hardcoding (for now). --- apps/dolly-frontend/src/main/resources/application-local.yml | 2 +- apps/faste-data-frontend/src/main/resources/application.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dolly-frontend/src/main/resources/application-local.yml b/apps/dolly-frontend/src/main/resources/application-local.yml index 82991790759..5ea0d8c34df 100644 --- a/apps/dolly-frontend/src/main/resources/application-local.yml +++ b/apps/dolly-frontend/src/main/resources/application-local.yml @@ -22,7 +22,7 @@ spring: client-secret: ${AZURE_APP_CLIENT_SECRET} provider: aad: - authorization-uri: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. + 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} diff --git a/apps/faste-data-frontend/src/main/resources/application.yml b/apps/faste-data-frontend/src/main/resources/application.yml index ff07d0a422e..949e1655bd9 100644 --- a/apps/faste-data-frontend/src/main/resources/application.yml +++ b/apps/faste-data-frontend/src/main/resources/application.yml @@ -19,7 +19,7 @@ spring: scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: aad: - authorization-uri: '#{T(java.lang.String).valueOf("${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT}").replace("token", "authorize")}' # Not directly set by NAIS. + 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} From e4c30b1d1bc43cf00f795562556acc3830dbb970 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 14:14:49 +0100 Subject: [PATCH 11/28] Testing with only issuer-uri (relying on well-known). --- .../src/main/resources/application.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 99247f45d56..572046a27f4 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -16,9 +16,7 @@ spring: scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: aad: - issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} - jwk-set-uri: ${AZURE_OPENID_CONFIG_JWKS_URI} - token-uri: ${AZURE_OPENID_CONFIG_TOKEN_ENDPOINT} + issuer-uri: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b/v2.0 consumers: endringsmelding-service: From 4210958b2abf00b96e34363192d4ef8371c8d982 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 14:56:07 +0100 Subject: [PATCH 12/28] - Added Spring Security debug logging. - Changed provider to azure. --- .../src/main/resources/application-local.yml | 3 +-- .../src/main/resources/application.yml | 8 ++++---- .../src/main/resources/logback-spring.xml | 2 ++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/endringsmelding-frontend/src/main/resources/application-local.yml b/apps/endringsmelding-frontend/src/main/resources/application-local.yml index b26d7b4a5c3..dbe599bab04 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application-local.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application-local.yml @@ -1,8 +1,7 @@ AZURE_APP_CLIENT_ID: ${sm://azure-app-client-id} AZURE_APP_CLIENT_SECRET: ${sm://azure-app-client-secret} -AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: ${sm://azure-openid-config-token-endpoint} -AZURE_OPENID_CONFIG_JWKS_URI: ${sm://azure-openid-config-jwks-uri} 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 572046a27f4..2abd52c2258 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -8,15 +8,15 @@ spring: oauth2: client: registration: - aad: + azure: authorization-grant-type: authorization_code client-id: ${AZURE_APP_CLIENT_ID} client-secret: ${AZURE_APP_CLIENT_SECRET} redirect-uri: '{baseUrl}/login/oauth2/code/{registrationId}' - scope: openid, ${AZURE_APP_CLIENT_ID}/.default + scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: - aad: - issuer-uri: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b/v2.0 + azure: + 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 From 67b0185db18793e3b7b2943bcc72a4552610eee7 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 15:29:54 +0100 Subject: [PATCH 13/28] Changes reply URLs. --- apps/endringsmelding-frontend/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/endringsmelding-frontend/config.yml b/apps/endringsmelding-frontend/config.yml index a4f37bf4cd2..42dd9fd5733 100644 --- a/apps/endringsmelding-frontend/config.yml +++ b/apps/endringsmelding-frontend/config.yml @@ -12,8 +12,8 @@ spec: enabled: true tenant: nav.no replyURLs: - - "https://testnav-endringsmelding.intern.dev.nav.no/login/oauth2/code/aad" - - "http://localhost:8080/login/oauth2/code/aad" + - "https://testnav-endringsmelding.intern.dev.nav.no/login/oauth2/code/azure" + - "http://localhost:8080/login/oauth2/code/azure" claims: groups: - id: 9c7efec1-1599-4216-a67e-6fd53a6a951c From 8362c3737f776c5fb67a1207cd2d02ceab567542 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Fri, 20 Dec 2024 16:23:18 +0100 Subject: [PATCH 14/28] Test using AZURE_APP_TENANT_ID. --- .../src/main/resources/application-local.yml | 1 + .../src/main/resources/application.yml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/endringsmelding-frontend/src/main/resources/application-local.yml b/apps/endringsmelding-frontend/src/main/resources/application-local.yml index dbe599bab04..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,6 @@ 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} diff --git a/apps/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 2abd52c2258..39c1dd3a6b8 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -16,7 +16,9 @@ spring: scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: azure: - issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} + authorization-uri: https://login.microsoftonline.com/${AZURE_APP_TENANT_ID}/oauth2/v2.0/authorize + token-uri: https://login.microsoftonline.com/${AZURE_APP_TENANT_ID}/oauth2/v2.0/token + jwk-set-uri: https://login.microsoftonline.com/${AZURE_APP_TENANT_ID}/discovery/v2.0/keys consumers: endringsmelding-service: From da5e8d5781930acd41e0a427e7e7b6bd5187c7cd Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Sat, 21 Dec 2024 14:19:16 +0100 Subject: [PATCH 15/28] Back to issuer-uri, but now with a CustomOidcUserService that dont' look up user info. --- .../config/CustomOidcUserService.java | 51 +++++++++++++++++++ .../config/SecurityConfig.java | 25 +++++++-- .../src/main/resources/application.yml | 4 +- 3 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcUserService.java diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcUserService.java b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcUserService.java new file mode 100644 index 00000000000..e8f902eb6b3 --- /dev/null +++ b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcUserService.java @@ -0,0 +1,51 @@ +package no.nav.testnav.apps.endringsmeldingfrontend.config; + +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest; +import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService; +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.stereotype.Service; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashSet; +import java.util.function.BiFunction; + +@Service +@RequiredArgsConstructor +class CustomOidcUserService extends OidcUserService { + + private final BiFunction oidcUserMapper = CustomOidcUserService::getUser; + + private static OidcUser getUser(OidcUserRequest userRequest, OidcUserInfo userInfo) { + var authorities = new LinkedHashSet(); + authorities.add(new OidcUserAuthority(userRequest.getIdToken(), userInfo)); + var token = userRequest.getAccessToken(); + token + .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(), userInfo, userNameAttributeName); + } + return new DefaultOidcUser(authorities, userRequest.getIdToken(), userInfo); + } + + @Override + public OidcUser loadUser(OidcUserRequest userRequest) throws OAuth2AuthenticationException { + Assert.notNull(userRequest, "userRequest cannot be null"); + return oidcUserMapper.apply(userRequest, null); + } + +} 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..7be66adc883 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 @@ -4,6 +4,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest; +import org.springframework.security.oauth2.client.userinfo.OAuth2UserService; +import org.springframework.security.oauth2.core.oidc.user.OidcUser; import org.springframework.security.web.server.SecurityWebFilterChain; @@ -13,13 +16,25 @@ public class SecurityConfig { @Bean public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { - return http.cors(ServerHttpSecurity.CorsSpec::disable) + 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(oauth2Login -> { }) .build(); } + + @Bean + public OAuth2UserService oidcUserService() { + return new CustomOidcUserService(); + } + } diff --git a/apps/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 39c1dd3a6b8..2abd52c2258 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -16,9 +16,7 @@ spring: scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: azure: - authorization-uri: https://login.microsoftonline.com/${AZURE_APP_TENANT_ID}/oauth2/v2.0/authorize - token-uri: https://login.microsoftonline.com/${AZURE_APP_TENANT_ID}/oauth2/v2.0/token - jwk-set-uri: https://login.microsoftonline.com/${AZURE_APP_TENANT_ID}/discovery/v2.0/keys + issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} consumers: endringsmelding-service: From 3b1c2d2db5770298b9fc48e9d2a1845f6149a437 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Tue, 24 Dec 2024 16:07:05 +0100 Subject: [PATCH 16/28] - Added a CustomOidcReactiveOAuth2UserService bean. - Added a CustomReactiveOAuth2UserService bean. --- ... CustomOidcReactiveOAuth2UserService.java} | 38 ++++++++++--------- .../CustomReactiveOAuth2UserService.java | 20 ++++++++++ .../config/CustomReactiveOauth2Config.java | 23 +++++++++++ .../config/SecurityConfig.java | 15 ++------ 4 files changed, 68 insertions(+), 28 deletions(-) rename apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/{CustomOidcUserService.java => CustomOidcReactiveOAuth2UserService.java} (65%) create mode 100644 apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java create mode 100644 apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcUserService.java b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcReactiveOAuth2UserService.java similarity index 65% rename from apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcUserService.java rename to apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcReactiveOAuth2UserService.java index e8f902eb6b3..6d0852f9fcc 100644 --- a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcUserService.java +++ b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcReactiveOAuth2UserService.java @@ -3,31 +3,35 @@ 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.client.oidc.userinfo.OidcUserService; 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.stereotype.Service; -import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import reactor.core.publisher.Mono; import java.util.LinkedHashSet; -import java.util.function.BiFunction; -@Service -@RequiredArgsConstructor -class CustomOidcUserService extends OidcUserService { +import static lombok.AccessLevel.PACKAGE; - private final BiFunction oidcUserMapper = CustomOidcUserService::getUser; +@RequiredArgsConstructor(access = PACKAGE) +class CustomOidcReactiveOAuth2UserService 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) { - private static OidcUser getUser(OidcUserRequest userRequest, OidcUserInfo userInfo) { var authorities = new LinkedHashSet(); - authorities.add(new OidcUserAuthority(userRequest.getIdToken(), userInfo)); - var token = userRequest.getAccessToken(); - token + authorities.add(new OidcUserAuthority(userRequest.getIdToken(), null)); + userRequest + .getAccessToken() .getScopes() .forEach(scope -> authorities.add(new SimpleGrantedAuthority("SCOPE_" + scope))); var providerDetails = userRequest @@ -37,15 +41,15 @@ private static OidcUser getUser(OidcUserRequest userRequest, OidcUserInfo userIn .getUserInfoEndpoint() .getUserNameAttributeName(); if (StringUtils.hasText(userNameAttributeName)) { - return new DefaultOidcUser(authorities, userRequest.getIdToken(), userInfo, userNameAttributeName); + return new DefaultOidcUser(authorities, userRequest.getIdToken(), null, userNameAttributeName); } - return new DefaultOidcUser(authorities, userRequest.getIdToken(), userInfo); + return new DefaultOidcUser(authorities, userRequest.getIdToken(), (OidcUserInfo) null); + } @Override - public OidcUser loadUser(OidcUserRequest userRequest) throws OAuth2AuthenticationException { - Assert.notNull(userRequest, "userRequest cannot be null"); - return oidcUserMapper.apply(userRequest, null); + public Mono loadUser(OidcUserRequest userRequest) throws OAuth2AuthenticationException { + return Mono.just(getUser(userRequest)); } } diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java new file mode 100644 index 00000000000..18e670bb6ea --- /dev/null +++ b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java @@ -0,0 +1,20 @@ +package no.nav.testnav.apps.endringsmeldingfrontend.config; + +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 CustomReactiveOAuth2UserService implements ReactiveOAuth2UserService { + + @Override + public Mono loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { + return Mono.empty(); + } + +} diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java new file mode 100644 index 00000000000..9ef8034c680 --- /dev/null +++ b/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java @@ -0,0 +1,23 @@ +package no.nav.testnav.apps.endringsmeldingfrontend.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +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; + +@Configuration +public class CustomReactiveOauth2Config { + + @Bean + public ReactiveOAuth2UserService reactiveOAuth2UserService() { + return new CustomReactiveOAuth2UserService(); + } + + @Bean + public OidcReactiveOAuth2UserService oidcReactiveOAuth2UserService() { + return new CustomOidcReactiveOAuth2UserService(); + } + +} 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 7be66adc883..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 @@ -4,18 +4,17 @@ import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; import org.springframework.security.config.web.server.ServerHttpSecurity; -import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest; -import org.springframework.security.oauth2.client.userinfo.OAuth2UserService; -import org.springframework.security.oauth2.core.oidc.user.OidcUser; 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) { + public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { return http .cors(ServerHttpSecurity.CorsSpec::disable) .csrf(ServerHttpSecurity.CsrfSpec::disable) @@ -27,14 +26,8 @@ public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) .permitAll() .anyExchange() .authenticated()) - .oauth2Login(oauth2Login -> { - }) + .oauth2Login(withDefaults()) .build(); } - @Bean - public OAuth2UserService oidcUserService() { - return new CustomOidcUserService(); - } - } From f57bcb7a0d01070c83232d6610daeb2c1fc5290d Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Mon, 30 Dec 2024 17:39:08 +0100 Subject: [PATCH 17/28] Moved custom user info classes into security-core lib and created auto config for beans. --- .../userinfo/NoopOidcReactiveOAuth2UserService.java | 4 ++-- .../userinfo/NoopReactiveOAuth2UserService.java | 4 ++-- .../NoopReactiveOauth2AutoConfiguration.java | 12 ++++++------ ...work.boot.autoconfigure.AutoConfiguration.imports | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) rename apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcReactiveOAuth2UserService.java => libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopOidcReactiveOAuth2UserService.java (93%) rename apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java => libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOAuth2UserService.java (78%) rename apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java => libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOauth2AutoConfiguration.java (65%) diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcReactiveOAuth2UserService.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopOidcReactiveOAuth2UserService.java similarity index 93% rename from apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcReactiveOAuth2UserService.java rename to libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopOidcReactiveOAuth2UserService.java index 6d0852f9fcc..7f059a7c6da 100644 --- a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomOidcReactiveOAuth2UserService.java +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopOidcReactiveOAuth2UserService.java @@ -1,4 +1,4 @@ -package no.nav.testnav.apps.endringsmeldingfrontend.config; +package no.nav.testnav.libs.securitycore.oauth2.client.userinfo; import lombok.RequiredArgsConstructor; import org.springframework.security.core.GrantedAuthority; @@ -18,7 +18,7 @@ import static lombok.AccessLevel.PACKAGE; @RequiredArgsConstructor(access = PACKAGE) -class CustomOidcReactiveOAuth2UserService extends OidcReactiveOAuth2UserService { +class NoopOidcReactiveOAuth2UserService extends OidcReactiveOAuth2UserService { /** * Stripped from {@code org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequestUtils#getUser(OidcUserRequest, OidcUserInfo)}. diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOAuth2UserService.java similarity index 78% rename from apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java rename to libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOAuth2UserService.java index 18e670bb6ea..015b48b8491 100644 --- a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOAuth2UserService.java +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOAuth2UserService.java @@ -1,4 +1,4 @@ -package no.nav.testnav.apps.endringsmeldingfrontend.config; +package no.nav.testnav.libs.securitycore.oauth2.client.userinfo; import lombok.RequiredArgsConstructor; import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; @@ -10,7 +10,7 @@ import static lombok.AccessLevel.PACKAGE; @RequiredArgsConstructor(access = PACKAGE) -class CustomReactiveOAuth2UserService implements ReactiveOAuth2UserService { +class NoopReactiveOAuth2UserService implements ReactiveOAuth2UserService { @Override public Mono loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { diff --git a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOauth2AutoConfiguration.java similarity index 65% rename from apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java rename to libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOauth2AutoConfiguration.java index 9ef8034c680..76d1dd6ef08 100644 --- a/apps/endringsmelding-frontend/src/main/java/no/nav/testnav/apps/endringsmeldingfrontend/config/CustomReactiveOauth2Config.java +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/oauth2/client/userinfo/NoopReactiveOauth2AutoConfiguration.java @@ -1,23 +1,23 @@ -package no.nav.testnav.apps.endringsmeldingfrontend.config; +package no.nav.testnav.libs.securitycore.oauth2.client.userinfo; +import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; 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; -@Configuration -public class CustomReactiveOauth2Config { +@AutoConfiguration +public class NoopReactiveOauth2AutoConfiguration { @Bean public ReactiveOAuth2UserService reactiveOAuth2UserService() { - return new CustomReactiveOAuth2UserService(); + return new NoopReactiveOAuth2UserService(); } @Bean public OidcReactiveOAuth2UserService oidcReactiveOAuth2UserService() { - return new CustomOidcReactiveOAuth2UserService(); + 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 From 1ffc37fa25a0f385d6c055d7148c3724a76e15f0 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 10:13:48 +0100 Subject: [PATCH 18/28] Added placeholder AZURE_OPENID_CONFIG_ISSUER value in test configs. --- apps/adresse-service/src/test/resources/application-test.yml | 1 + .../amelding-service/src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + apps/dolly-backend/src/test/resources/application-test.yml | 4 +++- apps/dolly-frontend/src/test/resources/application-test.yml | 4 ++-- .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../kodeverk-service/src/test/resources/application-test.yml | 2 ++ .../src/test/resources/application-test.yml | 2 ++ .../src/test/resources/application-test.yml | 2 ++ .../src/test/resources/application-test.yml | 2 ++ apps/miljoer-service/src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 5 +++-- .../src/test/resources/application-test.yml | 1 + apps/person-service/src/test/resources/application-test.yml | 1 + apps/profil-api/src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 2 ++ .../src/test/resources/application-test.yml | 3 ++- .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 3 ++- .../src/test/Resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + proxies/aareg-proxy/src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../dokarkiv-proxy/src/test/resources/application-test.yml | 1 + .../fullmakt-proxy/src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../krrstub-proxy/src/test/resources/application-test.yml | 1 + proxies/medl-proxy/src/test/resources/application-test.yml | 1 + proxies/pdl-proxy/src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 2 ++ proxies/saf-proxy/src/test/resources/application-test.yml | 1 + .../udistub-proxy/src/test/resources/application-test.yml | 1 + 46 files changed, 59 insertions(+), 7 deletions(-) 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/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/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/test/resources/application-test.yml b/apps/batch-bestilling-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 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,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: 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/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-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/generer-arbeidsforhold-populasjon-service/src/test/resources/application-test.yml b/apps/generer-arbeidsforhold-populasjon-service/src/test/resources/application-test.yml index aa8bfa92394..198e40dc002 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,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: 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/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/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-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/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/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/test/resources/application-test.yml b/apps/kodeverk-service/src/test/resources/application-test.yml index 0aeb22a14f6..a69fa740f61 100644 --- a/apps/kodeverk-service/src/test/resources/application-test.yml +++ b/apps/kodeverk-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/levende-arbeidsforhold-ansettelse/src/test/resources/application-test.yml b/apps/levende-arbeidsforhold-ansettelse/src/test/resources/application-test.yml index 6f0b72ba8ea..09310c9f953 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,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder + spring: r2dbc: url: r2dbc:h2:mem:///~/db/testdb 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..a69fa740f61 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,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder + spring: cloud: gcp: 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..a69fa740f61 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,5 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder + spring: cloud: gcp: 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/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/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/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/test/resources/application-test.yml b/apps/organisasjon-mottak-service/src/test/resources/application-test.yml index a28916c6e65..f1d3b23848b 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,4 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy spring: 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/person-organisasjon-tilgang-service/src/test/resources/application-test.yml b/apps/person-organisasjon-tilgang-service/src/test/resources/application-test.yml index 7e52003da3c..44e289f2034 100644 --- a/apps/person-organisasjon-tilgang-service/src/test/resources/application-test.yml +++ b/apps/person-organisasjon-tilgang-service/src/test/resources/application-test.yml @@ -1,10 +1,11 @@ -TOKEN_X_ISSUER: dummy -ALTINN_URL: dummy ALTINN_API_KEY: dummy +ALTINN_URL: 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/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/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/test/resources/application-test.yml b/apps/profil-api/src/test/resources/application-test.yml index bf7cc5cb0e7..a20bd502adf 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/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/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/test/resources/application-test.yml b/apps/testnav-ident-pool/src/test/resources/application-test.yml index bea909f59d4..3a37416d543 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_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy ### DATABASE ### 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/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/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/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/altinn3-tilgang-proxy/src/test/resources/application-test.yml b/proxies/altinn3-tilgang-proxy/src/test/resources/application-test.yml index f05debbd219..23ddd58e63f 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,2 @@ +AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder TOKEN_X_ISSUER: dummy \ No newline at end of file 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/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/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/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/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/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/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/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/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/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 From 918fb0d5488e9b01bc8d92e4ed03c08af8cae9eb Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 10:18:27 +0100 Subject: [PATCH 19/28] Reverted reply URL patterns from /azure to /aad. --- apps/endringsmelding-frontend/config.yml | 4 ++-- .../src/main/resources/application.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/endringsmelding-frontend/config.yml b/apps/endringsmelding-frontend/config.yml index 42dd9fd5733..a4f37bf4cd2 100644 --- a/apps/endringsmelding-frontend/config.yml +++ b/apps/endringsmelding-frontend/config.yml @@ -12,8 +12,8 @@ spec: enabled: true tenant: nav.no replyURLs: - - "https://testnav-endringsmelding.intern.dev.nav.no/login/oauth2/code/azure" - - "http://localhost:8080/login/oauth2/code/azure" + - "https://testnav-endringsmelding.intern.dev.nav.no/login/oauth2/code/aad" + - "http://localhost:8080/login/oauth2/code/aad" claims: groups: - id: 9c7efec1-1599-4216-a67e-6fd53a6a951c diff --git a/apps/endringsmelding-frontend/src/main/resources/application.yml b/apps/endringsmelding-frontend/src/main/resources/application.yml index 2abd52c2258..fe788da7667 100644 --- a/apps/endringsmelding-frontend/src/main/resources/application.yml +++ b/apps/endringsmelding-frontend/src/main/resources/application.yml @@ -8,14 +8,14 @@ spring: oauth2: client: registration: - azure: + aad: authorization-grant-type: authorization_code client-id: ${AZURE_APP_CLIENT_ID} client-secret: ${AZURE_APP_CLIENT_SECRET} redirect-uri: '{baseUrl}/login/oauth2/code/{registrationId}' scope: openid, ${AZURE_APP_CLIENT_ID}/.default provider: - azure: + aad: issuer-uri: ${AZURE_OPENID_CONFIG_ISSUER} consumers: From c6f3868825464e2d211fd5b0f62ffd8c11f37798 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 11:10:07 +0100 Subject: [PATCH 20/28] Clarified TODO. --- .../libs/servletsecurity/exchange/AzureAdTokenService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0ef59a84b9d..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,9 +23,9 @@ 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 -// TODO: Check no.nav.testnav.libs.servletsecurity.exchange.AzureAdTokenService. These behave differently. @ConditionalOnProperty("spring.security.oauth2.resourceserver.aad.issuer-uri") public class AzureAdTokenService implements TokenService { private final WebClient webClient; From 8105104cc77d5426616a1698fb13588911e36be4 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 11:25:45 +0100 Subject: [PATCH 21/28] Added a TODO. --- .../config/SecureOAuth2ServerToServerConfiguration.java | 1 + 1 file changed, 1 insertion(+) 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..9a4933da79d 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 @@ -37,6 +37,7 @@ }) 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 @ConditionalOnMissingBean public JwtDecoder jwtDecoder(List properties) { From 439b712cf441329de2eb2d7f491e33f77644db85 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 12:07:09 +0100 Subject: [PATCH 22/28] - Changed usage from old AAD_ISSUER_URI to NAIS provided AZURE_OPENID_CONFIG_ISSUER. - Added a TODO - this is not library code. --- .../registre/testnorge/profil/service/AzureAdTokenService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ) { From cc0189ddae8b0eb8020f1d3db8fd083a62089280 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 12:12:50 +0100 Subject: [PATCH 23/28] Added JwtDecoder beans for test profile, to avoid boilerplate mocks in tests. --- ...nsecureJwtServerToServerConfiguration.java | 15 ++++++++++---- ...cureOAuth2ServerToServerConfiguration.java | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) 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-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 9a4933da79d..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; @@ -39,9 +33,17 @@ 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 From 69def70229ae1987047a3753c5c8debd949d0984 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 12:23:10 +0100 Subject: [PATCH 24/28] - Removed boilerplate JwtDecoder mocks. - Added missing test profile config placeholders. - Removed a few Sonar warnings. --- .../ApplicationContextTest.java | 10 +-- .../src/test/resources/application-test.yml | 3 +- .../ApplicationContextTest.java | 10 ++- .../src/test/resources/application-test.yml | 1 + .../ApplicationContextTest.java | 12 ++-- .../src/test/resources/application-test.yml | 1 + .../ApplicationContextTest.java | 10 ++- .../src/test/resources/application-test.yml | 1 + .../ApplicationContextTest.java | 12 ++-- .../src/test/resources/application-test.yml | 1 + .../ApplicationContextTest.java | 10 +-- .../src/test/resources/application-test.yml | 1 + ...eidsforholdAnsettelseApplicationTests.java | 9 +-- .../src/test/resources/application-test.yml | 1 + .../src/test/resources/application-test.yml | 1 + .../ApplicationContextTest.java | 12 ++-- .../src/test/resources/application-test.yml | 1 + .../ApplicationContextTest.java | 8 --- .../src/test/resources/application-test.yml | 1 + .../ApplicationContextTest.java | 10 ++- .../src/test/resources/application-test.yml | 1 + .../profil/ApplicationContextTest.java | 10 ++- .../consumer/ArbeidsforholdConsumerTest.java | 25 +++----- .../consumer/HelsepersonellConsumerTest.java | 17 ++--- .../consumer/OrganisasjonConsumerTest.java | 21 +++---- .../consumer/PdlProxyConsumerTest.java | 23 +++---- .../consumer/SykemeldingConsumerTest.java | 62 ++++++------------- .../consumer/SyntElsamConsumerTest.java | 23 +++---- ...tSykemeldingControllerIntegrationTest.java | 5 -- .../src/test/resources/application-test.yml | 1 + .../identpool/ComponentTestConfig.java | 6 +- .../src/test/resources/application-test.yml | 2 +- .../ApplicationContextTest.java | 6 -- .../udistub/converter/itest/UdiStubITest.java | 5 +- .../src/test/resources/application-test.yml | 1 + 35 files changed, 115 insertions(+), 208 deletions(-) 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/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/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 198e40dc002..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,4 +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-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 198e40dc002..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,4 +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/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/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 a69fa740f61..70b074dc087 100644 --- a/apps/kodeverk-service/src/test/resources/application-test.yml +++ b/apps/kodeverk-service/src/test/resources/application-test.yml @@ -1,4 +1,5 @@ AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder spring: cloud: 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 09310c9f953..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,4 +1,5 @@ AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder spring: r2dbc: 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 a69fa740f61..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,4 +1,5 @@ AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder spring: cloud: 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 a69fa740f61..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,4 +1,5 @@ AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder spring: cloud: 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 f1d3b23848b..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,4 +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/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/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/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/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/resources/application-test.yml b/apps/testnav-ident-pool/src/test/resources/application-test.yml index 3a37416d543..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,4 +1,4 @@ -AZURE_OPENID_CONFIG_ISSUER: http://localhost/placeholder +AZURE_OPENID_CONFIG_TOKEN_ENDPOINT: http://localhost/placeholder TOKEN_X_ISSUER: dummy ### DATABASE ### 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/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: From 73ebba6bcd40977a99a123945a60e4f725477a68 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 12:23:53 +0100 Subject: [PATCH 25/28] Removed a warning. --- .../identpool/providers/v1/FinnesHosSkattComponentTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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) From 929f910b99f732af02eb1105e1887875ade3d1ba Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 13:14:10 +0100 Subject: [PATCH 26/28] - Added missing AZURE_OPENID_CONFIG_TOKEN_ENDPOINT test profile config. - Removed mock of JwtDecoder. --- .../testnav/altinn3tilgangproxy/ApplicationContextTest.java | 6 ------ .../src/test/resources/application-test.yml | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) 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 23ddd58e63f..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,2 +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 From 2a285a9efc587d20d3eb3de203dd8e9a7048c18a Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 13:20:52 +0100 Subject: [PATCH 27/28] - Fixed incorrect context path for testnav-altinn3-tilgang-service. - Added build trigger on docker-compose.yml. --- .github/workflows/integration-tests.yml | 1 + docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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/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 From ce5b7d73571b050fe2a33e00740b5e6f6e98f2b9 Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 9 Jan 2025 14:18:12 +0100 Subject: [PATCH 28/28] Removed mocks of JwtDecoder. --- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 8 ------- .../BrukerServiceIntegrationTest.java | 21 +++++++---------- .../no/nav/dolly/MockedJwtDecoderConfig.java | 22 ------------------ .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 9 +++----- .../ApplicationContextTest.java | 12 ++++------ .../ApplicationContextTest.java | 12 ++++------ .../ApplicationContextTest.java | 12 ++++------ .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 18 +++------------ .../orgnrservice/ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 10 ++++---- .../personservice/ApplicationContextTest.java | 10 ++++---- .../ApplicationContextTest.java | 21 ----------------- .../consumer/ArenaForvalterConsumerTest.java | 19 ++++----------- .../consumer/PdlConsumerTest.java | 21 ++++------------- .../PensjonTestdataFacadeConsumerTest.java | 11 +++------ .../consumer/PersonSearchConsumerTest.java | 10 +++----- .../SyntVedtakshistorikkConsumerTest.java | 10 ++------ .../sdforvalter/JwtDecoderConfig.java | 23 ------------------- .../ApplicationContextTest.java | 7 ------ .../controller/VarslingerControllerTest.java | 5 ---- .../VarslingerPersonControllerTest.java | 12 ---------- 29 files changed, 91 insertions(+), 272 deletions(-) delete mode 100644 apps/dolly-backend/src/test/java/no/nav/dolly/MockedJwtDecoderConfig.java delete mode 100644 apps/synt-vedtakshistorikk-service/src/test/java/no/nav/testnav/apps/syntvedtakshistorikkservice/ApplicationContextTest.java delete mode 100644 apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/JwtDecoderConfig.java 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/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/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/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/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-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-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-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/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/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/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/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/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-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-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-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/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/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-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/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/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/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/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();