Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/levende-arbeidsforhold
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum committed Aug 27, 2024
2 parents 31d9216 + 0005d81 commit 51ca2ae
Show file tree
Hide file tree
Showing 99 changed files with 1,160 additions and 396 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/common.integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: ./gradlew assemble --scan
- name: "Start docker containers"
run: |
JWK=$(cat ./mocks/jwk.json) docker-compose up -d --build
JWK=$(cat ./mocks/jwk.json) docker compose up --build --detach
- name: "Health check"
timeout-minutes: 5
run: |
Expand All @@ -52,4 +52,4 @@ jobs:
run: ./gradlew iTest --scan
- name: "Stop docker containers"
run: |
docker-compose down -v --remove-orphans
docker compose down --remove-orphans --volumes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Eller kjør:
Kjør kommandoen:

```
JWK=$(cat ./mocks/jwk.json) docker-compose up --build
JWK=$(cat ./mocks/jwk.json) docker compose up --build
```

Deretter kan itegrasjonstester kjøres med kommandoen:
Expand Down
1 change: 1 addition & 0 deletions apps/app-tilgang-analyse-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
implementation 'io.r2dbc:r2dbc-h2'
implementation 'org.postgresql:r2dbc-postgresql'
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-database-postgresql'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'

implementation "org.springdoc:springdoc-openapi-starter-webflux-ui:$versions.springdoc"
Expand Down
1 change: 1 addition & 0 deletions apps/app-tilgang-analyse-service/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_12
tier: db-custom-1-3840
databases:
- name: testnav-app-tilgang-analyse-service-db
liveness:
Expand Down
1 change: 1 addition & 0 deletions apps/brreg-stub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation 'com.zaxxer:HikariCP'

implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-database-postgresql'
implementation 'com.h2database:h2'

implementation 'wsdl4j:wsdl4j'
Expand Down
1 change: 1 addition & 0 deletions apps/bruker-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
implementation 'io.r2dbc:r2dbc-h2'
implementation 'org.postgresql:r2dbc-postgresql'
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-database-postgresql'

runtimeOnly 'org.postgresql:postgresql'
runtimeOnly 'com.h2database:h2'
Expand Down
1 change: 1 addition & 0 deletions apps/bruker-service/config.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_12
tier: db-custom-1-3840
databases:
- name: testnav-bruker-service-dev-db
resources:
Expand Down
1 change: 1 addition & 0 deletions apps/bruker-service/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_12
tier: db-custom-1-3840
databases:
- name: testnav-bruker-service-db
envFrom:
Expand Down
2 changes: 2 additions & 0 deletions apps/dolly-backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ dependencies {

implementation 'org.postgresql:postgresql'
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-database-postgresql'

implementation "ma.glasnost.orika:orika-core:$versions.orika"
implementation 'org.codehaus.jettison:jettison:1.5.4'
implementation "org.apache.poi:poi:$versions.apachePoi"
Expand Down
1 change: 1 addition & 0 deletions apps/dolly-backend/config.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_14
tier: db-custom-1-3840
name: testnav-dolly-backend-dev
databases:
- name: testnav-dolly-backend-dev
Expand Down
2 changes: 1 addition & 1 deletion apps/dolly-backend/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_14
tier: db-custom-2-7680
name: testnav-dolly-backend
databases:
- name: testnav-dolly-backend
tier: db-custom-2-3840
autoBackupHour: 2
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static void main(String[] args) {

SpringApplication.run(DollyBackendApplicationStarter.class, args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public void mapAtoB(RsInntektsmelding rsInntektsmelding,
public void mapAtoB(RsInntektsmelding.Inntektsmelding rsInntektsmelding,
RsInntektsmeldingRequest inntektsmelding, MappingContext context) {

inntektsmelding.setAarsakTilInnsending(
nullcheckSetDefaultValue(inntektsmelding.getAarsakTilInnsending(), AarsakInnsendingKodeListe.NY));
inntektsmelding.setAarsakTilInnsending(nonNull(rsInntektsmelding.getAarsakTilInnsending()) ?
mapperFacade.map(rsInntektsmelding.getAarsakTilInnsending(), AarsakInnsendingKodeListe.class) :
AarsakInnsendingKodeListe.NY);

if (nonNull(rsInntektsmelding.getArbeidsgiver())) {

Expand Down Expand Up @@ -254,4 +255,4 @@ private static LocalDateTime toLocalDateTime(LocalDate localDate) {

return nonNull(localDate) ? localDate.atStartOfDay() : null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.Collection;
import java.util.List;

public interface BestillingElasticRepository extends ElasticsearchRepository<ElasticBestilling, Long> {

List<ElasticBestilling> getAllByIdenterIn(List<String> ident);
List<ElasticBestilling> getAllByIdenterIn(Collection<String> identer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import static java.util.Objects.nonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,29 @@
import no.nav.dolly.domain.resultset.Tags;
import no.nav.dolly.domain.resultset.entity.testgruppe.RsTestgruppe;
import no.nav.dolly.mapper.MappingStrategy;
import no.nav.testnav.libs.servletsecurity.action.GetUserInfo;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import static java.util.Objects.nonNull;
import static no.nav.dolly.util.CurrentAuthentication.getUserId;
import static org.apache.commons.lang3.BooleanUtils.isTrue;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

@Component
@RequiredArgsConstructor
public class TestgruppeMappingStrategy implements MappingStrategy {

private final GetUserInfo getUserInfo;

private static String getBrukerId(Bruker bruker) {

if (isNotBlank(bruker.getBrukerId())) {
return bruker.getBrukerId();
} else {
return nonNull(bruker.getEidAv()) ? bruker.getEidAv().getBrukerId() : bruker.getNavIdent();
}
}

@Override
public void register(MapperFactory factory) {
factory.classMap(Testgruppe.class, RsTestgruppe.class)
.customize(new CustomMapper<>() {
@Override
public void mapAtoB(Testgruppe testgruppe, RsTestgruppe rsTestgruppe, MappingContext context) {

var securityContext = (SecurityContext) context.getProperty("securityContext");
if (nonNull(securityContext)) {
SecurityContextHolder.setContext(securityContext);
}

rsTestgruppe.setAntallIdenter(testgruppe.getTestidenter().size());
rsTestgruppe.setAntallIBruk((int) testgruppe.getTestidenter().stream()
.filter(ident -> isTrue(ident.getIBruk()))
.count());
rsTestgruppe.setFavorittIGruppen(!testgruppe.getFavorisertAv().isEmpty());
rsTestgruppe.setErEierAvGruppe(getUserId(getUserInfo).equals(getBrukerId(testgruppe.getOpprettetAv())));
rsTestgruppe.setErEierAvGruppe(nonNull(context.getProperty("brukerId")) && (context.getProperty("brukerId")).equals(getBrukerId(testgruppe.getOpprettetAv())));
rsTestgruppe.setErLaast(isTrue(rsTestgruppe.getErLaast()));
rsTestgruppe.setTags(testgruppe.getTags().stream()
.filter(tag -> Tags.DOLLY != tag)
Expand All @@ -62,4 +42,13 @@ public void mapAtoB(Testgruppe testgruppe, RsTestgruppe rsTestgruppe, MappingCon
.byDefault()
.register();
}

private static String getBrukerId(Bruker bruker) {

if (isNotBlank(bruker.getBrukerId())) {
return bruker.getBrukerId();
} else {
return nonNull(bruker.getEidAv()) ? bruker.getEidAv().getBrukerId() : bruker.getNavIdent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public RsTestgruppe oppdaterTestgruppeLaas(@PathVariable("gruppeId") Long gruppe
return mapperFacade.map(gruppe, RsTestgruppe.class);
}

@CacheEvict(value = {CACHE_GRUPPE}, allEntries = true)
@CacheEvict(value = { CACHE_GRUPPE }, allEntries = true)
@PostMapping
@Transactional
@ResponseStatus(HttpStatus.CREATED)
Expand Down Expand Up @@ -155,7 +155,7 @@ public void slettgruppe(@PathVariable("gruppeId") Long gruppeId) {
testgruppeService.deleteGruppeById(gruppeId);
}

@CacheEvict(value = {CACHE_BESTILLING, CACHE_GRUPPE}, allEntries = true)
@CacheEvict(value = { CACHE_BESTILLING, CACHE_GRUPPE }, allEntries = true)
@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/{gruppeId}/bestilling")
@Operation(description = "Opprett berikede testpersoner basert på fødselsdato, kjønn og identtype")
Expand All @@ -167,7 +167,7 @@ public RsBestillingStatus opprettIdentBestilling(@PathVariable("gruppeId") Long
}

@Operation(description = "Opprett berikede testpersoner basert på eskisterende identer")
@CacheEvict(value = {CACHE_BESTILLING, CACHE_GRUPPE}, allEntries = true)
@CacheEvict(value = { CACHE_BESTILLING, CACHE_GRUPPE }, allEntries = true)
@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/{gruppeId}/bestilling/fraidenter")
public RsBestillingStatus opprettIdentBestillingFraIdenter(@PathVariable("gruppeId") Long gruppeId, @RequestBody RsDollyBestillingFraIdenterRequest request) {
Expand All @@ -179,7 +179,7 @@ public RsBestillingStatus opprettIdentBestillingFraIdenter(@PathVariable("gruppe
}

@Operation(description = "Importere testpersoner fra PDL og legg til berikning non-PDL artifacter")
@CacheEvict(value = {CACHE_BESTILLING, CACHE_GRUPPE}, allEntries = true)
@CacheEvict(value = { CACHE_BESTILLING, CACHE_GRUPPE }, allEntries = true)
@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/{gruppeId}/bestilling/importfrapdl")
public RsBestillingStatus importAvIdenterFraPdlBestilling(@PathVariable("gruppeId") Long gruppeId, @RequestBody RsDollyImportFraPdlRequest request) {
Expand All @@ -191,7 +191,7 @@ public RsBestillingStatus importAvIdenterFraPdlBestilling(@PathVariable("gruppeI
}

@Operation(description = "Legg til berikning på alle i gruppe")
@CacheEvict(value = {CACHE_BESTILLING, CACHE_GRUPPE}, allEntries = true)
@CacheEvict(value = { CACHE_BESTILLING, CACHE_GRUPPE }, allEntries = true)
@ResponseStatus(HttpStatus.OK)
@PutMapping("/{gruppeId}/leggtilpaagruppe")
public RsBestillingStatus endreGruppeLeggTil(@PathVariable("gruppeId") Long gruppeId, @RequestBody RsDollyBestillingLeggTilPaaGruppe request) {
Expand All @@ -201,7 +201,7 @@ public RsBestillingStatus endreGruppeLeggTil(@PathVariable("gruppeId") Long grup
return mapperFacade.map(bestilling, RsBestillingStatus.class);
}

@CacheEvict(value = {CACHE_BESTILLING, CACHE_GRUPPE}, allEntries = true)
@CacheEvict(value = { CACHE_BESTILLING, CACHE_GRUPPE }, allEntries = true)
@PutMapping("/{gruppeId}/gjenopprett")
@Operation(description = "Gjenopprett testidenter tilhørende en gruppe med liste for tilhørende miljoer")
public RsBestillingStatus gjenopprettBestilling(@PathVariable("gruppeId") Long gruppeId,
Expand All @@ -212,7 +212,7 @@ public RsBestillingStatus gjenopprettBestilling(@PathVariable("gruppeId") Long g
return mapperFacade.map(bestilling, RsBestillingStatus.class);
}

@CacheEvict(value = {CACHE_GRUPPE, CACHE_BESTILLING}, allEntries = true)
@CacheEvict(value = { CACHE_GRUPPE, CACHE_BESTILLING }, allEntries = true)
@Transactional
@PutMapping(value = "/{gruppeId}/identer/{identer}")
@Operation(description = "Flytt angitte identer til denne gruppe")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import ma.glasnost.orika.MapperFacade;
import no.nav.dolly.bestilling.service.GjenopprettIdentService;
import no.nav.dolly.bestilling.service.OppdaterPersonService;
import no.nav.testnav.libs.dto.dolly.v1.FinnesDTO;
import no.nav.dolly.domain.dto.TestidentDTO;
import no.nav.dolly.domain.jpa.Bestilling;
import no.nav.dolly.domain.jpa.Bruker;
import no.nav.dolly.domain.resultset.RsDollyUpdateRequest;
import no.nav.dolly.domain.resultset.RsIdentBeskrivelse;
import no.nav.dolly.domain.resultset.entity.bestilling.RsBestillingStatus;
Expand All @@ -16,11 +16,14 @@
import no.nav.dolly.domain.testperson.IdentAttributesResponse;
import no.nav.dolly.exceptions.NotFoundException;
import no.nav.dolly.service.BestillingService;
import no.nav.dolly.service.BrukerService;
import no.nav.dolly.service.IdentService;
import no.nav.dolly.service.NavigasjonService;
import no.nav.dolly.service.OrdreService;
import no.nav.dolly.service.PersonService;
import no.nav.dolly.service.TransaksjonMappingService;
import no.nav.testnav.libs.dto.dolly.v1.FinnesDTO;
import no.nav.testnav.libs.servletsecurity.action.GetUserInfo;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -42,6 +45,7 @@
import static java.util.Objects.nonNull;
import static no.nav.dolly.config.CachingConfig.CACHE_BESTILLING;
import static no.nav.dolly.config.CachingConfig.CACHE_GRUPPE;
import static no.nav.dolly.util.CurrentAuthentication.getUserId;

@RestController
@RequiredArgsConstructor
Expand All @@ -54,9 +58,11 @@ public class TestpersonController {
private final OppdaterPersonService oppdaterPersonService;
private final MapperFacade mapperFacade;
private final IdentService identService;
private final BrukerService brukerService;
private final PersonService personService;
private final NavigasjonService navigasjonService;
private final OrdreService ordreService;
private final GetUserInfo getUserInfo;

@Operation(description = "Legge til egenskaper på person/endre person i TPS og øvrige systemer")
@PutMapping("/{ident}/leggtilpaaperson")
Expand Down Expand Up @@ -133,7 +139,8 @@ public void deleteTestident(@PathVariable String ident) {
@GetMapping("/naviger/{ident}")
public Mono<RsWhereAmI> navigerTilTestident(@PathVariable String ident) {

return navigasjonService.navigerTilIdent(ident);
Bruker bruker = brukerService.fetchBruker(getUserId(getUserInfo));
return navigasjonService.navigerTilIdent(ident, bruker);
}

@Operation(description = "Sjekk om ønsket testperson finnes i Dolly")
Expand Down
Loading

0 comments on commit 51ca2ae

Please sign in to comment.