diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2Controller.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2Controller.java index be753294..0ee09642 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2Controller.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2Controller.java @@ -81,7 +81,7 @@ public URI billingToken(@ApiParam("${swagger.dashboard.institutions.model.id}") log.debug("billing exchange institutionId = {}", Encode.forJava(institutionId)); log.info("env parameter: {}", Encode.forJava(environment.orElse(""))); - final ExchangedToken exchangedToken = exchangeTokenService.retrieveBillingExchangedToken(institutionId, lang); + final ExchangedToken exchangedToken = exchangeTokenService.retrieveBillingExchangedToken(institutionId); final URI location = URI.create(exchangedToken.getBackOfficeUrl().replace("", exchangedToken.getIdentityToken())); log.debug(LogUtils.CONFIDENTIAL_MARKER, "billing exchange result = {}", Encode.forJava(String.valueOf(location))); log.trace("billing exchange end"); diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2.java index 1f8c4b7e..3f3bd8c2 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2.java @@ -134,7 +134,7 @@ public ExchangedToken exchange(String institutionId, String productId, Optional< return new ExchangedToken(jwts, urlBO); } - public ExchangedToken retrieveBillingExchangedToken(String institutionId, String lang) { + public ExchangedToken retrieveBillingExchangedToken(String institutionId) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null || authentication.getPrincipal() == null || authentication.getCredentials() == null) { throw new IllegalStateException("Authentication is required"); @@ -165,9 +165,8 @@ public ExchangedToken retrieveBillingExchangedToken(String institutionId, String String jwts = createJwts(claims); log.debug(LogUtils.CONFIDENTIAL_MARKER, "Exchanged token = {}", jwts); log.trace("exchange end"); - final String billingUrlLang = Objects.nonNull(lang) ? billingUrl.concat("?lang=" + lang) : billingUrl; - return new ExchangedToken(jwts, billingUrlLang); + return new ExchangedToken(jwts, billingUrl); } private List retrieveInvoiceableProductList() { diff --git a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2ControllerTest.java b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2ControllerTest.java index c9722571..ad5d7950 100644 --- a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2ControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/TokenV2ControllerTest.java @@ -92,7 +92,7 @@ void exchange_emptyIdentityToken() throws Exception { void billingExchange() throws Exception { // given String institutionId = "inst1"; - Mockito.when(exchangeTokenServiceMock.retrieveBillingExchangedToken(institutionId, null)) + Mockito.when(exchangeTokenServiceMock.retrieveBillingExchangedToken(institutionId)) .thenReturn(new ExchangedToken("token", "urlBO")); // when MvcResult result = mockMvc.perform(MockMvcRequestBuilders @@ -107,7 +107,7 @@ void billingExchange() throws Exception { assertNotNull(resource); assertEquals(resource.toString(), "urlBO"); verify(exchangeTokenServiceMock, Mockito.times(1)) - .retrieveBillingExchangedToken(institutionId, null); + .retrieveBillingExchangedToken(institutionId); verifyNoMoreInteractions(exchangeTokenServiceMock); } @@ -115,7 +115,7 @@ void billingExchange() throws Exception { void billingExchange_emptyIdentityToken() throws Exception { // given String institutionId = "inst1"; - Mockito.when(exchangeTokenServiceMock.retrieveBillingExchangedToken(institutionId, null)) + Mockito.when(exchangeTokenServiceMock.retrieveBillingExchangedToken(institutionId)) .thenReturn(new ExchangedToken("", "")); // when MvcResult result = mockMvc.perform(MockMvcRequestBuilders @@ -130,7 +130,7 @@ void billingExchange_emptyIdentityToken() throws Exception { assertNotNull(resource); assertEquals(resource.toString(), ""); verify(exchangeTokenServiceMock, Mockito.times(1)) - .retrieveBillingExchangedToken(institutionId, null); + .retrieveBillingExchangedToken(institutionId); verifyNoMoreInteractions(exchangeTokenServiceMock); } } \ No newline at end of file diff --git a/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2Test.java b/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2Test.java index 185efa0d..628fd554 100644 --- a/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2Test.java +++ b/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/ExchangeTokenServiceV2Test.java @@ -644,7 +644,7 @@ void billingExchange_noAuth() throws Exception { JwtService jwtServiceMock = mock(JwtService.class); ExchangeTokenServiceV2 ExchangeTokenServiceV2 = new ExchangeTokenServiceV2(jwtServiceMock, null, null, null, properties, null, null, new InstitutionResourceMapperImpl()); // when - Executable executable = () -> ExchangeTokenServiceV2.retrieveBillingExchangedToken(null, null); + Executable executable = () -> ExchangeTokenServiceV2.retrieveBillingExchangedToken(null); // then IllegalStateException e = assertThrows(IllegalStateException.class, executable); assertEquals("Authentication is required", e.getMessage()); @@ -710,7 +710,7 @@ void billingExchange_noSessionTokenClaims() throws Exception { ExchangeTokenServiceV2 ExchangeTokenServiceV2 = new ExchangeTokenServiceV2(jwtServiceMock, institutionServiceMock, groupServiceMock, productsConnector, properties, null, userApiConnector, new InstitutionResourceMapperImpl()); - Executable executable = () -> ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId, null); + Executable executable = () -> ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId); // then RuntimeException e = assertThrows(IllegalArgumentException.class, executable); assertEquals("Session token claims is required", e.getMessage()); @@ -753,7 +753,7 @@ void billingExchange_noInstitutionInfo() throws Exception { TestingAuthenticationToken authentication = new TestingAuthenticationToken(SelfCareUser.builder("ccbc5350-0ba7-47bc-9f61-8c65001939f9").build(), "password", authorities); TestSecurityContextHolder.setAuthentication(authentication); // when - Executable executable = () -> ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId, null); + Executable executable = () -> ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId); // then RuntimeException e = assertThrows(IllegalArgumentException.class, executable); assertEquals("Institution info is required", e.getMessage()); @@ -850,7 +850,7 @@ void billingExchange_nullGroupInfo(PrivateKey privateKey) throws Exception { when(userApiConnector.getProducts(institutionId, String.valueOf(userId))).thenReturn(userInstitution); ExchangeTokenServiceV2 ExchangeTokenServiceV2 = new ExchangeTokenServiceV2(jwtServiceMock, institutionServiceMock, groupServiceMock, productsConnectorMock, properties, UserV2Service, userApiConnector, new InstitutionResourceMapperImpl()); // when - final ExchangedToken exchangedToken = ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId, null); + final ExchangedToken exchangedToken = ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId); // then assertNotNull(exchangedToken.getIdentityToken()); Jws claimsJws = Jwts.parser() @@ -892,7 +892,6 @@ void billingExchange_nullGroupInfo(PrivateKey privateKey) throws Exception { @EnumSource(PrivateKey.class) void billingExchange_ok(PrivateKey privateKey) throws Exception { // given - String lang = "en"; String jti = "id"; String credential = "password"; Date iat = Date.from(Instant.now().minusSeconds(1)); @@ -976,7 +975,7 @@ void billingExchange_ok(PrivateKey privateKey) throws Exception { when(userApiConnector.getProducts(institutionId, String.valueOf(userId))).thenReturn(userInstitution); ExchangeTokenServiceV2 ExchangeTokenServiceV2 = new ExchangeTokenServiceV2(jwtServiceMock, institutionServiceMock, groupServiceMock, productsConnectorMock, properties, UserV2Service, userApiConnector, new InstitutionResourceMapperImpl()); // when - final ExchangedToken exchangedToken = ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId, lang); + final ExchangedToken exchangedToken = ExchangeTokenServiceV2.retrieveBillingExchangedToken(institutionId); // then assertNotNull(exchangedToken.getIdentityToken()); Jws claimsJws = Jwts.parser()