Skip to content

Commit

Permalink
Merge branch 'master' into feature/sykemelding-forbedre-status-tilbak…
Browse files Browse the repository at this point in the history
…emelding
  • Loading branch information
krharum committed Nov 28, 2024
2 parents 23d7c26 + de9bc7e commit c8f2469
Show file tree
Hide file tree
Showing 34 changed files with 767 additions and 57 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/proxy.sykemelding-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: sykemelding-proxy

on:
push:
paths:
- "plugins/**"
- "libs/reactive-core/**"
- "libs/reactive-proxy/**"
- "libs/security-token-service/**"
- "proxies/sykemelding-proxy/**"
- ".github/workflows/proxy.sykemelding-proxy.yml"

jobs:
workflow:
uses: ./.github/workflows/common.workflow.backend.yml
with:
cluster: "dev-gcp"
working-directory: "proxies/sykemelding-proxy"
deploy-tag: "#deploy-proxy-sykemelding"
permissions:
contents: read
id-token: write
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonforvalterResponse;
import no.nav.dolly.domain.jpa.TransaksjonMapping;
Expand All @@ -21,18 +21,12 @@

@Slf4j
@Service
@NoArgsConstructor
@RequiredArgsConstructor
public class PensjonforvalterHelper {

private TransaksjonMappingService transaksjonMappingService;
private ObjectMapper objectMapper;
private ErrorStatusDecoder errorStatusDecoder;

public PensjonforvalterHelper(TransaksjonMappingService transaksjonMappingService, ObjectMapper objectMapper, ErrorStatusDecoder errorStatusDecoder) {
this.transaksjonMappingService = transaksjonMappingService;
this.objectMapper = objectMapper;
this.errorStatusDecoder = errorStatusDecoder;
}
private final TransaksjonMappingService transaksjonMappingService;
private final ObjectMapper objectMapper;
private final ErrorStatusDecoder errorStatusDecoder;

@SuppressWarnings("java:S3740")
public void saveAPTransaksjonId(String ident, String miljoe, Long bestillingId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
Expand All @@ -43,7 +44,8 @@ public ObjectMapper objectMapper() {
.addDeserializer(YearMonth.class, new DollyYearMonthDeserializer())
.addSerializer(YearMonth.class, new YearMonthSerializer(DateTimeFormatter.ofPattern(YEAR_MONTH)))
.addDeserializer(ZonedDateTime.class, new DollyZonedDateTimeDeserializer())
.addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer(DateTimeFormatter.ISO_DATE_TIME));
.addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer(DateTimeFormatter.ISO_DATE_TIME))
.addDeserializer(Instant.class, new DollyInstantDeserializer());
return JsonMapper
.builder()
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
Expand Down Expand Up @@ -107,4 +109,17 @@ public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext d
return dateTime.length() > 10 ? LocalDateTime.parse(dateTime) : LocalDate.parse(dateTime).atStartOfDay();
}
}

private static class DollyInstantDeserializer extends JsonDeserializer<Instant> {

@Override
public Instant deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
if (isBlank(node.asText())) {
return null;
}
var timestamp = node.asText();
return Instant.parse(timestamp.contains("Z") ? timestamp : timestamp + "Z");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package no.nav.dolly.errorhandling;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
Expand All @@ -20,7 +20,7 @@

@Slf4j
@Service
@NoArgsConstructor
@RequiredArgsConstructor
public class ErrorStatusDecoder {

private static final String TEKNISK_FEIL = "Teknisk feil {} mottatt fra system";
Expand All @@ -31,11 +31,7 @@ public class ErrorStatusDecoder {
private static final String DETAILS = "details";
private static final String FEIL = "Feil= ";

private ObjectMapper objectMapper;

public ErrorStatusDecoder(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
private final ObjectMapper objectMapper;

public static String getInfoVenter(String system) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.dolly.bestilling.pensjonforvalter.service;

import com.fasterxml.jackson.databind.ObjectMapper;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MappingContext;
import no.nav.dolly.bestilling.pensjonforvalter.PensjonforvalterConsumer;
Expand All @@ -13,6 +14,9 @@
import no.nav.dolly.domain.jpa.BestillingProgress;
import no.nav.dolly.domain.resultset.RsDollyUtvidetBestilling;
import no.nav.dolly.domain.resultset.pensjon.PensjonData;
import no.nav.dolly.errorhandling.ErrorStatusDecoder;
import no.nav.dolly.repository.TransaksjonMappingRepository;
import no.nav.dolly.service.TransaksjonMappingService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -51,8 +55,13 @@ class PensjonPensjonsdataServiceTest {

private static final String IDENT = "11111111111";

@Mock
private TransaksjonMappingRepository transaksjonMappingRepository;

@Spy
private PensjonforvalterHelper pensjonforvalterHelper;
private PensjonforvalterHelper pensjonforvalterHelper =
new PensjonforvalterHelper(new TransaksjonMappingService(transaksjonMappingRepository, new ObjectMapper()),
new ObjectMapper(), new ErrorStatusDecoder(new ObjectMapper()));

@Mock
private PensjonforvalterConsumer pensjonforvalterConsumer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.dolly.bestilling.pensjonforvalter.utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonforvalterResponse;
import no.nav.dolly.errorhandling.ErrorStatusDecoder;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -16,7 +17,7 @@
class PensjonforvalterHelperTest {

@Spy
private ErrorStatusDecoder errorStatusDecoder;
private ErrorStatusDecoder errorStatusDecoder = new ErrorStatusDecoder(new ObjectMapper());

@InjectMocks
private PensjonforvalterHelper pensjonforvalterHelper;
Expand Down
10 changes: 0 additions & 10 deletions apps/person-service/src/main/resources/pdl/pdlPerson2Query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,6 @@ query($ident: ID!, $historikk: Boolean!) {
...metadataDetails
}
},
fullmakt(historikk: $historikk) {
motpartsPersonident,
motpartsRolle,
omraader,
gyldigFraOgMed,
gyldigTilOgMed,
metadata {
...metadataDetails
}
},
folkeregisteridentifikator(historikk: $historikk) {
identifikasjonsnummer,
status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ query($ident1: ID!) {
opplysningsId
}
}
fullmakt {
metadata {
opplysningsId
}
}
},
hentIdenter(ident: $ident1, historikk: true, grupper: [AKTORID, FOLKEREGISTERIDENT, NPID]) {
identer {
Expand Down
10 changes: 0 additions & 10 deletions apps/person-service/src/main/resources/pdl/pdlbolkquery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,6 @@ query($identer: [ID!]!) {
...metadataDetails
}
},
fullmakt(historikk: true) {
motpartsPersonident,
motpartsRolle,
omraader,
gyldigFraOgMed,
gyldigTilOgMed,
metadata {
...metadataDetails
}
},
folkeregisteridentifikator(historikk: true) {
identifikasjonsnummer,
status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AzureAdProfileConsumer(
.build());

if (proxyHost != null) {
log.info("Setter opp proxy host {} for Azure Ad", proxyHost);
log.trace("Setter opp proxy host {} for Azure Ad", proxyHost);
var uri = URI.create(proxyHost);
builder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public AzureAdTokenService(
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

if (proxyHost != null) {
log.info("Setter opp proxy host {} for Client Credentials", proxyHost);
log.trace("Setter opp proxy host {} for Client Credentials", proxyHost);
var uri = URI.create(proxyHost);
builder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ReactiveJwtDecoder jwtDecoder() {
private WebClient buildProxyWebClient(String proxyHost) {
var builder = WebClient.builder();
if (proxyHost != null) {
log.info("Setter opp proxy host {} for jwt decoder.", proxyHost);
log.trace("Setter opp proxy host {} for jwt decoder.", proxyHost);
var uri = URI.create(proxyHost);
builder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public AzureAdTokenService(
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

if (proxyHost != null) {
log.info("Setter opp proxy host {} for Client Credentials", proxyHost);
log.trace("Setter opp proxy host {} for Client Credentials", proxyHost);
var uri = URI.create(proxyHost);
builder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public NavAzureAdTokenService(
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

if (proxyHost != null) {
log.info("Setter opp proxy host {} for Client Credentials", proxyHost);
log.trace("Setter opp proxy host {} for Client Credentials", proxyHost);
var uri = URI.create(proxyHost);
HttpClient httpClient = HttpClient
.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public TrygdeetatenAzureAdTokenService(
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

if (nonNull(proxyHost)) {
log.info("Setter opp proxy host {} for Client Credentials", proxyHost);
log.trace("Setter opp proxy host {} for Client Credentials", proxyHost);
var uri = URI.create(proxyHost);
builder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AzureAdTokenService(
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

if (proxyHost != null) {
log.info("Setter opp proxy host {} for Client Credentials", proxyHost);
log.trace("Setter opp proxy host {} for Client Credentials", proxyHost);
var uri = URI.create(proxyHost);
builder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public AzureAdTokenService(
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

if (proxyHost != null) {
log.info("Setter opp proxy host {} for Client Credentials", proxyHost);
log.trace("Setter opp proxy host {} for Client Credentials", proxyHost);
var uri = URI.create(proxyHost);
builder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public SlackConsumer(
this.token = token;
this.applicationName = applicationName;
if (proxyHost != null) {
log.info("Setter opp proxy host {} for Slack api", proxyHost);
log.trace("Setter opp proxy host {} for Slack api", proxyHost);
var uri = URI.create(proxyHost);
webClientBuilder.clientConnector(new ReactorClientHttpConnector(
HttpClient
Expand All @@ -47,15 +47,15 @@ public SlackConsumer(
public void publish(Message message) {
log.info("Publiserer melding til slack.");
SlackResponse response = new PublishMessageCommand(webClient, token, message).call();
if (!response.getOk()) {
if (!Boolean.TRUE.equals(response.getOk())) {
throw new SlackConsumerException("Klarer ikke aa opprette slack melding", response);
}
}

public void uploadFile(byte[] file, String fileName, String channel) {
log.info("Publiserer fil til slack.");
SlackResponse response = new UploadFileCommand(webClient, token, file, fileName, channel, applicationName).call();
if (!response.getOk()) {
if (!Boolean.TRUE.equals(response.getOk())) {
throw new SlackConsumerException("Klarer ikke aa opprette slack melding", response);
}
}
Expand Down
8 changes: 8 additions & 0 deletions proxies/sykemelding-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ghcr.io/navikt/baseimages/temurin:21
LABEL maintainer="Team Dolly"

ENV JAVA_OPTS="-Dspring.profiles.active=prod"

ADD /build/libs/app.jar /app/app.jar

EXPOSE 8080
18 changes: 18 additions & 0 deletions proxies/sykemelding-proxy/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id "dolly-proxies"
}

sonarqube {
properties {
property "sonar.projectKey", "testnav-sykemelding-proxy"
property "sonar.projectName", "testnav-sykemelding-proxy"
}
}

dependencies {
implementation 'no.nav.testnav.libs:security-core'
implementation 'no.nav.testnav.libs:reactive-security'
implementation 'no.nav.testnav.libs:data-transfer-objects'

testImplementation 'org.springframework.security:spring-security-test'
}
Loading

0 comments on commit c8f2469

Please sign in to comment.