Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/toggle-i-fieldarray
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran authored Dec 6, 2024
2 parents 039d9fd + 78df828 commit 545729d
Show file tree
Hide file tree
Showing 32 changed files with 101 additions and 510 deletions.
3 changes: 0 additions & 3 deletions apps/adresse-service/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion apps/brreg-stub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion apps/brreg-stub/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ rootProject.name = 'brreg-stub'

includeBuild "../../plugins/java"

includeBuild '../../libs/database'
includeBuild '../../libs/servlet-core'
includeBuild '../../libs/vault'

Expand Down
3 changes: 0 additions & 3 deletions apps/sykemelding-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 0 additions & 15 deletions apps/synt-sykemelding-api/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions apps/synt-sykemelding-api/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 0 additions & 3 deletions apps/synt-sykemelding-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion apps/testnorge-statisk-data-forvalter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion apps/testnorge-statisk-data-forvalter/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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"));
Expand All @@ -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)));
}
Expand All @@ -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
Expand All @@ -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);

}

};

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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
Expand All @@ -66,21 +65,21 @@ class OrkestreringControllerAaregIntegrationTest {

private final KodeverkResponse kodeverkResponse = new KodeverkResponse(Collections.singletonList("yrke"));
private static String syntString;
private final TypeReference<List<RsAaregSyntetiseringsRequest>> SYNT_RESPONSE = new TypeReference<>() {
private final TypeReference<List<RsAaregSyntetiseringsRequest>> syntResponse = new TypeReference<>() {
};

@BeforeAll
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")));

Expand Down Expand Up @@ -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")));
Expand All @@ -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")));
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 545729d

Please sign in to comment.