diff --git a/apps/adresse-service/src/main/resources/application.yaml b/apps/adresse-service/src/main/resources/application.yaml index 98dbbe9e7bf..5b96088b72e 100644 --- a/apps/adresse-service/src/main/resources/application.yaml +++ b/apps/adresse-service/src/main/resources/application.yaml @@ -16,9 +16,6 @@ spring: issuer-uri: ${TOKEN_X_ISSUER} jwk-set-uri: ${TOKEN_X_JWKS_URI} accepted-audience: ${TOKEN_X_CLIENT_ID} - cloud: - vault: - enabled: false springdoc: swagger-ui: diff --git a/apps/brreg-stub/build.gradle b/apps/brreg-stub/build.gradle index 9c396b61094..a2629f98e70 100644 --- a/apps/brreg-stub/build.gradle +++ b/apps/brreg-stub/build.gradle @@ -22,7 +22,6 @@ dependencies { exclude group: "com.google.code.findbugs" } - implementation "no.nav.testnav.libs:database" implementation "no.nav.testnav.libs:servlet-core" implementation "no.nav.testnav.libs:vault" diff --git a/apps/brreg-stub/settings.gradle b/apps/brreg-stub/settings.gradle index dda5fadcdfc..b2447fc62b7 100644 --- a/apps/brreg-stub/settings.gradle +++ b/apps/brreg-stub/settings.gradle @@ -6,7 +6,6 @@ rootProject.name = 'brreg-stub' includeBuild "../../plugins/java" -includeBuild '../../libs/database' includeBuild '../../libs/servlet-core' includeBuild '../../libs/vault' diff --git a/apps/sykemelding-api/src/main/resources/application.yml b/apps/sykemelding-api/src/main/resources/application.yml index 6075f7a084a..9e2485911f2 100644 --- a/apps/sykemelding-api/src/main/resources/application.yml +++ b/apps/sykemelding-api/src/main/resources/application.yml @@ -9,9 +9,6 @@ spring: version: application.version.todo name: testnav-sykemelding-api description: Api for opprettelse av detaljerte sykemeldinger - cloud: - vault: - enabled: false security: oauth2: resourceserver: diff --git a/apps/synt-sykemelding-api/src/main/resources/application-dev.yml b/apps/synt-sykemelding-api/src/main/resources/application-dev.yml index 4c1de6302c8..af43c132df4 100644 --- a/apps/synt-sykemelding-api/src/main/resources/application-dev.yml +++ b/apps/synt-sykemelding-api/src/main/resources/application-dev.yml @@ -1,18 +1,3 @@ -TOKEN_X_CLIENT_ID: dev-gcp:dolly:testnav-synt-sykemelding-api - -spring: - config: - import: "sm://" - security: - oauth2: - resourceserver: - aad: - accepted-audience: ${sm://azure-app-client-id}, api://${sm://azure-app-client-id} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} - consumers: synt-sykemelding: url: http://synthdata-elsam-gcp.intern.dolly.svc.cluster.local diff --git a/apps/synt-sykemelding-api/src/main/resources/application-local.yml b/apps/synt-sykemelding-api/src/main/resources/application-local.yml index e77e1c2c6af..974482f7e91 100644 --- a/apps/synt-sykemelding-api/src/main/resources/application-local.yml +++ b/apps/synt-sykemelding-api/src/main/resources/application-local.yml @@ -1,3 +1,13 @@ +TOKEN_X_ISSUER: https://tokenx.dev-gcp.nav.cloud.nais.io + +spring: + config: + import: "sm://" + security: + oauth2: + resourceserver: + aad: + accepted-audience: ${sm://azure-app-client-id}, api://${sm://azure-app-client-id} consumers: synt-sykemelding: diff --git a/apps/synt-sykemelding-api/src/main/resources/application.yml b/apps/synt-sykemelding-api/src/main/resources/application.yml index 6e4c9d4a232..a9ff3f6ba65 100644 --- a/apps/synt-sykemelding-api/src/main/resources/application.yml +++ b/apps/synt-sykemelding-api/src/main/resources/application.yml @@ -5,9 +5,6 @@ spring: version: application.version.todo name: testnav-synt-sykemelding-api description: Api for opprettelse av syntetiske sykemeldinger - cloud: - vault: - enabled: false security: oauth2: resourceserver: diff --git a/apps/testnorge-statisk-data-forvalter/build.gradle b/apps/testnorge-statisk-data-forvalter/build.gradle index d6b76061f85..27ec15bee1a 100644 --- a/apps/testnorge-statisk-data-forvalter/build.gradle +++ b/apps/testnorge-statisk-data-forvalter/build.gradle @@ -16,7 +16,6 @@ dependencies { implementation "no.nav.testnav.libs:commands" implementation "no.nav.testnav.libs:csv-converter" implementation "no.nav.testnav.libs:data-transfer-objects" - implementation "no.nav.testnav.libs:database" implementation "no.nav.testnav.libs:kafka-config" implementation "no.nav.testnav.libs:kafka-producers" implementation "no.nav.testnav.libs:security-core" diff --git a/apps/testnorge-statisk-data-forvalter/settings.gradle b/apps/testnorge-statisk-data-forvalter/settings.gradle index adf6eef2ad7..54c77ebbb15 100644 --- a/apps/testnorge-statisk-data-forvalter/settings.gradle +++ b/apps/testnorge-statisk-data-forvalter/settings.gradle @@ -10,7 +10,6 @@ includeBuild '../../libs/avro-schema' includeBuild '../../libs/commands' includeBuild '../../libs/csv-converter' includeBuild '../../libs/data-transfer-objects' -includeBuild '../../libs/database' includeBuild '../../libs/kafka-config' includeBuild '../../libs/kafka-producers' includeBuild '../../libs/security-core' diff --git a/apps/testnorge-statisk-data-forvalter/src/main/resources/application-prod.yml b/apps/testnorge-statisk-data-forvalter/src/main/resources/application-prod.yml index 8cee85b29e6..8ac700c1f9b 100644 --- a/apps/testnorge-statisk-data-forvalter/src/main/resources/application-prod.yml +++ b/apps/testnorge-statisk-data-forvalter/src/main/resources/application-prod.yml @@ -1,4 +1,6 @@ spring: + config: + import: vault:// datasource: url: jdbc:postgresql://b27dbvl032.preprod.local:5432/testnav-statisk-data?useUnicode=yes&characterEncoding=UTF-8 hikari: @@ -20,15 +22,17 @@ spring: jwk-set-uri: ${TOKEN_X_JWKS_URI} accepted-audience: ${TOKEN_X_CLIENT_ID} cloud: + gcp: + secretmanager: + enabled: false # Running in dev-fss. vault: - kv: - enabled: false - host: vault.adeo.no - port: 443 - fail-fast: true connection-timeout: 15000 - read-timeout: 30000 database: backend: postgresql/preprod-fss - role: testnav-statisk-data-admin enabled: true + role: testnav-statisk-data-admin + fail-fast: true + host: vault.adeo.no + kv.enabled: false + port: 443 + read-timeout: 30000 diff --git a/apps/testnorge-statisk-data-forvalter/src/main/resources/bootstrap.yaml b/apps/testnorge-statisk-data-forvalter/src/main/resources/bootstrap.yaml deleted file mode 100644 index f830ab610ad..00000000000 --- a/apps/testnorge-statisk-data-forvalter/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,20 +0,0 @@ -spring.cloud.vault: - host: vault.adeo.no - port: 443 - connection-timeout: 15000 - read-timeout: 30000 - application-name: preprod/fss/testnorge-statisk-data-forvalter - - authentication: TOKEN - - generic: - enabled: false - backend: kv - application-name: preprod/fss/testnorge-statisk-data/dolly - default-context: preprod/fss/testnorge-statisk-data/dolly - database: - enabled: true - role: testnorge-statisk-data-admin - backend: postgresql/preprod-fss - username-property: spring.datasource.username - password-property: spring.datasource.password \ No newline at end of file diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/consumer/rs/aareg/SyntAaregConsumerTest.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/consumer/rs/aareg/SyntAaregConsumerTest.java index 990f8bf9ad7..cbae50d91d8 100644 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/consumer/rs/aareg/SyntAaregConsumerTest.java +++ b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/consumer/rs/aareg/SyntAaregConsumerTest.java @@ -8,19 +8,17 @@ import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; +import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.slf4j.LoggerFactory; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import java.io.IOException; import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.stream.Collectors; import static no.nav.registre.sdforvalter.ResourceUtils.getResourceFileContent; import static org.hamcrest.CoreMatchers.containsString; @@ -29,9 +27,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItems; - -@TestPropertySource(locations = "classpath:application-test.yml") -@ActiveProfiles("test") public class SyntAaregConsumerTest { private final String fnr1 = "01010101010"; @@ -55,15 +50,15 @@ public void shouldGetSyntetiserteMeldinger() { var result = syntAaregConsumer.getSyntetiserteArbeidsforholdsmeldinger(fnrs); - assertThat(result.get(0).getArbeidsforhold().getArbeidstaker().getIdent(), equalTo(fnrs.get(0))); - assertThat(result.get(0).getArbeidsforhold().getArbeidsavtale().getArbeidstidsordning(), equalTo("doegnkontinuerligSkiftOgTurnus355")); - assertThat(result.get(0).getArbeidsforhold().getArbeidsavtale().getAvtaltArbeidstimerPerUke(), equalTo(35.5)); - assertThat(result.get(0).getArbeidsforhold().getArbeidsavtale().getEndringsdatoStillingsprosent(), equalTo(LocalDate.of(1985, 8, 1))); - assertThat(result.get(0).getArbeidsforhold().getArbeidsavtale().getStillingsprosent(), equalTo(0.01)); - assertThat(result.get(0).getArbeidsforhold().getAnsettelsesPeriode().getFom(), equalTo(LocalDate.of(1985, 8, 1))); - assertThat(result.get(0).getArbeidsforhold().getPermisjon().get(0).getPermisjonsId(), equalTo("a1b2c3")); - assertThat(result.get(0).getArbeidsforhold().getPermisjon().get(0).getPermisjonsprosent(), equalTo(10.5)); - assertThat(result.get(0).getArbeidsforhold().getUtenlandsopphold().get(0).getLand(), equalTo("NOR")); + assertThat(result.getFirst().getArbeidsforhold().getArbeidstaker().getIdent(), equalTo(fnrs.getFirst())); + assertThat(result.getFirst().getArbeidsforhold().getArbeidsavtale().getArbeidstidsordning(), equalTo("doegnkontinuerligSkiftOgTurnus355")); + assertThat(result.getFirst().getArbeidsforhold().getArbeidsavtale().getAvtaltArbeidstimerPerUke(), equalTo(35.5)); + assertThat(result.getFirst().getArbeidsforhold().getArbeidsavtale().getEndringsdatoStillingsprosent(), equalTo(LocalDate.of(1985, 8, 1))); + assertThat(result.getFirst().getArbeidsforhold().getArbeidsavtale().getStillingsprosent(), equalTo(0.01)); + assertThat(result.getFirst().getArbeidsforhold().getAnsettelsesPeriode().getFom(), equalTo(LocalDate.of(1985, 8, 1))); + assertThat(result.getFirst().getArbeidsforhold().getPermisjon().getFirst().getPermisjonsId(), equalTo("a1b2c3")); + assertThat(result.getFirst().getArbeidsforhold().getPermisjon().getFirst().getPermisjonsprosent(), equalTo(10.5)); + assertThat(result.getFirst().getArbeidsforhold().getUtenlandsopphold().getFirst().getLand(), equalTo("NOR")); assertThat(result.get(1).getArbeidsforhold().getArbeidstaker().getIdent(), equalTo(fnrs.get(1))); assertThat(result.get(1).getArbeidsforhold().getArbeidsforholdID(), equalTo("oAq5SJgOPDHQnERi")); assertThat(result.get(1).getArbeidsforhold().getArbeidsforholdstype(), equalTo("ordinaertArbeidsforhold")); @@ -77,7 +72,7 @@ public void shouldGetSyntetiserteMeldingerWithPaging() { var result = syntAaregConsumer.getSyntetiserteArbeidsforholdsmeldinger(fnrs); - var identsInResponse = result.stream().map(a -> a.getArbeidsforhold().getArbeidstaker().getIdent()).collect(Collectors.toList()); + var identsInResponse = result.stream().map(a -> a.getArbeidsforhold().getArbeidstaker().getIdent()).toList(); assertThat(identsInResponse, hasItems(fnrs.get(0), fnrs.get(1), fnrs.get(2))); } @@ -94,7 +89,7 @@ public void shouldLogOnEmptyResponse() { syntAaregConsumer.getSyntetiserteArbeidsforholdsmeldinger(fnrs); assertThat(listAppender.list.size(), is(equalTo(1))); - assertThat(listAppender.list.get(0).toString(), containsString("Feil under syntetisering")); + assertThat(listAppender.list.getFirst().toString(), containsString("Feil under syntetisering")); } @After @@ -103,27 +98,33 @@ public void tearDown() throws IOException { } private Dispatcher getDispatcher() { + return new Dispatcher() { + + @NotNull @Override - public MockResponse dispatch(RecordedRequest request) { - if (request.getPath().equals("/synt-aareg/api/v1/generate_aareg") && request.getMethod().equals("POST")) { - var body = request.getBody().readUtf8(); - switch (body) { - case "[\"01010101010\",\"02020202020\"]": - return new MockResponse().setResponseCode(200) - .addHeader("Content-Type", "application/json") - .setBody(getResourceFileContent("files/arbeidsforholdsmelding.json")); - case "[\"03030303030\"]": - return new MockResponse().setResponseCode(200) - .addHeader("Content-Type", "application/json") - .setBody(getResourceFileContent("files/arbeidsforholdsmelding_paged.json")); - case "[\"01010101010\"]": - return new MockResponse().setResponseCode(500); - } + public MockResponse dispatch(@NotNull RecordedRequest request) { + + if ("/synt-aareg/api/v1/generate_aareg".equals(request.getPath()) && "POST".equals(request.getMethod())) { + return switch (request.getBody().readUtf8()) { + case "[\"01010101010\",\"02020202020\"]" -> new MockResponse() + .setResponseCode(200) + .addHeader("Content-Type", "application/json") + .setBody(getResourceFileContent("files/arbeidsforholdsmelding.json")); + case "[\"03030303030\"]" -> new MockResponse() + .setResponseCode(200) + .addHeader("Content-Type", "application/json") + .setBody(getResourceFileContent("files/arbeidsforholdsmelding_paged.json")); + case "[\"01010101010\"]" -> new MockResponse().setResponseCode(500); + default -> + throw new IllegalStateException("Unexpected request body: " + request.getBody().readUtf8()); + }; } - return new MockResponse().setResponseCode(404); + } + }; + } } diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerAaregIntegrationTest.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerAaregIntegrationTest.java index aeee8867f8d..56670b27755 100644 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerAaregIntegrationTest.java +++ b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerAaregIntegrationTest.java @@ -15,8 +15,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -25,7 +23,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.MockMvc; import reactor.core.publisher.Mono; @@ -36,16 +33,18 @@ import static no.nav.registre.sdforvalter.ResourceUtils.getResourceFileContent; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@ExtendWith(MockitoExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest( + webEnvironment = RANDOM_PORT, + properties = "spring.cloud.vault.token=SET_TO_SOMETHING_TO_ALLOW_CONTEXT_TO_LOAD" +) +@ActiveProfiles("test") @AutoConfigureWireMock(port = 0) @AutoConfigureMockMvc -@TestPropertySource(locations = "classpath:application-test.yml") -@ActiveProfiles("test") class OrkestreringControllerAaregIntegrationTest { @Autowired @@ -66,7 +65,7 @@ class OrkestreringControllerAaregIntegrationTest { private final KodeverkResponse kodeverkResponse = new KodeverkResponse(Collections.singletonList("yrke")); private static String syntString; - private final TypeReference> SYNT_RESPONSE = new TypeReference<>() { + private final TypeReference> syntResponse = new TypeReference<>() { }; @BeforeAll @@ -74,13 +73,13 @@ public static void setup() { syntString = getResourceFileContent("files/enkel_arbeidsforholdmelding.json"); } - @Disabled + @Disabled("Fix verify GET on (.*)/kodeverk-api/api/v1/kodeverk/Yrker/koder") @Test void shouldInitiateAaregFromDatabase() throws Exception { - final AaregModel aaregModel = createAaregModel(FNR, ORGNR); + final AaregModel aaregModel = createAaregModel(); aaregRepository.save(aaregModel); - var arbeidsforholdmelding = objectMapper.readValue(syntString, SYNT_RESPONSE); + var arbeidsforholdmelding = objectMapper.readValue(syntString, syntResponse); when(tokenExchange.exchange(any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("dummy"))); @@ -142,10 +141,10 @@ void shouldInitiateAaregFromDatabase() throws Exception { @Test void shouldNotOppretteAaregWhenAlreadyExists() throws Exception { - final AaregModel aaregModel = createAaregModel(FNR, ORGNR); + final AaregModel aaregModel = createAaregModel(); aaregRepository.save(aaregModel); - var arbeidsforholdmelding = objectMapper.readValue(syntString, SYNT_RESPONSE); + var arbeidsforholdmelding = objectMapper.readValue(syntString, syntResponse); var arbeidsforholdResponse = Collections.singletonList(arbeidsforholdmelding.getFirst().getArbeidsforhold().toArbeidsforhold()); when(tokenExchange.exchange(any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("dummy"))); @@ -168,10 +167,10 @@ void shouldNotOppretteAaregWhenAlreadyExists() throws Exception { } - @Disabled + @Disabled("Fix verify GET on (.*)/kodeverk-api/api/v1/kodeverk/Yrker/koder") @Test void shouldNotOppretteAaregIfSyntError() throws Exception { - final AaregModel aaregModel = createAaregModel(FNR, ORGNR); + final AaregModel aaregModel = createAaregModel(); aaregRepository.save(aaregModel); when(tokenExchange.exchange(any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("dummy"))); @@ -219,10 +218,10 @@ void shouldNotOppretteAaregIfSyntError() throws Exception { .verifyGet(); } - private AaregModel createAaregModel(String fnr, String orgId) { + private AaregModel createAaregModel() { AaregModel model = new AaregModel(); - model.setFnr(fnr); - model.setOrgId(orgId); + model.setFnr(FNR); + model.setOrgId(ORGNR); return model; } diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerKrrIntegrationTest.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerKrrIntegrationTest.java index 72594780743..4fa4cb7f064 100644 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerKrrIntegrationTest.java +++ b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/OrkestreringControllerKrrIntegrationTest.java @@ -24,7 +24,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringBootTest(webEnvironment = RANDOM_PORT) +@SpringBootTest( + webEnvironment = RANDOM_PORT, + properties = "spring.cloud.vault.token=SET_TO_SOMETHING_TO_ALLOW_CONTEXT_TO_LOAD" +) @ActiveProfiles("test") @AutoConfigureWireMock(port = 0) @AutoConfigureMockMvc(addFilters = false) diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1AaregIntegrationTest.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1AaregIntegrationTest.java index e4a55a1408a..8500e738703 100644 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1AaregIntegrationTest.java +++ b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1AaregIntegrationTest.java @@ -8,30 +8,27 @@ import no.nav.registre.sdforvalter.domain.AaregListe; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; 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.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.MockMvc; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@ExtendWith(MockitoExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@AutoConfigureWireMock(port = 0) -@AutoConfigureMockMvc -@TestPropertySource( - locations = "classpath:application-test.yml" +@SpringBootTest( + webEnvironment = RANDOM_PORT, + properties = "spring.cloud.vault.token=SET_TO_SOMETHING_TO_ALLOW_CONTEXT_TO_LOAD" ) @ActiveProfiles("test") +@AutoConfigureWireMock(port = 0) +@AutoConfigureMockMvc class StaticDataControllerV1AaregIntegrationTest { @Autowired private MockMvc mvc; diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1EregIntegrationTest.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1EregIntegrationTest.java index 79be0e0d8cb..9df2d1dfb87 100644 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1EregIntegrationTest.java +++ b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1EregIntegrationTest.java @@ -15,33 +15,30 @@ import no.nav.registre.sdforvalter.domain.Opprinnelse; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; 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.http.MediaType; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.MockMvc; import java.util.ArrayList; import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@ExtendWith(MockitoExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@AutoConfigureMockMvc() -@TestPropertySource( - locations = "classpath:application-test.yml" +@SpringBootTest( + webEnvironment = RANDOM_PORT, + properties = "spring.cloud.vault.token=SET_TO_SOMETHING_TO_ALLOW_CONTEXT_TO_LOAD" ) @ActiveProfiles("test") +@AutoConfigureMockMvc() class StaticDataControllerV1EregIntegrationTest { private static final String EREG_API = "/api/v1/faste-data/ereg"; @Autowired diff --git a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1KrrIntegrationTest.java b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1KrrIntegrationTest.java index 8f2bc905730..a16c0c98b38 100644 --- a/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1KrrIntegrationTest.java +++ b/apps/testnorge-statisk-data-forvalter/src/test/java/no/nav/registre/sdforvalter/provider/rs/v1/StaticDataControllerV1KrrIntegrationTest.java @@ -8,34 +8,31 @@ import no.nav.registre.sdforvalter.domain.KrrListe; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; 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.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.MockMvc; import java.util.Arrays; import static com.github.tomakehurst.wiremock.client.WireMock.reset; import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@ExtendWith(MockitoExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@AutoConfigureWireMock(port = 0) -@AutoConfigureMockMvc -@TestPropertySource( - locations = "classpath:application-test.yml" +@SpringBootTest( + webEnvironment = RANDOM_PORT, + properties = "spring.cloud.vault.token=SET_TO_SOMETHING_TO_ALLOW_CONTEXT_TO_LOAD" ) @ActiveProfiles("test") +@AutoConfigureWireMock(port = 0) +@AutoConfigureMockMvc class StaticDataControllerV1KrrIntegrationTest { @Autowired private MockMvc mvc; 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 00f18d3c630..a4c5a1d25d2 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 @@ -16,7 +16,7 @@ spring: secretmanager: enabled: false vault: - token: dummy + enabled: false AAD_ISSUER_URI: http://localhost:${wiremock.server.port:0}/token diff --git a/apps/testnorge-statisk-data-forvalter/src/test/resources/bootstrap.yml b/apps/testnorge-statisk-data-forvalter/src/test/resources/bootstrap.yml deleted file mode 100644 index 85b05c6c99b..00000000000 --- a/apps/testnorge-statisk-data-forvalter/src/test/resources/bootstrap.yml +++ /dev/null @@ -1,5 +0,0 @@ -spring: - flyway.enabled: false - cloud: - vault: - enabled: false \ No newline at end of file diff --git a/apps/udi-stub/build.gradle b/apps/udi-stub/build.gradle index b19ffb6e90f..34832bd733e 100644 --- a/apps/udi-stub/build.gradle +++ b/apps/udi-stub/build.gradle @@ -25,7 +25,6 @@ dependencies { implementation "com.sun.xml.ws:jaxws-rt:$versions.jaxws" - implementation "no.nav.testnav.libs:database" implementation "no.nav.testnav.libs:servlet-core" implementation "no.nav.testnav.libs:servlet-security" implementation "no.nav.testnav.libs:vault" diff --git a/apps/udi-stub/settings.gradle b/apps/udi-stub/settings.gradle index 768a4c41be3..ecadb87fc43 100644 --- a/apps/udi-stub/settings.gradle +++ b/apps/udi-stub/settings.gradle @@ -7,7 +7,6 @@ rootProject.name = 'udi-stub' includeBuild "../../plugins/java" includeBuild '../../libs/data-transfer-objects' -includeBuild '../../libs/database' includeBuild '../../libs/servlet-core' includeBuild '../../libs/servlet-security' includeBuild '../../libs/vault' diff --git a/apps/udi-stub/src/test/resources/application-test.yml b/apps/udi-stub/src/test/resources/application-test.yml index e191f5ee131..fe24f5b2071 100644 --- a/apps/udi-stub/src/test/resources/application-test.yml +++ b/apps/udi-stub/src/test/resources/application-test.yml @@ -6,9 +6,6 @@ spring: secretmanager: enabled: false vault: - database: - enabled: false - token: "test" enabled: false datasource: url: jdbc:tc:postgresql:15:///test?TC_REUSABLE=true diff --git a/libs/database/build.gradle b/libs/database/build.gradle deleted file mode 100644 index a41ac47cec6..00000000000 --- a/libs/database/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -plugins { - id "dolly-libs" -} - -sonarqube { - properties { - property "sonar.projectKey", "testnav-database" - property "sonar.projectName", "testnav-database" - } -} - - -dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - - implementation 'org.springframework.cloud:spring-cloud-vault-config-databases' - implementation 'org.springframework.cloud:spring-cloud-starter-vault-config' - implementation 'org.flywaydb:flyway-core' - implementation 'org.flywaydb:flyway-database-postgresql' -} diff --git a/libs/database/gradle/wrapper/gradle-wrapper.jar b/libs/database/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2ae..00000000000 Binary files a/libs/database/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/libs/database/gradle/wrapper/gradle-wrapper.properties b/libs/database/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 48c0a02ca41..00000000000 --- a/libs/database/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/libs/database/gradlew b/libs/database/gradlew deleted file mode 100755 index 3da45c161b0..00000000000 --- a/libs/database/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright ? 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?, -# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?; -# * compound commands having a testable exit status, especially ?case?; -# * various built-in commands including ?command?, ?set?, and ?ulimit?. -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/libs/database/gradlew.bat b/libs/database/gradlew.bat deleted file mode 100644 index ac1b06f9382..00000000000 --- a/libs/database/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/libs/database/gradlewUpdate.sh b/libs/database/gradlewUpdate.sh deleted file mode 100755 index e5ee6361152..00000000000 --- a/libs/database/gradlewUpdate.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -gradle wrapper \ No newline at end of file diff --git a/libs/database/settings.gradle b/libs/database/settings.gradle deleted file mode 100644 index 8ad6f78209f..00000000000 --- a/libs/database/settings.gradle +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id "com.gradle.develocity" version "3.17.4" -} - -rootProject.name = 'database' - -includeBuild "../../plugins/java" - -develocity { - buildScan { - termsOfUseUrl = "https://gradle.com/terms-of-service" - termsOfUseAgree = "yes" - } -} diff --git a/libs/vault/build.gradle b/libs/vault/build.gradle index e4af068b808..e524b72f38a 100644 --- a/libs/vault/build.gradle +++ b/libs/vault/build.gradle @@ -1,7 +1,13 @@ plugins { - id 'dolly-libs' + id "dolly-libs" } dependencies { api "org.springframework.cloud:spring-cloud-starter-vault-config" + + implementation "org.springframework.boot:spring-boot-starter-data-jpa" + implementation "org.springframework.cloud:spring-cloud-vault-config-databases" + + implementation "org.flywaydb:flyway-core" + implementation "org.flywaydb:flyway-database-postgresql" } \ No newline at end of file diff --git a/libs/database/src/main/java/no/nav/testnav/libs/database/config/FlywayConfiguration.java b/libs/vault/src/main/java/no/nav/testnav/libs/database/config/FlywayConfiguration.java similarity index 100% rename from libs/database/src/main/java/no/nav/testnav/libs/database/config/FlywayConfiguration.java rename to libs/vault/src/main/java/no/nav/testnav/libs/database/config/FlywayConfiguration.java diff --git a/libs/database/src/main/java/no/nav/testnav/libs/database/config/VaultHikariConfiguration.java b/libs/vault/src/main/java/no/nav/testnav/libs/database/config/VaultHikariConfiguration.java similarity index 100% rename from libs/database/src/main/java/no/nav/testnav/libs/database/config/VaultHikariConfiguration.java rename to libs/vault/src/main/java/no/nav/testnav/libs/database/config/VaultHikariConfiguration.java