From 1eb3301ed22dab00250f32516160837acd638e9d Mon Sep 17 00:00:00 2001 From: JulieHillRoa Date: Tue, 29 Oct 2024 10:12:10 +0100 Subject: [PATCH] =?UTF-8?q?Fjerner=20endepunkt=20hent-registrering=20og=20?= =?UTF-8?q?alt=20som=20g=C3=A5r=20mot=20veilarbregistrering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nais-dev-gcp.yaml | 6 -- nais-prod-gcp.yaml | 6 -- .../VeilarbregistreringClient.java | 10 --- .../VeilarbregistreringClientImpl.java | 45 ----------- .../veilarbperson/config/ClientConfig.java | 9 --- .../config/EnvironmentProperties.java | 2 - .../veilarbperson/config/SelftTestConfig.java | 3 - .../controller/v1/PersonController.java | 8 -- .../controller/v3/PersonV3Controller.java | 8 -- .../service/RegistreringService.java | 19 ----- src/main/resources/application.properties | 2 - .../config/ClientTestConfig.java | 9 --- .../controller/PersonControllerTest.java | 81 ------------------- .../controller/PersonV3ControllerTest.java | 49 ----------- 14 files changed, 257 deletions(-) delete mode 100644 src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClient.java delete mode 100644 src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClientImpl.java delete mode 100644 src/test/java/no/nav/veilarbperson/controller/PersonControllerTest.java diff --git a/nais-dev-gcp.yaml b/nais-dev-gcp.yaml index 9c167aa9..83c586f8 100644 --- a/nais-dev-gcp.yaml +++ b/nais-dev-gcp.yaml @@ -65,8 +65,6 @@ spec: namespace: team-rocket - application: poao-tilgang namespace: poao - - application: veilarbregistrering - namespace: paw - application: aia-backend namespace: paw - application: paw-arbeidssoekerregisteret-api-oppslag @@ -121,10 +119,6 @@ spec: value: api://dev-gcp.poao.veilarboppfolging/.default - name: VEILARBOPPFOLGING_URL value: http://veilarboppfolging.poao/veilarboppfolging - - name: VEILARBREGISTRERING_SCOPE - value: api://dev-gcp.paw.veilarbregistrering/.default - - name: VEILARBREGISTRERING_URL - value: http://veilarbregistrering.paw - name: KONTOREGISTER_PERSON_V1_SCOPE value: api://dev-gcp.okonomi.sokos-kontoregister-person/.default - name: KONTOREGISTER_PERSON_V1_URL diff --git a/nais-prod-gcp.yaml b/nais-prod-gcp.yaml index e1bd4351..54ead39b 100644 --- a/nais-prod-gcp.yaml +++ b/nais-prod-gcp.yaml @@ -64,8 +64,6 @@ spec: namespace: team-rocket - application: poao-tilgang namespace: poao - - application: veilarbregistrering - namespace: paw - application: aia-backend namespace: paw - application: paw-arbeidssoekerregisteret-api-oppslag @@ -121,10 +119,6 @@ spec: value: api://prod-gcp.poao.veilarboppfolging/.default - name: VEILARBOPPFOLGING_URL value: http://veilarboppfolging.poao/veilarboppfolging - - name: VEILARBREGISTRERING_SCOPE - value: api://prod-gcp.paw.veilarbregistrering/.default - - name: VEILARBREGISTRERING_URL - value: http://veilarbregistrering.paw - name: KONTOREGISTER_PERSON_V1_SCOPE value: api://prod-gcp.okonomi.sokos-kontoregister-person/.default - name: KONTOREGISTER_PERSON_V1_URL diff --git a/src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClient.java b/src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClient.java deleted file mode 100644 index 6d876b63..00000000 --- a/src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClient.java +++ /dev/null @@ -1,10 +0,0 @@ -package no.nav.veilarbperson.client.veilarbregistrering; - -import no.nav.common.health.HealthCheck; -import no.nav.common.types.identer.Fnr; -import okhttp3.Response; - -public interface VeilarbregistreringClient extends HealthCheck { - - Response hentRegistrering(Fnr fnr); -} diff --git a/src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClientImpl.java b/src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClientImpl.java deleted file mode 100644 index 30ff8ec9..00000000 --- a/src/main/java/no/nav/veilarbperson/client/veilarbregistrering/VeilarbregistreringClientImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -package no.nav.veilarbperson.client.veilarbregistrering; - -import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import no.nav.common.health.HealthCheckResult; -import no.nav.common.health.HealthCheckUtils; -import no.nav.common.rest.client.RestClient; -import no.nav.common.types.identer.Fnr; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import org.springframework.http.HttpHeaders; - -import java.util.function.Supplier; - -import static no.nav.common.utils.UrlUtils.joinPaths; -import static org.springframework.http.HttpHeaders.ACCEPT; -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; - -@RequiredArgsConstructor -public class VeilarbregistreringClientImpl implements VeilarbregistreringClient { - - private final OkHttpClient client; - - private final String veilarbregistreringUrl; - - private final Supplier serviceTokenSupplier; - - @Override - @SneakyThrows - public Response hentRegistrering(Fnr fnr) { - Request request = new Request.Builder() - .url(joinPaths(veilarbregistreringUrl, "/veilarbregistrering/api/registrering?fnr=" + fnr)) - .header(ACCEPT, APPLICATION_JSON_VALUE) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + serviceTokenSupplier.get()) - .build(); - - return RestClient.baseClient().newCall(request).execute(); - } - - @Override - public HealthCheckResult checkHealth() { - return HealthCheckUtils.pingUrl(joinPaths(veilarbregistreringUrl, "/veilarbregistrering/internal/isReady"), client); - } -} diff --git a/src/main/java/no/nav/veilarbperson/config/ClientConfig.java b/src/main/java/no/nav/veilarbperson/config/ClientConfig.java index 296c6b6c..9ea18874 100644 --- a/src/main/java/no/nav/veilarbperson/config/ClientConfig.java +++ b/src/main/java/no/nav/veilarbperson/config/ClientConfig.java @@ -36,8 +36,6 @@ import no.nav.veilarbperson.client.representasjon.RepresentasjonClientImpl; import no.nav.veilarbperson.client.veilarboppfolging.VeilarboppfolgingClient; import no.nav.veilarbperson.client.veilarboppfolging.VeilarboppfolgingClientImpl; -import no.nav.veilarbperson.client.veilarbregistrering.VeilarbregistreringClient; -import no.nav.veilarbperson.client.veilarbregistrering.VeilarbregistreringClientImpl; import no.nav.veilarbperson.service.AuthService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -115,13 +113,6 @@ public RepresentasjonClient representasjonClient(EnvironmentProperties propertie () -> authService.getAadOboTokenForTjeneste(properties.getReprApiScope())); } - @Bean - public VeilarbregistreringClient veilarbregistreringClient(EnvironmentProperties properties, AzureAdMachineToMachineTokenClient aadMachineToMachineTokenClient) { - return new VeilarbregistreringClientImpl(RestClient.baseClient(), - properties.getVeilarbregistreringUrl(), - () -> aadMachineToMachineTokenClient.createMachineToMachineToken(properties.getVeilarbregistreringScope())); - } - @Bean public OppslagArbeidssoekerregisteretClient oppslagArbeidssoekerregisteretClient( EnvironmentProperties properties, diff --git a/src/main/java/no/nav/veilarbperson/config/EnvironmentProperties.java b/src/main/java/no/nav/veilarbperson/config/EnvironmentProperties.java index 75b80a15..c41c103c 100644 --- a/src/main/java/no/nav/veilarbperson/config/EnvironmentProperties.java +++ b/src/main/java/no/nav/veilarbperson/config/EnvironmentProperties.java @@ -31,8 +31,6 @@ public class EnvironmentProperties { private String skjermedePersonerPipUrl; private String veilarboppfolgingScope; private String veilarboppfolgingUrl; - private String veilarbregistreringScope; - private String veilarbregistreringUrl; private String kontoregisterScope; private String kontoregisterUrl; private String aiaBackendUrl; diff --git a/src/main/java/no/nav/veilarbperson/config/SelftTestConfig.java b/src/main/java/no/nav/veilarbperson/config/SelftTestConfig.java index 17c29efa..8eeb1107 100644 --- a/src/main/java/no/nav/veilarbperson/config/SelftTestConfig.java +++ b/src/main/java/no/nav/veilarbperson/config/SelftTestConfig.java @@ -10,7 +10,6 @@ import no.nav.veilarbperson.client.nom.SkjermetClient; import no.nav.veilarbperson.client.pdl.PdlClient; import no.nav.veilarbperson.client.regoppslag.RegoppslagClient; -import no.nav.veilarbperson.client.veilarbregistrering.VeilarbregistreringClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -27,7 +26,6 @@ public SelfTestChecks selfTestChecks( SkjermetClient skjermetClient, Norg2Client norg2Client, PdlClient pdlClient, - VeilarbregistreringClient veilarbregistreringClient, RegoppslagClient regoppslagClient ) { return new SelfTestChecks(List.of( @@ -37,7 +35,6 @@ public SelfTestChecks selfTestChecks( new SelfTestCheck("Norg2", false, norg2Client), new SelfTestCheck("PDL", true, pdlClient), new SelfTestCheck("skjermede-personer", true, skjermetClient), - new SelfTestCheck("Veilarbregistrering", false, veilarbregistreringClient), new SelfTestCheck("Regoppslag", false, regoppslagClient) )); } diff --git a/src/main/java/no/nav/veilarbperson/controller/v1/PersonController.java b/src/main/java/no/nav/veilarbperson/controller/v1/PersonController.java index b02b51b6..4f66d534 100644 --- a/src/main/java/no/nav/veilarbperson/controller/v1/PersonController.java +++ b/src/main/java/no/nav/veilarbperson/controller/v1/PersonController.java @@ -79,14 +79,6 @@ public ResponseEntity cvOgJobbprofil(@RequestParam(value = "fnr", requir return cvJobbprofilService.hentCvJobbprofilJson(fnr); } - @Deprecated - @GetMapping("/registrering") - public ResponseEntity registrering(@RequestParam(value = "fnr") Fnr fnr) { - authService.stoppHvisEksternBruker(); - authService.sjekkLesetilgang(fnr); - return registreringService.hentRegistrering(fnr); - } - @Deprecated @PostMapping("/registrering/endringer") public ResponseEntity endringIRegistreringdata(@RequestBody PersonRequestBody personRequestBody) { diff --git a/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java b/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java index fd5f09cb..212efc79 100644 --- a/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java +++ b/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java @@ -72,14 +72,6 @@ public ResponseEntity cvOgJobbprofil(@RequestBody PersonRequest personRe return cvJobbprofilService.hentCvJobbprofilJson(personRequest.getFnr()); } - @PostMapping("/person/hent-registrering") - @Operation(summary = "Henter registreringen til person") - public ResponseEntity registrering(@RequestBody PersonRequest personRequest) { - authService.stoppHvisEksternBruker(); - authService.sjekkLesetilgang(personRequest.getFnr()); - return registreringService.hentRegistrering(personRequest.getFnr()); - } - @PostMapping("/person/registrering/hent-endringer") @Operation(summary = "Henter endringer på registreringen til person") public ResponseEntity endringIRegistreringdata(@RequestBody PersonRequest personRequest) { diff --git a/src/main/java/no/nav/veilarbperson/service/RegistreringService.java b/src/main/java/no/nav/veilarbperson/service/RegistreringService.java index fcebf9b7..8743640c 100644 --- a/src/main/java/no/nav/veilarbperson/service/RegistreringService.java +++ b/src/main/java/no/nav/veilarbperson/service/RegistreringService.java @@ -5,7 +5,6 @@ import no.nav.common.types.identer.Fnr; import no.nav.veilarbperson.client.aiabackend.AiaBackendClient; import no.nav.veilarbperson.client.aiabackend.EndringIRegistreringsdataRequestDTO; -import no.nav.veilarbperson.client.veilarbregistrering.VeilarbregistreringClient; import okhttp3.Response; import okhttp3.ResponseBody; import org.springframework.http.ResponseEntity; @@ -15,26 +14,8 @@ @Service public class RegistreringService { - private final VeilarbregistreringClient client; private final AiaBackendClient aiaBackendClient; - @SneakyThrows - public ResponseEntity hentRegistrering(Fnr fnr) { - try (Response response = client.hentRegistrering(fnr); - ResponseBody responseBody = response.body()) { - - String bodyString = null; - - if (responseBody != null) { - bodyString = responseBody.string(); - } - - return ResponseEntity - .status(response.code()) - .body(bodyString); - } - } - @SneakyThrows public ResponseEntity hentEndringIRegistreringsdata(Fnr fnr) { try (Response response = aiaBackendClient.hentEndringIRegistreringsdata(new EndringIRegistreringsdataRequestDTO(fnr.get())); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index eebb49db..bd74df13 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -31,8 +31,6 @@ app.env.skjermedePersonerPipScope=${SKJERMEDE_PERSONER_PIP_SCOPE} app.env.skjermedePersonerPipUrl=${SKJERMEDE_PERSONER_PIP_URL} app.env.veilarboppfolgingScope=${VEILARBOPPFOLGING_SCOPE} app.env.veilarboppfolgingUrl=${VEILARBOPPFOLGING_URL} -app.env.veilarbregistreringScope=${VEILARBREGISTRERING_SCOPE} -app.env.veilarbregistreringUrl=${VEILARBREGISTRERING_URL} app.env.kontoregisterScope=${KONTOREGISTER_PERSON_V1_SCOPE} app.env.kontoregisterUrl=${KONTOREGISTER_PERSON_V1_URL} app.env.aiaBackendUrl=${AIA_BACKEND_URL} diff --git a/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java b/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java index 2456c635..b6bc270c 100644 --- a/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java +++ b/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java @@ -28,11 +28,8 @@ import no.nav.veilarbperson.client.pdl.PdlClient; import no.nav.veilarbperson.client.pdl.domain.PdlRequest; import no.nav.veilarbperson.client.representasjon.RepresentasjonClient; -import no.nav.veilarbperson.client.representasjon.RepresentasjonClientImpl; import no.nav.veilarbperson.client.veilarboppfolging.UnderOppfolging; import no.nav.veilarbperson.client.veilarboppfolging.VeilarboppfolgingClient; -import no.nav.veilarbperson.client.veilarbregistrering.VeilarbregistreringClient; -import no.nav.veilarbperson.client.veilarbregistrering.VeilarbregistreringClientImpl; import okhttp3.Response; import org.jetbrains.annotations.NotNull; import org.mockito.Mockito; @@ -279,12 +276,6 @@ public SelfTestChecks selfTestChecks() { return mock(SelfTestChecks.class); } - @Bean - public VeilarbregistreringClient veilarbregistreringClient() { - return new VeilarbregistreringClientImpl( - RestClient.baseClient(), "http://localhost:" + WIREMOCK_PORT, () -> ""); - } - @Bean public OppslagArbeidssoekerregisteretClient oppslagArbeidssoekerregisteretClient() { return new OppslagArbeidssoekerregisteretClientImpl( diff --git a/src/test/java/no/nav/veilarbperson/controller/PersonControllerTest.java b/src/test/java/no/nav/veilarbperson/controller/PersonControllerTest.java deleted file mode 100644 index 49a7d83e..00000000 --- a/src/test/java/no/nav/veilarbperson/controller/PersonControllerTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package no.nav.veilarbperson.controller; - -import com.github.tomakehurst.wiremock.client.WireMock; -import no.nav.poao_tilgang.poao_tilgang_test_core.NavAnsatt; -import no.nav.poao_tilgang.poao_tilgang_test_core.NavContext; -import no.nav.poao_tilgang.poao_tilgang_test_core.PrivatBruker; -import no.nav.veilarbperson.config.ApplicationTestConfig; -import no.nav.veilarbperson.controller.v1.PersonController; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.web.servlet.MockMvc; - -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@WebMvcTest(controllers = PersonController.class) -@Import({ApplicationTestConfig.class}) -@DirtiesContext -public class PersonControllerTest { - - @Autowired - private MockMvc mockMvc; - - @Autowired - private NavContext navContext; - - @Test - public void returnerer_registrering_for_registrert_bruker() throws Exception { - PrivatBruker ny = navContext.getPrivatBrukere().ny(); - NavAnsatt navAnsatt = navContext.getNavAnsatt().nyFor(ny); - - - String expectedJson = "{}"; - String fnr = ny.getNorskIdent(); - - stubFor(WireMock.get(urlEqualTo("/veilarbregistrering/api/registrering?fnr=" + fnr)) - .willReturn(ok() - .withHeader("Content-Type", "application/json") - .withBody(expectedJson))); - - - mockMvc - .perform( - get("/api/person/registrering") - .queryParam("fnr", fnr) - .header("test_ident", navAnsatt.getNavIdent()) - .header("test_ident_type", "INTERN") - ) - .andExpect(content().json(expectedJson)) - .andExpect(status().is(200)); - } - - @Test - public void returnerer_ikke_registrering_for_bruker_som_ikke_er_registrert() throws Exception { - PrivatBruker ny = navContext.getPrivatBrukere().ny(); - NavAnsatt navAnsatt = navContext.getNavAnsatt().nyFor(ny); - - String fnr = ny.getNorskIdent(); - - stubFor(WireMock.get(urlEqualTo("/veilarbregistrering/api/registrering?fnr=" + fnr)) - .willReturn( - notFound() - .withHeader("Content-Type", "application/json"))); - - - mockMvc - .perform( - get("/api/person/registrering") - .queryParam("fnr", fnr) - .header("test_ident", navAnsatt.getNavIdent()) - .header("test_ident_type", "INTERN") - ) - .andExpect(status().is(404)); - } -} - diff --git a/src/test/java/no/nav/veilarbperson/controller/PersonV3ControllerTest.java b/src/test/java/no/nav/veilarbperson/controller/PersonV3ControllerTest.java index 0cd158ed..bc7e5955 100644 --- a/src/test/java/no/nav/veilarbperson/controller/PersonV3ControllerTest.java +++ b/src/test/java/no/nav/veilarbperson/controller/PersonV3ControllerTest.java @@ -47,55 +47,6 @@ public class PersonV3ControllerTest { @MockBean private PersonV2Service personV2Service; - @Test - public void returnerer_registrering_for_registrert_bruker() throws Exception { - PrivatBruker ny = navContext.getPrivatBrukere().ny(); - NavAnsatt navAnsatt = navContext.getNavAnsatt().nyFor(ny); - - String expectedJson = "{}"; - String fnr = ny.getNorskIdent(); - - stubFor(WireMock.get(urlEqualTo("/veilarbregistrering/api/registrering?fnr=" + fnr)) - .willReturn(ok() - .withHeader("Content-Type", "application/json") - .withBody(expectedJson))); - - - mockMvc - .perform( - post("/api/v3/person/hent-registrering") - .contentType(APPLICATION_JSON) - .content("{\"fnr\":\"" + fnr + "\"}") - .header("test_ident", navAnsatt.getNavIdent()) - .header("test_ident_type", "INTERN") - ) - .andExpect(content().json(expectedJson)) - .andExpect(status().is(200)); - } - - @Test - public void returnerer_ikke_registrering_for_bruker_som_ikke_er_registrert() throws Exception { - PrivatBruker ny = navContext.getPrivatBrukere().ny(); - NavAnsatt navAnsatt = navContext.getNavAnsatt().nyFor(ny); - String fnr = ny.getNorskIdent(); - - stubFor(WireMock.get(urlEqualTo("/veilarbregistrering/api/registrering?fnr=" + fnr)) - .willReturn( - notFound() - .withHeader("Content-Type", "application/json"))); - - - mockMvc - .perform( - post("/api/v3/person/hent-registrering") - .contentType(APPLICATION_JSON) - .content("{\"fnr\":\"" + fnr + "\"}") - .header("test_ident", navAnsatt.getNavIdent()) - .header("test_ident_type", "INTERN") - ) - .andExpect(status().is(404)); - } - @Test public void returnerer_person_uten_behandlingsnummer_hent_person() throws Exception { PrivatBruker ny = navContext.getPrivatBrukere().ny();