From 6d568d0b56330580435bc32ea34d1ef1a0e7facc Mon Sep 17 00:00:00 2001 From: gioelemella <128155546+gioelemella@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:09:25 +0100 Subject: [PATCH 01/24] fix: Activation date (#524) --- .../selfcare/pagopa/backoffice/service/StationService.java | 5 ++--- .../selfcare/pagopa/backoffice/service/WrapperService.java | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java index 04d06edba..3dc8030fa 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java @@ -363,8 +363,7 @@ private WrapperStations buildEnrichedWrapperStations(Stations stations) { if (optionalWrapperEntities.isPresent()) { WrapperEntityStations wrapperEntities = optionalWrapperEntities.get(); wrapperStation.setCreatedAt(wrapperEntities.getCreatedAt()); - WrapperEntityStation mostRecentEntity = getStationWrapperEntityOperationsSortedList(wrapperEntities).get(0); - wrapperStation.setActivationDate(mostRecentEntity.getEntity().getActivationDate()); + wrapperStation.setActivationDate(wrapperEntities.getEntities().get(0).getEntity().getActivationDate()); } return wrapperStation; }).toList(); @@ -389,7 +388,7 @@ private StationDetailResource buildActiveStationDetails( WrapperEntityStation mostRecentEntity = getStationWrapperEntityOperationsSortedList(wrapperEntities).get(0); stationDetailResource.setPendingUpdate(!WrapperStatus.APPROVED.equals(mostRecentEntity.getStatus())); - stationDetailResource.setActivationDate(mostRecentEntity.getEntity().getActivationDate()); + stationDetailResource.setActivationDate(wrapperEntities.getEntities().get(0).getEntity().getActivationDate()); } else { stationDetailResource.setPendingUpdate(false); } diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/WrapperService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/WrapperService.java index f783077bf..9e55c2672 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/WrapperService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/WrapperService.java @@ -308,6 +308,7 @@ public WrapperEntities update( Optional optionalWrapperEntities = this.repository.findById(stationCode); if (optionalWrapperEntities.isEmpty()) { + stationDetails.setActivationDate(Instant.now()); return createWrapperStation(stationDetails, WrapperStatus.valueOf(status)); } From c3164f90fa70d1c19b5ae35453a9f2a944aa5aa2 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 22 Nov 2024 14:10:18 +0000 Subject: [PATCH 02/24] Bump to version 2.32.3 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 3b3c39c15..5ad232a44 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.434.0 -appVersion: "2.32.2" +version: 0.435.0 +appVersion: "2.32.3" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 0decb22ef..cbc23538a 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.2" + tag: "2.32.3" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 373c1dd71..f76808d95 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.2" #improve + tag: "2.32.3" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 9ad13686b..8694f6c7a 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.2" #improve + tag: "2.32.3" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 04a03caf7..18b5db135 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.32.2" + "version": "2.32.3" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 4120a0c8b..d97b67880 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.32.2 + 2.32.3 SelfCare Backoffice Microservice to manage PagoPA Backoffice From d55badd8d8acb7fc8060825c90c644e2a81aa118 Mon Sep 17 00:00:00 2001 From: gioelemella <128155546+gioelemella@users.noreply.github.com> Date: Mon, 25 Nov 2024 12:25:42 +0100 Subject: [PATCH 03/24] fix: Cron logs metadata (#525) --- .../backoffice/scheduler/CiBrokerExtractionScheduler.java | 3 +-- .../backoffice/scheduler/IbanByBrokerExtractionScheduler.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CiBrokerExtractionScheduler.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CiBrokerExtractionScheduler.java index 81b58a9c4..baad28c8b 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CiBrokerExtractionScheduler.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CiBrokerExtractionScheduler.java @@ -117,9 +117,8 @@ private Set getAllBrokersOrThrowException() { updateMDCError(e, "Export CI Broker"); String errMsg = "[Export-CI] - An error occurred while extracting broker list, export aborted"; log.error(errMsg, e); - throw new AppException(AppError.BROKER_CI_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg); - } finally { MDC.clear(); + throw new AppException(AppError.BROKER_CI_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg); } } diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/IbanByBrokerExtractionScheduler.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/IbanByBrokerExtractionScheduler.java index e6306a299..f3e57d42d 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/IbanByBrokerExtractionScheduler.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/IbanByBrokerExtractionScheduler.java @@ -171,9 +171,8 @@ private Set getAllBrokersOrThrowException() { updateMDCError(e, "Export Broker IBAN"); String errMsg = "[Export IBANs] - An error occurred while extracting broker list, export aborted"; log.error(errMsg, e); - throw new AppException(AppError.BROKER_IBAN_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg); - } finally { MDC.clear(); + throw new AppException(AppError.BROKER_IBAN_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg); } } From 91ff4fe734fc9936d82bf520fdb886a02a0fc408 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 25 Nov 2024 11:26:29 +0000 Subject: [PATCH 04/24] Bump to version 2.32.4 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 5ad232a44..f60524aa9 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.435.0 -appVersion: "2.32.3" +version: 0.436.0 +appVersion: "2.32.4" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index cbc23538a..c0a2a9f41 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.3" + tag: "2.32.4" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index f76808d95..047f5e31d 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.3" #improve + tag: "2.32.4" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 8694f6c7a..f106fb2e7 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.3" #improve + tag: "2.32.4" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 18b5db135..df683ba15 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.32.3" + "version": "2.32.4" }, "servers": [ { diff --git a/pom.xml b/pom.xml index d97b67880..2f9b9526d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.32.3 + 2.32.4 SelfCare Backoffice Microservice to manage PagoPA Backoffice From bcc90a9fb546a11dfb29112a3018f395ecad71ff Mon Sep 17 00:00:00 2001 From: gioelemella <128155546+gioelemella@users.noreply.github.com> Date: Thu, 28 Nov 2024 09:42:45 +0100 Subject: [PATCH 05/24] [PPANTT-209] chore: Change ACA api key name (#526) --- .../pagopa/backoffice/model/institutions/Subscription.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java index bb5d5bcf7..8e1523640 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java @@ -27,7 +27,7 @@ public enum Subscription { BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false), BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false), PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false), - ACA("/products/aca", "ACA - paCreatePosition", "aca-", CI, "aca", true); + ACA("/products/aca", "ACA - Conferimento delle posizioni debitorie", "aca-", CI, "aca", true); private final String scope; private final String displayName; From c209c69b0c502f27ca043ad354958be193da21a3 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Thu, 28 Nov 2024 08:43:40 +0000 Subject: [PATCH 06/24] Bump to version 2.32.5 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f60524aa9..371060581 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.436.0 -appVersion: "2.32.4" +version: 0.437.0 +appVersion: "2.32.5" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index c0a2a9f41..84e15c7e3 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.4" + tag: "2.32.5" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 047f5e31d..baf86b85c 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.4" #improve + tag: "2.32.5" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index f106fb2e7..a7160d580 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.4" #improve + tag: "2.32.5" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index df683ba15..7694f92dd 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.32.4" + "version": "2.32.5" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 2f9b9526d..3fedabc3f 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.32.4 + 2.32.5 SelfCare Backoffice Microservice to manage PagoPA Backoffice From a8fc7619e5622d11e813dc240f431a2eb6ade3f5 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Mon, 2 Dec 2024 09:08:48 +0000 Subject: [PATCH 07/24] Bump to version 2.32.6 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 371060581..5814a5ae9 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.437.0 -appVersion: "2.32.5" +version: 0.438.0 +appVersion: "2.32.6" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 84e15c7e3..bf337593a 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.5" + tag: "2.32.6" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index baf86b85c..a630448df 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.5" #improve + tag: "2.32.6" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index a7160d580..ffd7157cb 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.5" #improve + tag: "2.32.6" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 7694f92dd..0af8dace5 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.32.5" + "version": "2.32.6" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 3fedabc3f..8bd3cfb45 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.32.5 + 2.32.6 SelfCare Backoffice Microservice to manage PagoPA Backoffice From 5c66d2c43e015a638ee365eb78f2b9a8227d60d0 Mon Sep 17 00:00:00 2001 From: Samuele Varianti <128470180+svariant@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:01:12 +0100 Subject: [PATCH 08/24] [PPANTT-215] feat: Send emails to CIs in UAT & PROD (#527) --- helm/values-dev.yaml | 1 + helm/values-prod.yaml | 1 + helm/values-uat.yaml | 1 + .../backoffice/client/AwsSesClient.java | 22 ++++++++----------- .../resources/application-local.properties | 1 + src/main/resources/application.properties | 2 +- .../backoffice/client/AwsSesClientTest.java | 16 +++++++------- src/test/resources/application.properties | 3 ++- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index bf337593a..cd1be30b5 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -82,6 +82,7 @@ microservice-chart: GEC_SERVICE_URL: https://api.dev.platform.pagopa.it FORWARDER_SERVICE_URL: https://api.dev.platform.pagopa.it TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it + ENABLE_SEND_EMAIL: false AZURE_RESOURCE_GROUP: pagopa-d-api-rg AZURE_SERVICE_NAME: pagopa-d-apim APPCONFIGURATION_ENDPOINT: 'https://pagopa-d-selfcare-appconfiguration.azconfig.io' diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index a630448df..1c4861dc3 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -85,6 +85,7 @@ microservice-chart: GEC_SERVICE_URL: https://api.platform.pagopa.it FORWARDER_SERVICE_URL: https://api.platform.pagopa.it TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it + ENABLE_SEND_EMAIL: true AZURE_RESOURCE_GROUP: pagopa-p-api-rg AZURE_SERVICE_NAME: pagopa-p-apim APPCONFIGURATION_ENDPOINT: 'https://pagopa-p-selfcare-appconfiguration.azconfig.io' diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index ffd7157cb..1323a6393 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -83,6 +83,7 @@ microservice-chart: GEC_SERVICE_URL: https://api.uat.platform.pagopa.it FORWARDER_SERVICE_URL: https://api.uat.platform.pagopa.it TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it + ENABLE_SEND_EMAIL: true AZURE_RESOURCE_GROUP: pagopa-u-api-rg AZURE_SERVICE_NAME: pagopa-u-apim APPCONFIGURATION_ENDPOINT: 'https://pagopa-u-selfcare-appconfiguration.azconfig.io' diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java index c45563bc1..099f288fc 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java @@ -32,7 +32,7 @@ public class AwsSesClient { private final ExternalApiClient externalApiClient; - private final String environment; + private final Boolean enableSendEmail; private final String testEmailAddress; @@ -44,17 +44,17 @@ public AwsSesClient( @Value("${aws.ses.user}") String from, SpringTemplateEngine templateEngine, ExternalApiClient externalApiClient, - @Value("${info.properties.environment}") String environment, @Value("${institution.subscription.test-email}") String testEmailAddress, - @Value("${institution.subscription.pagopa-operator-email}") String pagopaOperatorEmailAddress - ) { + @Value("${institution.subscription.pagopa-operator-email}") String pagopaOperatorEmailAddress, + @Value("${institution.subscription.enable-send-email}") Boolean enableSendEmail) { this.sesClient = sesClient; this.from = from; this.templateEngine = templateEngine; this.externalApiClient = externalApiClient; - this.environment = environment; + this.testEmailAddress = testEmailAddress; this.pagopaOperatorEmailAddress = pagopaOperatorEmailAddress; + this.enableSendEmail = enableSendEmail; } /** @@ -72,7 +72,7 @@ public AwsSesClient( */ public void sendEmail(EmailMessageDetail email, boolean sendEmailToPagopaOperator) { String taxCode = email.getInstitutionTaxCode(); - if (isNotProdWithoutTestEmail() || isProdWithNullDestinationInstitutionTaxCode(taxCode)) { + if (hasNotRequiredData(taxCode)) { log.warn("Skip send email process"); return; } @@ -132,7 +132,7 @@ private SendEmailRequest buildEmailRequest(EmailMessageDetail email, String[] to } private String[] getToAddressList(String taxCode, SelfcareProductUser destinationUserType) { - if (!this.environment.equals("PROD")) { + if (Boolean.FALSE.equals(this.enableSendEmail)) { return new String[]{testEmailAddress}; } Optional optionalInstitution = this.externalApiClient.getInstitutionsFiltered(taxCode) @@ -158,11 +158,7 @@ private String[] getToAddressList(String taxCode, SelfcareProductUser destinatio .toArray(new String[0]); } - private boolean isProdWithNullDestinationInstitutionTaxCode(String taxCode) { - return this.environment.equals("PROD") && taxCode == null; - } - - private boolean isNotProdWithoutTestEmail() { - return !this.environment.equals("PROD") && StringUtils.isBlank(testEmailAddress); + private boolean hasNotRequiredData(String taxCode) { + return Boolean.FALSE.equals(this.enableSendEmail) ? StringUtils.isBlank(testEmailAddress) : taxCode == null; } } diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 2d0fc1d18..6c2531440 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -58,4 +58,5 @@ authorization.taxonomy.subscriptionKey=${PAPGOPA_APIM_TAXONOMY_API_KEY_PAGOPA} # Other institution.subscription.test-email=${TEST_EMAIL} institution.subscription.pagopa-operator-email=${PAGOPA_OPERATOR_EMAIL} +institution.subscription.enable-send-email=${ENABLE_SEND_EMAIL} cron.job.schedule.enabled=true diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0119fe38f..7476c2f32 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -97,7 +97,7 @@ extraction.bundles.getAllBundles.pageLimit=${EXTRACTION_BUNDLES_GETALLBUNDLES_LI # Other institution.subscription.test-email=${TEST_EMAIL:} institution.subscription.pagopa-operator-email=${PAGOPA_OPERATOR_EMAIL:} - +institution.subscription.enable-send-email=${ENABLE_SEND_EMAIL:} # Client API retry retry.utils.maxAttempts=${CLIENT_RETRY_MAX_ATTEMPTS:3} retry.utils.maxDelay=${CLIENT_RETRY_MAX_DELAY:2000} diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java index f9fb067e1..f9f321b3a 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java @@ -48,7 +48,7 @@ class AwsSesClientTest { @Test void sendEmailPRODSuccess() { - ReflectionTestUtils.setField(sut, "environment", "PROD"); + ReflectionTestUtils.setField(sut, "enableSendEmail", true); Institutions institutions = buildInstitutions(); List institutionProductUsers = buildInstitutionProductUsers(); @@ -68,7 +68,7 @@ void sendEmailPRODSuccess() { @Test void sendEmailNotPRODSuccess() { - ReflectionTestUtils.setField(sut, "environment", "DEV"); + ReflectionTestUtils.setField(sut, "enableSendEmail", false); when(templateEngine.process(anyString(), any())).thenReturn("html template"); when(sesClient.sendEmail(any(SendEmailRequest.class))).thenReturn(SendEmailResponse.builder().build()); @@ -86,7 +86,7 @@ void sendEmailNotPRODSuccess() { @Test void sendEmailPRODFail() { - ReflectionTestUtils.setField(sut, "environment", "PROD"); + ReflectionTestUtils.setField(sut, "enableSendEmail", true); Institutions institutions = buildInstitutions(); List institutionProductUsers = buildInstitutionProductUsers(); @@ -106,7 +106,7 @@ void sendEmailPRODFail() { @Test void sendEmailPRODNoInstitutionTaxCodeSkipped() { - ReflectionTestUtils.setField(sut, "environment", "PROD"); + ReflectionTestUtils.setField(sut, "enableSendEmail", true); ReflectionTestUtils.setField(sut, "testEmailAddress", "test@mail.it"); assertDoesNotThrow(() -> sut.sendEmail(buildEmailMessageDetail(null))); @@ -124,7 +124,7 @@ void sendEmailPRODNoInstitutionTaxCodeSkipped() { @Test void sendEmailNoInstitutionFoundSkipped() { - ReflectionTestUtils.setField(sut, "environment", "PROD"); + ReflectionTestUtils.setField(sut, "enableSendEmail", true); when(externalApiClient.getInstitutionsFiltered(INSTITUTION_TAX_CODE)) .thenReturn(Institutions.builder().institutions(Collections.emptyList()).build()); @@ -143,7 +143,7 @@ void sendEmailNoInstitutionFoundSkipped() { @Test void sendEmailNoDestinationSkipped() { - ReflectionTestUtils.setField(sut, "environment", "PROD"); + ReflectionTestUtils.setField(sut, "enableSendEmail", true); Institutions institutions = buildInstitutions(); @@ -163,7 +163,7 @@ void sendEmailNoDestinationSkipped() { @Test void sendEmailNotPRODAndNoTestEmailSkipped() { - ReflectionTestUtils.setField(sut, "environment", "DEV"); + ReflectionTestUtils.setField(sut, "enableSendEmail", false); ReflectionTestUtils.setField(sut, "testEmailAddress", null); assertDoesNotThrow(() -> sut.sendEmail(buildEmailMessageDetail(INSTITUTION_TAX_CODE))); @@ -181,7 +181,7 @@ void sendEmailNotPRODAndNoTestEmailSkipped() { @Test void sendEmailPRODSWithPagopaOperatorSuccess() { - ReflectionTestUtils.setField(sut, "environment", "PROD"); + ReflectionTestUtils.setField(sut, "enableSendEmail", true); Institutions institutions = buildInstitutions(); List institutionProductUsers = buildInstitutionProductUsers(); diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 4e28c3e82..10806fe59 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -96,5 +96,6 @@ extraction.ibans.clean.olderThanDays=7 extraction.ibans.persistIbanBatchSize=8000 extraction.bundles.getAllBundles.pageLimit=200 # Other -institution.subscription.test-email=tes@mail.it +institution.subscription.test-email=test@mail.it institution.subscription.pagopa-operator-email=operator@mail.it +institution.subscription.enable-send-email=false \ No newline at end of file From a591eb4eab137009e29dddf76a65e5e87c3b790d Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 3 Dec 2024 10:02:16 +0000 Subject: [PATCH 09/24] Bump to version 2.33.0 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 5814a5ae9..d9d3d938e 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.438.0 -appVersion: "2.32.6" +version: 0.439.0 +appVersion: "2.33.0" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index cd1be30b5..5567df9e1 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.6" + tag: "2.33.0" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 1c4861dc3..dd53fb95c 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.6" #improve + tag: "2.33.0" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 1323a6393..73d150d73 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.32.6" #improve + tag: "2.33.0" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 0af8dace5..14f3755d0 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.32.6" + "version": "2.33.0" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 8bd3cfb45..00031b6f5 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.32.6 + 2.33.0 SelfCare Backoffice Microservice to manage PagoPA Backoffice From 8fa059df4b3ec0220bfbb305795ade66fe8b4737 Mon Sep 17 00:00:00 2001 From: gioelemella <128155546+gioelemella@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:41:54 +0100 Subject: [PATCH 10/24] [PPANTT-218] fix: Deploy gha (#528) --- .../workflows/deploy_with_github_runner.yml | 43 +------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/.github/workflows/deploy_with_github_runner.yml b/.github/workflows/deploy_with_github_runner.yml index 0743e57d3..d7bf4fa40 100644 --- a/.github/workflows/deploy_with_github_runner.yml +++ b/.github/workflows/deploy_with_github_runner.yml @@ -44,30 +44,8 @@ permissions: contents: read jobs: - create_runner: - name: Create Runner - runs-on: ubuntu-22.04 - environment: - name: ${{ inputs.environment }} - outputs: - runner_name: ${{ steps.create_github_runner.outputs.runner_name }} - steps: - - name: Create GitHub Runner - id: create_github_runner - # from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-create-action - uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-create-action@main - with: - client_id: ${{ secrets.CD_CLIENT_ID }} - tenant_id: ${{ secrets.TENANT_ID }} - subscription_id: ${{ secrets.SUBSCRIPTION_ID }} - container_app_environment_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_NAME }} - resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} # RG of the runner - pat_token: ${{ secrets.BOT_TOKEN_GITHUB }} - self_hosted_runner_image_tag: "latest" - deploy: - needs: [ create_runner ] - runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ] + runs-on: [ self-hosted-job, "${{ inputs.environment }}" ] name: Deploy on AKS environment: ${{ inputs.environment }} steps: @@ -93,25 +71,6 @@ jobs: run: | helm uninstall ${{ env.APP_NAME }}${{inputs.suffix_name}} -n ${{ vars.NAMESPACE }} - cleanup_runner: - name: Cleanup Runner - needs: [ create_runner, deploy ] - if: ${{ success() || failure() }} - runs-on: ubuntu-22.04 - environment: ${{ inputs.environment }} - steps: - - name: Cleanup GitHub Runner - id: cleanup_github_runner - # from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-cleanup-action - uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-cleanup-action@main - with: - client_id: ${{ secrets.CD_CLIENT_ID }} - tenant_id: ${{ secrets.TENANT_ID }} - subscription_id: ${{ secrets.SUBSCRIPTION_ID }} - resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} - runner_name: ${{ needs.create_runner.outputs.runner_name }} - pat_token: ${{ secrets.BOT_TOKEN_GITHUB }} - update_openapi: needs: [ deploy ] runs-on: ubuntu-latest From efec42edbf9e5ec0b43d3a229ad1ddc78801fc0f Mon Sep 17 00:00:00 2001 From: gioelemella <128155546+gioelemella@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:52:09 +0100 Subject: [PATCH 11/24] fix: helm (#529) --- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 5567df9e1..20eabf218 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -82,7 +82,7 @@ microservice-chart: GEC_SERVICE_URL: https://api.dev.platform.pagopa.it FORWARDER_SERVICE_URL: https://api.dev.platform.pagopa.it TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it - ENABLE_SEND_EMAIL: false + ENABLE_SEND_EMAIL: 'false' AZURE_RESOURCE_GROUP: pagopa-d-api-rg AZURE_SERVICE_NAME: pagopa-d-apim APPCONFIGURATION_ENDPOINT: 'https://pagopa-d-selfcare-appconfiguration.azconfig.io' diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index dd53fb95c..0aa5130f8 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -85,7 +85,7 @@ microservice-chart: GEC_SERVICE_URL: https://api.platform.pagopa.it FORWARDER_SERVICE_URL: https://api.platform.pagopa.it TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it - ENABLE_SEND_EMAIL: true + ENABLE_SEND_EMAIL: 'true' AZURE_RESOURCE_GROUP: pagopa-p-api-rg AZURE_SERVICE_NAME: pagopa-p-apim APPCONFIGURATION_ENDPOINT: 'https://pagopa-p-selfcare-appconfiguration.azconfig.io' diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 73d150d73..e9a86c912 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -83,7 +83,7 @@ microservice-chart: GEC_SERVICE_URL: https://api.uat.platform.pagopa.it FORWARDER_SERVICE_URL: https://api.uat.platform.pagopa.it TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it - ENABLE_SEND_EMAIL: true + ENABLE_SEND_EMAIL: 'true' AZURE_RESOURCE_GROUP: pagopa-u-api-rg AZURE_SERVICE_NAME: pagopa-u-apim APPCONFIGURATION_ENDPOINT: 'https://pagopa-u-selfcare-appconfiguration.azconfig.io' From d72a8fc58a647eb14852aa11d94491db140a05fd Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 3 Dec 2024 14:53:04 +0000 Subject: [PATCH 12/24] Bump to version 2.33.1 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index d9d3d938e..f104a08ae 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.439.0 -appVersion: "2.33.0" +version: 0.440.0 +appVersion: "2.33.1" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 20eabf218..f4d0b7896 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.33.0" + tag: "2.33.1" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 0aa5130f8..7cbf67fcf 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.33.0" #improve + tag: "2.33.1" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index e9a86c912..ff92f81fc 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.33.0" #improve + tag: "2.33.1" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 14f3755d0..a1aec98a8 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.33.0" + "version": "2.33.1" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 00031b6f5..0eec7fd5d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.33.0 + 2.33.1 SelfCare Backoffice Microservice to manage PagoPA Backoffice From 6f5c6c513891abe9ab10f07f9a81e7904dbb286c Mon Sep 17 00:00:00 2001 From: gioelemella <128155546+gioelemella@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:50:32 +0100 Subject: [PATCH 13/24] [PPANTT-215] feat: Add environment info in mail content (#530) --- .../backoffice/client/AwsSesClient.java | 12 ++++++-- ...issionBundleMailNotificationScheduler.java | 15 +++++++++- .../service/AsyncNotificationService.java | 22 +++++++++++---- .../backoffice/service/ChannelService.java | 17 +++++++++-- .../service/CommissionBundleService.java | 28 +++++++++---------- .../backoffice/service/StationService.java | 17 +++++++++-- .../backoffice/util/MailTextConstants.java | 12 ++++---- .../acceptBundleSubscriptionOfferEmail.html | 7 +++-- .../acceptBundleSubscriptionRequestEmail.html | 6 +++- .../channelReviewRequestedEmail.html | 2 +- .../createBundleSubscriptionOfferEmail.html | 9 ++++-- .../createBundleSubscriptionRequestEmail.html | 7 +++-- .../templates/deleteBundleEmail.html | 7 +++-- .../templates/expiringBundleEmail.html | 7 +++-- .../stationReviewRequestedEmail.html | 2 +- .../backoffice/client/AwsSesClientTest.java | 8 ++++++ 16 files changed, 131 insertions(+), 47 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java index 099f288fc..4e07e5f9c 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClient.java @@ -32,6 +32,8 @@ public class AwsSesClient { private final ExternalApiClient externalApiClient; + private final String environment; + private final Boolean enableSendEmail; private final String testEmailAddress; @@ -44,6 +46,7 @@ public AwsSesClient( @Value("${aws.ses.user}") String from, SpringTemplateEngine templateEngine, ExternalApiClient externalApiClient, + @Value("${info.properties.environment}") String environment, @Value("${institution.subscription.test-email}") String testEmailAddress, @Value("${institution.subscription.pagopa-operator-email}") String pagopaOperatorEmailAddress, @Value("${institution.subscription.enable-send-email}") Boolean enableSendEmail) { @@ -51,7 +54,7 @@ public AwsSesClient( this.from = from; this.templateEngine = templateEngine; this.externalApiClient = externalApiClient; - + this.environment = environment; this.testEmailAddress = testEmailAddress; this.pagopaOperatorEmailAddress = pagopaOperatorEmailAddress; this.enableSendEmail = enableSendEmail; @@ -111,6 +114,7 @@ public void sendEmail(EmailMessageDetail email) { private SendEmailRequest buildEmailRequest(EmailMessageDetail email, String[] toAddressList, boolean sendEmailToPagopaOperator) { String html = this.templateEngine.process(email.getHtmlBodyFileName(), email.getHtmlBodyContext()); + String subject = isNotProd() ? String.format("[%s] %s", this.environment, email.getSubject()) : email.getSubject(); return SendEmailRequest.builder() .source(this.from) @@ -122,7 +126,7 @@ private SendEmailRequest buildEmailRequest(EmailMessageDetail email, String[] to } }) .message(m -> m - .subject(c -> c.data(email.getSubject())) + .subject(c -> c.data(subject)) .body(b -> b .html(c -> c.data(html).charset(StandardCharsets.UTF_8.name())) .text(c -> c.data(email.getTextBody())) @@ -158,6 +162,10 @@ private String[] getToAddressList(String taxCode, SelfcareProductUser destinatio .toArray(new String[0]); } + private boolean isNotProd() { + return !this.environment.equals("PROD"); + } + private boolean hasNotRequiredData(String taxCode) { return Boolean.FALSE.equals(this.enableSendEmail) ? StringUtils.isBlank(testEmailAddress) : taxCode == null; } diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CommissionBundleMailNotificationScheduler.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CommissionBundleMailNotificationScheduler.java index 51a4d39e3..b276a69e4 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CommissionBundleMailNotificationScheduler.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/scheduler/CommissionBundleMailNotificationScheduler.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -35,6 +36,8 @@ @Slf4j public class CommissionBundleMailNotificationScheduler { + private final String environment; + private static final String VALID_FROM_DATE_FORMAT = "yyyy-MM-dd"; private final BundleAllPages bundleAllPages; @@ -44,10 +47,12 @@ public class CommissionBundleMailNotificationScheduler { private final AwsSesClient awsSesClient; public CommissionBundleMailNotificationScheduler( + @Value("${info.properties.environment}") String environment, BundleAllPages bundleAllPages, ApiConfigClient apiConfigClient, AwsSesClient awsSesClient ) { + this.environment = environment; this.bundleAllPages = bundleAllPages; this.apiConfigClient = apiConfigClient; this.awsSesClient = awsSesClient; @@ -111,7 +116,7 @@ private void sendMail(String expireAt, Bundle bundle, String notifyTaxCode, Stri EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(notifyTaxCode) .subject(BUNDLE_EXPIRE_SUBJECT) - .textBody(String.format(BUNDLE_EXPIRE_BODY, bundle.getName(), bundle.getPspBusinessName(), pspTaxCode, expireAt)) + .textBody(String.format(BUNDLE_EXPIRE_BODY, bundle.getName(), bundle.getPspBusinessName(), pspTaxCode, expireAt, getEnvParam())) .htmlBodyFileName("expiringBundleEmail.html") .htmlBodyContext(buildEmailHtmlBodyContext(bundle.getName(), bundle.getPspBusinessName(), pspTaxCode, expireAt)) .destinationUserType(SelfcareProductUser.ADMIN) @@ -144,8 +149,16 @@ private Context buildEmailHtmlBodyContext( properties.put("pspName", pspBusinessName); properties.put("pspTaxCode", pspTaxCode); properties.put("expireAt", expireAt); + properties.put("environment", getEnvParam()); context.setVariables(properties); return context; } + + private String getEnvParam() { + if (this.environment.equals("PROD")) { + return ""; + } + return String.format(".%s", this.environment.toLowerCase()); + } } diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/AsyncNotificationService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/AsyncNotificationService.java index 5009c2b51..f8129cf25 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/AsyncNotificationService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/AsyncNotificationService.java @@ -3,6 +3,7 @@ import it.pagopa.selfcare.pagopa.backoffice.client.AwsSesClient; import it.pagopa.selfcare.pagopa.backoffice.model.email.EmailMessageDetail; import it.pagopa.selfcare.pagopa.backoffice.model.institutions.SelfcareProductUser; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.thymeleaf.context.Context; @@ -17,9 +18,14 @@ @Service public class AsyncNotificationService { + private final String environment; private final AwsSesClient awsSesClient; - public AsyncNotificationService(AwsSesClient awsSesClient) { + public AsyncNotificationService( + @Value("${info.properties.environment}") String environment, + AwsSesClient awsSesClient + ) { + this.environment = environment; this.awsSesClient = awsSesClient; } @@ -43,7 +49,7 @@ public void notifyDeletePSPBundleAsync( EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(ciTaxCode) .subject(BUNDLE_DELETE_SUBJECT) - .textBody(String.format(BUNDLE_DELETE_BODY, pspName, bundleName)) + .textBody(String.format(BUNDLE_DELETE_BODY, pspName, bundleName, getEnvParam())) .htmlBodyFileName("deleteBundleEmail.html") .htmlBodyContext(bodyContext) .destinationUserType(SelfcareProductUser.ADMIN) @@ -60,13 +66,17 @@ private Context buildEmailHtmlBodyContext(String bundleName, String pspName) { // Properties to show up in Template after stored in Context Map properties = new HashMap<>(); properties.put("bundleName", bundleName); - - if (pspName != null) { - properties.put("pspName", pspName); - } + properties.put("environment", getEnvParam()); + properties.put("pspName", pspName); context.setVariables(properties); return context; + } + private String getEnvParam() { + if (this.environment.equals("PROD")) { + return ""; + } + return String.format(".%s", this.environment.toLowerCase()); } } diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ChannelService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ChannelService.java index 2060470a1..840524b30 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ChannelService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ChannelService.java @@ -27,6 +27,7 @@ import it.pagopa.selfcare.pagopa.backoffice.model.institutions.SelfcareProductUser; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Service; @@ -49,7 +50,9 @@ public class ChannelService { private static final String UPDATE_CHANEL_SUBJECT = "Modifica canale attiva"; private static final String UPDATE_CHANEL_EMAIL_BODY = "Ciao, %n%n%n pagoPA ha revisionato e validato il canale %s che hai modificato. Da questo momento la modifica effettuata risulta attiva.%n%n%nA presto,%n%n Back-office pagoPA"; private static final String CHANNEL_REVIEW_SUBJECT = "Modifiche richieste"; - private static final String CHANNEL_REVIEW_EMAIL_BODY = "Ciao, %n%n%n pagoPA ha richiesto delle modifiche al canale %s che hai creato.%n Puoi vedere le modifiche qui sotto oppure nel dettaglio del canale (https://selfcare.platform.pagopa.it/ui/channels/%s).%n Modifiche richieste %n '%s' %n%n%nA presto,%n%n Pagamenti pagoPA"; + private static final String CHANNEL_REVIEW_EMAIL_BODY = "Ciao, %n%n%n pagoPA ha richiesto delle modifiche al canale %s che hai creato.%n Puoi vedere le modifiche qui sotto oppure nel dettaglio del canale (https://selfcare%s.platform.pagopa.it/ui/channels/%s).%n Modifiche richieste %n '%s' %n%n%nA presto,%n%n Pagamenti pagoPA"; + + private final String environment; private final ApiConfigClient apiConfigClient; @@ -61,11 +64,13 @@ public class ChannelService { @Autowired public ChannelService( + @Value("${info.properties.environment}") String environment, ApiConfigClient apiConfigClient, WrapperService wrapperService, JiraServiceManagerClient jsmClient, AwsSesClient awsSesClient ) { + this.environment = environment; this.apiConfigClient = apiConfigClient; this.wrapperService = wrapperService; this.jsmClient = jsmClient; @@ -286,7 +291,7 @@ public ChannelDetailsResource updateWrapperChannelWithOperatorReview( EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(brokerPspCode) .subject(CHANNEL_REVIEW_SUBJECT) - .textBody(String.format(CHANNEL_REVIEW_EMAIL_BODY, channelCode, channelCode, note)) + .textBody(String.format(CHANNEL_REVIEW_EMAIL_BODY, channelCode, getEnvParam(), channelCode, note)) .htmlBodyFileName("channelReviewRequestedEmail.html") .htmlBodyContext(buildChannelHtmlEmailBodyContext(channelCode, note)) .destinationUserType(SelfcareProductUser.OPERATOR) @@ -303,6 +308,7 @@ private Context buildChannelHtmlEmailBodyContext(String channelCode, String note // Properties to show up in Template after stored in Context Map properties = new HashMap<>(); properties.put("channelCode", channelCode); + properties.put("environment", getEnvParam()); if (note != null) { properties.put("reviewNote", note); } @@ -311,6 +317,13 @@ private Context buildChannelHtmlEmailBodyContext(String channelCode, String note return context; } + private String getEnvParam() { + if (this.environment.equals("PROD")) { + return ""; + } + return String.format(".%s", this.environment.toLowerCase()); + } + private WrapperChannels buildEnrichedWrapperChannels(Channels channels) { WrapperChannels response; List wrapperChannels = channels.getChannelList().parallelStream() diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/CommissionBundleService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/CommissionBundleService.java index 8b4452537..da5c70960 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/CommissionBundleService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/CommissionBundleService.java @@ -39,8 +39,7 @@ public class CommissionBundleService { public static final String SUBJECT_NEW_BUNDLE_GEC = "Creazione Nuovo Pacchetto GEC %s"; public static final String DETAIL_NEW_BUNDLE_GEC = "E' stato creato un nuovo pacchetto GEC '%s' da parte di %s (CF: %s) che si attiverà a partire dal %s. Si prega di prenderne visione per verificare se il PSP ha configurato correttamente il pacchetto. \nLink: https://selfcare%s.platform.pagopa.it/ui/comm-bundles/detail/%s"; - @Value("${info.properties.environment}") - private String environment; + private final String environment; private final GecClient gecClient; @@ -64,6 +63,7 @@ public class CommissionBundleService { @Autowired public CommissionBundleService( + @Value("${info.properties.environment}") String environment, GecClient gecClient, ModelMapper modelMapper, TaxonomyService taxonomyService, @@ -75,6 +75,7 @@ public CommissionBundleService( ExportService exportService, BundleAllPages bundleAllPages ) { + this.environment = environment; this.gecClient = gecClient; this.modelMapper = modelMapper; this.taxonomyService = taxonomyService; @@ -206,7 +207,7 @@ public void acceptPublicBundleSubscriptionsByPSP( EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(ciTaxCode) .subject(BUNDLE_ACCEPT_REQUEST_SUBJECT) - .textBody(String.format(BUNDLE_ACCEPT_REQUEST_BODY, bundleName)) + .textBody(String.format(BUNDLE_ACCEPT_REQUEST_BODY, bundleName, getEnvParam())) .htmlBodyFileName("acceptBundleSubscriptionRequestEmail.html") .htmlBodyContext(buildEmailHtmlBodyContext(bundleName)) .destinationUserType(SelfcareProductUser.ADMIN) @@ -494,7 +495,7 @@ public void createCIBundleRequest(String ciTaxCode, PublicBundleRequest bundleRe EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(bundleRequest.getIdPsp()) .subject(BUNDLE_CREATE_REQUEST_SUBJECT) - .textBody(String.format(BUNDLE_CREATE_REQUEST_BODY, bundleName)) + .textBody(String.format(BUNDLE_CREATE_REQUEST_BODY, bundleName, getEnvParam())) .htmlBodyFileName("createBundleSubscriptionRequestEmail.html") .htmlBodyContext(buildEmailHtmlBodyContext(bundleName)) .destinationUserType(SelfcareProductUser.ADMIN) @@ -558,7 +559,7 @@ public void createCIBundleOffers( EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(ciTaxCode) .subject(BUNDLE_CREATE_OFFER_SUBJECT) - .textBody(String.format(BUNDLE_CREATE_OFFER_BODY, bundleName)) + .textBody(String.format(BUNDLE_CREATE_OFFER_BODY, bundleName, getEnvParam())) .htmlBodyFileName("createBundleSubscriptionOfferEmail.html") .htmlBodyContext(bodyContext) .destinationUserType(SelfcareProductUser.ADMIN) @@ -591,7 +592,7 @@ public CIBundleId acceptPrivateBundleOffer( EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(pspTaxCode) .subject(BUNDLE_ACCEPT_OFFER_SUBJECT) - .textBody(String.format(BUNDLE_ACCEPT_OFFER_BODY, bundleName)) + .textBody(String.format(BUNDLE_ACCEPT_OFFER_BODY, bundleName, getEnvParam())) .htmlBodyFileName("acceptBundleSubscriptionOfferEmail.html") .htmlBodyContext(buildEmailHtmlBodyContext(bundleName)) .destinationUserType(SelfcareProductUser.ADMIN) @@ -641,25 +642,24 @@ public byte[] exportPSPBundleList(String pspTaxCode, List bundleType return this.exportService.exportPSPBundlesToCsv(pspCode, bundleTypeList); } - private Context buildEmailHtmlBodyContext(String bundleName, String pspName) { + private Context buildEmailHtmlBodyContext(String bundleName) { // Thymeleaf Context Context context = new Context(); // Properties to show up in Template after stored in Context Map properties = new HashMap<>(); properties.put("bundleName", bundleName); - - if (pspName != null) { - properties.put("pspName", pspName); - } + properties.put("environment", getEnvParam()); context.setVariables(properties); return context; - } - private Context buildEmailHtmlBodyContext(String bundleName) { - return buildEmailHtmlBodyContext(bundleName, null); + private String getEnvParam() { + if (this.environment.equals("PROD")) { + return ""; + } + return String.format(".%s", this.environment.toLowerCase()); } private List buildCISubscriptionInfoList( diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java index 3dc8030fa..153ca858f 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/StationService.java @@ -24,6 +24,7 @@ import it.pagopa.selfcare.pagopa.backoffice.model.stations.*; import org.mapstruct.factory.Mappers; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.thymeleaf.context.Context; @@ -45,7 +46,9 @@ public class StationService { private static final String UPDATE_STATION_SUBJECT = "Modifica stazione attiva"; private static final String UPDATE_STATION_EMAIL_BODY = "Ciao, %n%n%n pagoPA ha revisionato e validato la stazione %s che hai modificato. Da questo momento la modifica effettuata risulta attiva.%n%n%nA presto,%n%n Pagamenti pagoPA"; private static final String STATION_REVIEW_SUBJECT = "Modifiche richieste"; - private static final String STATION_REVIEW_EMAIL_BODY = "Ciao, %n%n%n pagoPA ha richiesto delle modifiche alla stazione %s che hai creato.%n Puoi vedere le modifiche qui sotto oppure nel dettaglio della stazione (https://selfcare.platform.pagopa.it/ui/stations/%s).%n Modifiche richieste %n '%s' %n%n%nA presto,%n%n Pagamenti pagoPA"; + private static final String STATION_REVIEW_EMAIL_BODY = "Ciao, %n%n%n pagoPA ha richiesto delle modifiche alla stazione %s che hai creato.%n Puoi vedere le modifiche qui sotto oppure nel dettaglio della stazione (https://selfcare%s.platform.pagopa.it/ui/stations/%s).%n Modifiche richieste %n '%s' %n%n%nA presto,%n%n Pagamenti pagoPA"; + + private final String environment; private final CreditorInstitutionMapper creditorInstitutionMapper = Mappers.getMapper(CreditorInstitutionMapper.class); @@ -63,12 +66,14 @@ public class StationService { @Autowired public StationService( + @Value("${info.properties.environment}") String environment, ApiConfigClient apiConfigClient, WrapperService wrapperService, AwsSesClient awsSesClient, ForwarderClient forwarderClient, JiraServiceManagerClient jiraServiceManagerClient ) { + this.environment = environment; this.apiConfigClient = apiConfigClient; this.wrapperService = wrapperService; this.awsSesClient = awsSesClient; @@ -238,7 +243,7 @@ public StationDetailResource updateWrapperStationWithOperatorReview( EmailMessageDetail messageDetail = EmailMessageDetail.builder() .institutionTaxCode(ciTaxCode) .subject(STATION_REVIEW_SUBJECT) - .textBody(String.format(STATION_REVIEW_EMAIL_BODY, stationCode, stationCode, note)) + .textBody(String.format(STATION_REVIEW_EMAIL_BODY, stationCode, getEnvParam(), stationCode, note)) .htmlBodyFileName("stationReviewRequestedEmail.html") .htmlBodyContext(buildStationHtmlEmailBodyContext(stationCode, note)) .destinationUserType(SelfcareProductUser.OPERATOR) @@ -323,6 +328,7 @@ private Context buildStationHtmlEmailBodyContext(String stationCode, String note // Properties to show up in Template after stored in Context Map properties = new HashMap<>(); properties.put("stationCode", stationCode); + properties.put("environment", getEnvParam()); if (note != null) { properties.put("reviewNote", note); } @@ -331,6 +337,13 @@ private Context buildStationHtmlEmailBodyContext(String stationCode, String note return context; } + private String getEnvParam() { + if (this.environment.equals("PROD")) { + return ""; + } + return String.format(".%s", this.environment.toLowerCase()); + } + /** * @deprecated this API invoke the old station code generation logic that can cause collision on wrapper data for PT */ diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/util/MailTextConstants.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/util/MailTextConstants.java index 717688fa4..3a6d527d5 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/util/MailTextConstants.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/util/MailTextConstants.java @@ -4,20 +4,20 @@ public class MailTextConstants { // PSP notification public static final String BUNDLE_ACCEPT_OFFER_SUBJECT = "Offerta di adesione confermata"; - public static final String BUNDLE_ACCEPT_OFFER_BODY = "Ciao %n%n%n la tua offerta di adesione al pacchetto %s è stata accettata.%n%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; + public static final String BUNDLE_ACCEPT_OFFER_BODY = "Ciao %n%n%n la tua offerta di adesione al pacchetto %s è stata accettata.%n%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare%s.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; public static final String BUNDLE_REJECT_OFFER_SUBJECT = "Offerta di adesione rifiutata"; public static final String BUNDLE_REJECT_OFFER_BODY = "Ciao %n%n%n la tua offerta di adesione al pacchetto %s è stata rifiutata.%n%n%n Se riscontri dei problemi, puoi richiedere maggiori dettagli utilizzando il canale di assistenza ( https://selfcare.pagopa.it/assistenza ).%n%n%nA presto,%n%nPagamenti pagoPa"; public static final String BUNDLE_CREATE_REQUEST_SUBJECT = "Nuova richiesta di attivazione pacchetto commissionale"; - public static final String BUNDLE_CREATE_REQUEST_BODY = "Ciao, %n%n%n ci sono nuove richieste di attivazione per il pacchetto commissionale %s.%n%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; + public static final String BUNDLE_CREATE_REQUEST_BODY = "Ciao, %n%n%n ci sono nuove richieste di attivazione per il pacchetto commissionale %s.%n%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare%s.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; // CI notification public static final String BUNDLE_DELETE_SUBJECT = "Eliminazione pacchetto commissionale"; - public static final String BUNDLE_DELETE_BODY = "Ciao, %n%n%n %s ha richiesto l'eliminazione del pacchetto %s che non sarà più visibile a partire dalla mezzanotte di domani. Se riscontri dei problemi, contatta l'ente.%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; + public static final String BUNDLE_DELETE_BODY = "Ciao, %n%n%n %s ha richiesto l'eliminazione del pacchetto %s che non sarà più visibile a partire dalla mezzanotte di domani. Se riscontri dei problemi, contatta l'ente.%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare%s.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; public static final String BUNDLE_CREATE_OFFER_SUBJECT = "Nuova offerta di attivazione pacchetto commissionale"; - public static final String BUNDLE_CREATE_OFFER_BODY = "Ciao, %n%n%n c'è una nuova offerta di attivazione per il pacchetto commissionale %s.%n%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; + public static final String BUNDLE_CREATE_OFFER_BODY = "Ciao, %n%n%n c'è una nuova offerta di attivazione per il pacchetto commissionale %s.%n%n%n Puoi gestire i tuoi pacchetti qui ( https://selfcare%s.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; public static final String BUNDLE_ACCEPT_REQUEST_SUBJECT = "Richiesta di adesione confermata"; - public static final String BUNDLE_ACCEPT_REQUEST_BODY = "Ciao %n%n%n la tua richiesta di adesione al pacchetto %s è stata accettata.%n%n%n Puoi vedere e gestire il pacchetto da qui ( https://selfcare.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; + public static final String BUNDLE_ACCEPT_REQUEST_BODY = "Ciao %n%n%n la tua richiesta di adesione al pacchetto %s è stata accettata.%n%n%n Puoi vedere e gestire il pacchetto da qui ( https://selfcare%s.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; public static final String BUNDLE_REJECT_REQUEST_SUBJECT = "Richiesta di adesione rifiutata"; public static final String BUNDLE_REJECT_REQUEST_BODY = "Ciao %n%n%n la tua richiesta di adesione al pacchetto %s è stata rifiutata.%n%n%n Se riscontri dei problemi, puoi richiedere maggiori dettagli utilizzando il canale di assistenza ( https://selfcare.pagopa.it/assistenza ).%n%n%nA presto,%n%nPagamenti pagoPa"; public static final String BUNDLE_DELETE_SUBSCRIPTION_SUBJECT = "Conferma rimozione da pacchetto"; @@ -27,7 +27,7 @@ public class MailTextConstants { // cron-job notification public static final String BUNDLE_EXPIRE_SUBJECT = "Pacchetto commissionale in scadenza"; - public static final String BUNDLE_EXPIRE_BODY = "Ciao, %n%n%n il pacchetto %s del PSP %s (codice fiscale: %s) scadrà in data %s.%n%n%n Puoi vedere i tuoi pacchetti qui ( https://selfcare.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; + public static final String BUNDLE_EXPIRE_BODY = "Ciao, %n%n%n il pacchetto %s del PSP %s (codice fiscale: %s) scadrà in data %s.%n%n%n Puoi vedere i tuoi pacchetti qui ( https://selfcare%s.platform.pagopa.it/ui/comm-bundles ).%n%n%nA presto,%n%nPagamenti pagoPa"; private MailTextConstants() {} diff --git a/src/main/resources/templates/acceptBundleSubscriptionOfferEmail.html b/src/main/resources/templates/acceptBundleSubscriptionOfferEmail.html index 3f7cf2941..f1810f5a5 100644 --- a/src/main/resources/templates/acceptBundleSubscriptionOfferEmail.html +++ b/src/main/resources/templates/acceptBundleSubscriptionOfferEmail.html @@ -19,8 +19,11 @@

La tua offerta di adesione al pacchetto è stata confermata


Puoi gestire i tuoi pacchetti qui https://selfcare.platform.pagopa.it/ui/comm-bundles. -

+ href="@{https://selfcare{env}.platform.pagopa.it/ui/comm-bundles(env=${environment})}"> + https://selfcare.platform.pagopa.it/ui/comm-bundles + https://selfcare.uat.platform.pagopa.it/ui/comm-bundles + https://selfcare.dev.platform.pagopa.it/ui/comm-bundles +.

A presto, diff --git a/src/main/resources/templates/acceptBundleSubscriptionRequestEmail.html b/src/main/resources/templates/acceptBundleSubscriptionRequestEmail.html index e6be4dcdc..37a30be2d 100644 --- a/src/main/resources/templates/acceptBundleSubscriptionRequestEmail.html +++ b/src/main/resources/templates/acceptBundleSubscriptionRequestEmail.html @@ -19,7 +19,11 @@

La tua richiesta di adesione al pacchetto è stata confermata


Puoi vedere e gestire il tuo pacchetto da qui https://selfcare.platform.pagopa.it/ui/comm-bundles. + href="@{https://selfcare{env}.platform.pagopa.it/ui/comm-bundles(env=${environment})}"> + https://selfcare.platform.pagopa.it/ui/comm-bundles + https://selfcare.uat.platform.pagopa.it/ui/comm-bundles + https://selfcare.dev.platform.pagopa.it/ui/comm-bundles +.


diff --git a/src/main/resources/templates/channelReviewRequestedEmail.html b/src/main/resources/templates/channelReviewRequestedEmail.html index dc8158b20..9cf002b4f 100644 --- a/src/main/resources/templates/channelReviewRequestedEmail.html +++ b/src/main/resources/templates/channelReviewRequestedEmail.html @@ -19,7 +19,7 @@

Modifiche richieste

Puoi vedere le modifiche qui sotto oppure nel dettaglio + th:href="@{https://selfcare{env}.platform.pagopa.it/ui/channels/detail/{pathVar}/TO_BE_VALIDATED(env=${environment},pathVar=${channelCode})}">dettaglio del canale.

diff --git a/src/main/resources/templates/createBundleSubscriptionOfferEmail.html b/src/main/resources/templates/createBundleSubscriptionOfferEmail.html index f525ae179..bfe6d35fc 100644 --- a/src/main/resources/templates/createBundleSubscriptionOfferEmail.html +++ b/src/main/resources/templates/createBundleSubscriptionOfferEmail.html @@ -17,9 +17,12 @@

Nuova offerta di attivazione pacchetto commissionale


- Puoi vedere e gestire il pacchetto da qui https://selfcare.platform.pagopa.it/ui/comm-bundles. -

+ Puoi vedere e gestire il tuo pacchetto da qui + https://selfcare.platform.pagopa.it/ui/comm-bundles + https://selfcare.uat.platform.pagopa.it/ui/comm-bundles + https://selfcare.dev.platform.pagopa.it/ui/comm-bundles +.

A presto, diff --git a/src/main/resources/templates/createBundleSubscriptionRequestEmail.html b/src/main/resources/templates/createBundleSubscriptionRequestEmail.html index 12e22394f..fe2aa16ac 100644 --- a/src/main/resources/templates/createBundleSubscriptionRequestEmail.html +++ b/src/main/resources/templates/createBundleSubscriptionRequestEmail.html @@ -18,8 +18,11 @@

Nuova richiesta di attivazione pacchetto commissionale


Puoi gestire i tuoi pacchetti qui https://selfcare.platform.pagopa.it/ui/comm-bundles. -

+ href="@{https://selfcare{env}.platform.pagopa.it/ui/comm-bundles(env=${environment})}"> + https://selfcare.platform.pagopa.it/ui/comm-bundles + https://selfcare.uat.platform.pagopa.it/ui/comm-bundles + https://selfcare.dev.platform.pagopa.it/ui/comm-bundles +.

A presto, diff --git a/src/main/resources/templates/deleteBundleEmail.html b/src/main/resources/templates/deleteBundleEmail.html index 199b854e3..e660c75c9 100644 --- a/src/main/resources/templates/deleteBundleEmail.html +++ b/src/main/resources/templates/deleteBundleEmail.html @@ -21,8 +21,11 @@

Eliminazione pacchetto commissionale


Puoi gestire i tuoi pacchetti qui https://selfcare.platform.pagopa.it/ui/comm-bundles. -

+ href="@{https://selfcare{env}.platform.pagopa.it/ui/comm-bundles(env=${environment})}"> + https://selfcare.platform.pagopa.it/ui/comm-bundles + https://selfcare.uat.platform.pagopa.it/ui/comm-bundles + https://selfcare.dev.platform.pagopa.it/ui/comm-bundles +.

A presto, diff --git a/src/main/resources/templates/expiringBundleEmail.html b/src/main/resources/templates/expiringBundleEmail.html index d53b1776e..f8c6e0aa3 100644 --- a/src/main/resources/templates/expiringBundleEmail.html +++ b/src/main/resources/templates/expiringBundleEmail.html @@ -21,8 +21,11 @@

Pacchetto commissionale in scadenza

Puoi gestire i tuoi pacchetti qui https://selfcare.platform.pagopa.it/ui/comm-bundles. -

+ href="@{https://selfcare{env}.platform.pagopa.it/ui/comm-bundles(env=${environment})}"> + https://selfcare.platform.pagopa.it/ui/comm-bundles + https://selfcare.uat.platform.pagopa.it/ui/comm-bundles + https://selfcare.dev.platform.pagopa.it/ui/comm-bundles +.

A presto, diff --git a/src/main/resources/templates/stationReviewRequestedEmail.html b/src/main/resources/templates/stationReviewRequestedEmail.html index ecd756b0b..64c46ca74 100644 --- a/src/main/resources/templates/stationReviewRequestedEmail.html +++ b/src/main/resources/templates/stationReviewRequestedEmail.html @@ -19,7 +19,7 @@

Modifiche richieste

Puoi vedere le modifiche qui sotto oppure nel dettaglio + th:href="@{https://selfcare{env}.platform.pagopa.it/ui/stations/detail/{pathVar}/TO_BE_VALIDATED(env=${environment}, pathVar=${stationCode})}">dettaglio della stazione.

diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java index f9f321b3a..35b1bff4c 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/client/AwsSesClientTest.java @@ -49,6 +49,7 @@ class AwsSesClientTest { @Test void sendEmailPRODSuccess() { ReflectionTestUtils.setField(sut, "enableSendEmail", true); + ReflectionTestUtils.setField(sut, "environment", "PROD"); Institutions institutions = buildInstitutions(); List institutionProductUsers = buildInstitutionProductUsers(); @@ -69,6 +70,7 @@ void sendEmailPRODSuccess() { @Test void sendEmailNotPRODSuccess() { ReflectionTestUtils.setField(sut, "enableSendEmail", false); + ReflectionTestUtils.setField(sut, "environment", "UAT"); when(templateEngine.process(anyString(), any())).thenReturn("html template"); when(sesClient.sendEmail(any(SendEmailRequest.class))).thenReturn(SendEmailResponse.builder().build()); @@ -87,6 +89,7 @@ void sendEmailNotPRODSuccess() { @Test void sendEmailPRODFail() { ReflectionTestUtils.setField(sut, "enableSendEmail", true); + ReflectionTestUtils.setField(sut, "environment", "PROD"); Institutions institutions = buildInstitutions(); List institutionProductUsers = buildInstitutionProductUsers(); @@ -108,6 +111,7 @@ void sendEmailPRODFail() { void sendEmailPRODNoInstitutionTaxCodeSkipped() { ReflectionTestUtils.setField(sut, "enableSendEmail", true); ReflectionTestUtils.setField(sut, "testEmailAddress", "test@mail.it"); + ReflectionTestUtils.setField(sut, "environment", "PROD"); assertDoesNotThrow(() -> sut.sendEmail(buildEmailMessageDetail(null))); @@ -125,6 +129,7 @@ void sendEmailPRODNoInstitutionTaxCodeSkipped() { @Test void sendEmailNoInstitutionFoundSkipped() { ReflectionTestUtils.setField(sut, "enableSendEmail", true); + ReflectionTestUtils.setField(sut, "environment", "PROD"); when(externalApiClient.getInstitutionsFiltered(INSTITUTION_TAX_CODE)) .thenReturn(Institutions.builder().institutions(Collections.emptyList()).build()); @@ -144,6 +149,7 @@ void sendEmailNoInstitutionFoundSkipped() { @Test void sendEmailNoDestinationSkipped() { ReflectionTestUtils.setField(sut, "enableSendEmail", true); + ReflectionTestUtils.setField(sut, "environment", "PROD"); Institutions institutions = buildInstitutions(); @@ -165,6 +171,7 @@ void sendEmailNoDestinationSkipped() { void sendEmailNotPRODAndNoTestEmailSkipped() { ReflectionTestUtils.setField(sut, "enableSendEmail", false); ReflectionTestUtils.setField(sut, "testEmailAddress", null); + ReflectionTestUtils.setField(sut, "environment", "UAT"); assertDoesNotThrow(() -> sut.sendEmail(buildEmailMessageDetail(INSTITUTION_TAX_CODE))); @@ -182,6 +189,7 @@ void sendEmailNotPRODAndNoTestEmailSkipped() { @Test void sendEmailPRODSWithPagopaOperatorSuccess() { ReflectionTestUtils.setField(sut, "enableSendEmail", true); + ReflectionTestUtils.setField(sut, "environment", "PROD"); Institutions institutions = buildInstitutions(); List institutionProductUsers = buildInstitutionProductUsers(); From 788b9d46ee8d888d2126014afc078db55e2b12aa Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 4 Dec 2024 10:51:54 +0000 Subject: [PATCH 14/24] Bump to version 2.34.0 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f104a08ae..437170449 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.440.0 -appVersion: "2.33.1" +version: 0.441.0 +appVersion: "2.34.0" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index f4d0b7896..75cf74863 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.33.1" + tag: "2.34.0" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 7cbf67fcf..ac43912cd 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.33.1" #improve + tag: "2.34.0" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index ff92f81fc..f5acf7aba 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.33.1" #improve + tag: "2.34.0" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index a1aec98a8..5b9d2494e 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.33.1" + "version": "2.34.0" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 0eec7fd5d..0e64dce51 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.33.1 + 2.34.0 SelfCare Backoffice Microservice to manage PagoPA Backoffice From 0eeae78251f0a79b4968366ed75c9b56da8aca58 Mon Sep 17 00:00:00 2001 From: gioelemella <128155546+gioelemella@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:10:14 +0100 Subject: [PATCH 15/24] [PPANTT-222] fix: BO external authorizer config (#531) --- .../service/ApiManagementService.java | 7 +++ .../service/ApiManagementServiceTest.java | 53 ++++++++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java index df0a4c107..564427eb9 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java @@ -560,6 +560,13 @@ private AuthorizationConfig getAuthorizationConfig( authorizationMetadata = buildAuthorizationMetadata(ciSegregationCodes); } } + if (subscription.equals(Subscription.BO_EXT_EC) || subscription.equals(Subscription.BO_EXT_PSP)) { + authorizationEntities.add( + AuthorizationEntity.builder() + .name(institution.getDescription()) + .value(institution.getTaxCode()) + .build()); + } return new AuthorizationConfig(authorizationEntities, authorizationMetadata); } diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java index 7cc367ddf..b14d03476 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java @@ -40,7 +40,6 @@ import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.http.HttpStatus; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -378,10 +377,20 @@ void createSubscriptionKeysForBOExtEC() { verify(apimClient, never()).createInstitution(anyString(), any()); verify(apimClient).createInstitutionSubscription(any(), any(), any(), any(), any()); verify(externalApiClient).getInstitution(INSTITUTION_ID); - verify(authorizerConfigClient, times(2)).createAuthorization(any()); verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null); verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean()); + verify(authorizerConfigClient, times(2)).createAuthorization(authorizationCaptor.capture()); + + Authorization captorValue = authorizationCaptor.getValue(); + assertNotNull(captorValue); + assertNotNull(captorValue.getOwner()); + assertEquals(INSTITUTION_TAX_CODE, captorValue.getOwner().getId()); + assertNotNull(captorValue.getAuthorizedEntities()); + assertEquals(1, captorValue.getAuthorizedEntities().size()); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> INSTITUTION_TAX_CODE.equals(elem.getValue()))); + assertNotNull(captorValue.getOtherMetadata()); + assertTrue(captorValue.getOtherMetadata().isEmpty()); } @Test @@ -638,9 +647,17 @@ void regeneratePrimaryKeyForBOExtEC() { verify(apimClient).getApiSubscriptions(INSTITUTION_ID); verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean()); verify(authorizerConfigClient).deleteAuthorization(anyString()); - verify(authorizerConfigClient).createAuthorization(any()); verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null); verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); + verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); + + Authorization captorValue = authorizationCaptor.getValue(); + assertNotNull(captorValue); + assertNotNull(captorValue.getAuthorizedEntities()); + assertEquals(1, captorValue.getAuthorizedEntities().size()); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> INSTITUTION_TAX_CODE.equals(elem.getValue()))); + assertNotNull(captorValue.getOtherMetadata()); + assertTrue(captorValue.getOtherMetadata().isEmpty()); } @Test @@ -659,9 +676,17 @@ void regeneratePrimaryKeyForBOExtPSP() { verify(apimClient).getApiSubscriptions(INSTITUTION_ID); verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean()); verify(authorizerConfigClient).deleteAuthorization(anyString()); - verify(authorizerConfigClient).createAuthorization(any()); verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null); verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); + verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); + + Authorization captorValue = authorizationCaptor.getValue(); + assertNotNull(captorValue); + assertNotNull(captorValue.getAuthorizedEntities()); + assertEquals(1, captorValue.getAuthorizedEntities().size()); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> INSTITUTION_TAX_CODE.equals(elem.getValue()))); + assertNotNull(captorValue.getOtherMetadata()); + assertTrue(captorValue.getOtherMetadata().isEmpty()); } @Test @@ -769,9 +794,17 @@ void regenerateSecondaryKeyForBOExtEC() { verify(apimClient).regenerateSecondaryKey(subscriptionId); verify(apimClient).getApiSubscriptions(INSTITUTION_ID); verify(authorizerConfigClient).deleteAuthorization(anyString()); - verify(authorizerConfigClient).createAuthorization(any()); verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null); verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); + verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); + + Authorization captorValue = authorizationCaptor.getValue(); + assertNotNull(captorValue); + assertNotNull(captorValue.getAuthorizedEntities()); + assertEquals(1, captorValue.getAuthorizedEntities().size()); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> INSTITUTION_TAX_CODE.equals(elem.getValue()))); + assertNotNull(captorValue.getOtherMetadata()); + assertTrue(captorValue.getOtherMetadata().isEmpty()); } @Test @@ -790,9 +823,17 @@ void regenerateSecondaryKeyForBOExtPSP() { verify(apimClient).regenerateSecondaryKey(subscriptionId); verify(apimClient).getApiSubscriptions(INSTITUTION_ID); verify(authorizerConfigClient).deleteAuthorization(anyString()); - verify(authorizerConfigClient).createAuthorization(any()); verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null); verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); + verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); + + Authorization captorValue = authorizationCaptor.getValue(); + assertNotNull(captorValue); + assertNotNull(captorValue.getAuthorizedEntities()); + assertEquals(1, captorValue.getAuthorizedEntities().size()); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> INSTITUTION_TAX_CODE.equals(elem.getValue()))); + assertNotNull(captorValue.getOtherMetadata()); + assertTrue(captorValue.getOtherMetadata().isEmpty()); } @Test From 22f5bab04ae168f1949ab8502f82d54bd19efb17 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Fri, 6 Dec 2024 10:11:03 +0000 Subject: [PATCH 16/24] Bump to version 2.34.1 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 437170449..1c092520b 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-selfcare-ms-backoffice description: Microservice that manage api keys for pagopa product from selfcare type: application -version: 0.441.0 -appVersion: "2.34.0" +version: 0.442.0 +appVersion: "2.34.1" dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 75cf74863..2618181ab 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.34.0" + tag: "2.34.1" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index ac43912cd..5af66ccd3 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.34.0" #improve + tag: "2.34.1" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index f5acf7aba..648e79318 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend - tag: "2.34.0" #improve + tag: "2.34.1" #improve pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 5b9d2494e..d74e3b67e 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "Microservice to manage PagoPA Backoffice", "termsOfService": "https://www.pagopa.gov.it/", "title": "SelfCare Backoffice", - "version": "2.34.0" + "version": "2.34.1" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 0e64dce51..b11cbb9ab 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 2.5.14 pagopa-selfcare-ms-backoffice - 2.34.0 + 2.34.1 SelfCare Backoffice Microservice to manage PagoPA Backoffice From 6dfb9983508ade9823f860952a46cff876d357ba Mon Sep 17 00:00:00 2001 From: giomella Date: Mon, 16 Dec 2024 11:14:58 +0100 Subject: [PATCH 17/24] [PPANTT-223] added new api key subscription for Fdr KPI API --- .../model/institutions/Subscription.java | 1 + .../service/ApiManagementService.java | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java index 8e1523640..b2b522062 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java @@ -24,6 +24,7 @@ public enum Subscription { BIZ("/products/bizevents", "BIZ - Recupero ricevute Ente Creditore", "biz-", CI, null, false), FDR_ORG("/products/fdr-org", "FdR - Flussi di Rendicontazione (EC)", "fdrorg-", CI, "fdr", true), FDR_PSP("/products/fdr-psp", "FdR - Flussi di Rendicontazione (PSP)", "fdrpsp-", PSP, "fdr", true), + FDR_KPI_API("/products/fdr-", "FdR - Quality Improvement KPI API", "fdrkpiapi-", PSP, "fdr", true), BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false), BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false), PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false), diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java index 564427eb9..586b6f5f2 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java @@ -177,7 +177,7 @@ public InstitutionApiKeysResource getInstitutionApiKeys(String institutionId) { /** * Create the subscription's api keys to the specified subscription for the specified institution. *

- * If the subscription is for {@link Subscription#BO_EXT_EC} or {@link Subscription#BO_EXT_PSP} then it configure + * If the subscription configuration {@link Subscription} require authorizer then it call * the Authorizer config service in order to enable the authorization process. * * @param institutionId the id of the institution @@ -187,7 +187,7 @@ public InstitutionApiKeysResource getInstitutionApiKeys(String institutionId) { public InstitutionApiKeysResource createSubscriptionKeys(String institutionId, Subscription subscriptionCode) { InstitutionResponse institution = getInstitutionResponse(institutionId); checkIfInstitutionCanOperateOnSubscriptionOtherwiseThrowException(institution, subscriptionCode); - if (subscriptionCode.equals(Subscription.FDR_PSP) && !InstitutionType.PT.equals(institution.getInstitutionType())) { + if (isPSPCodeRequiredForProvidedSubscriptionAnInstitution(subscriptionCode, institution)) { checkIfPSPCodeIsAvailableOtherwiseThrowException(institution, subscriptionCode); } @@ -229,8 +229,8 @@ public InstitutionApiKeysResource createSubscriptionKeys(String institutionId, S /** * Regenerate the primary subscription key to the specified subscription for the given institution. *

- * If the subscription is for {@link Subscription#BO_EXT_EC} or {@link Subscription#BO_EXT_PSP} then it update - * the Authorizer config service with the new api key. + * If the subscription configuration {@link Subscription} require authorizer then it call + * the Authorizer config service in order to enable the authorization process. * * @param institutionId the id of the institution * @param subscriptionId the id of the subscription @@ -240,7 +240,7 @@ public void regeneratePrimaryKey(@NotNull String institutionId, @NotNull String var prefix = subscriptionId.split("-")[0] + "-"; Subscription subscription = Subscription.fromPrefix(prefix); checkIfInstitutionCanOperateOnSubscriptionOtherwiseThrowException(institution, subscription); - if (subscription.equals(Subscription.FDR_PSP) && !InstitutionType.PT.equals(institution.getInstitutionType())) { + if (isPSPCodeRequiredForProvidedSubscriptionAnInstitution(subscription, institution)) { checkIfPSPCodeIsAvailableOtherwiseThrowException(institution, subscription); } this.apimClient.regeneratePrimaryKey(subscriptionId); @@ -253,8 +253,8 @@ public void regeneratePrimaryKey(@NotNull String institutionId, @NotNull String /** * Regenerate the secondary subscription key to the specified subscription for the given institution. *

- * If the subscription is for {@link Subscription#BO_EXT_EC} or {@link Subscription#BO_EXT_PSP} then it update - * the Authorizer config service with the new api key. + * If the subscription configuration {@link Subscription} require authorizer then it call + * the Authorizer config service in order to enable the authorization process. * * @param institutionId the id of the institution * @param subscriptionId the id of the subscription @@ -264,7 +264,7 @@ public void regenerateSecondaryKey(@NotNull String institutionId, @NotNull Strin var prefix = subscriptionId.split("-")[0] + "-"; Subscription subscription = Subscription.fromPrefix(prefix); checkIfInstitutionCanOperateOnSubscriptionOtherwiseThrowException(institution, subscription); - if (subscription.equals(Subscription.FDR_PSP) && !InstitutionType.PT.equals(institution.getInstitutionType())) { + if (isPSPCodeRequiredForProvidedSubscriptionAnInstitution(subscription, institution)) { checkIfPSPCodeIsAvailableOtherwiseThrowException(institution, subscription); } this.apimClient.regenerateSecondaryKey(subscriptionId); @@ -459,7 +459,7 @@ private AuthorizationEntity getAuthorizationEntity( String taxCode ) { String value = taxCode; - if (subscription.equals(Subscription.FDR_PSP)) { + if (subscription.equals(Subscription.FDR_PSP) || subscription.equals(Subscription.FDR_KPI_API)) { try { value = this.legacyPspCodeUtil.retrievePspCode(taxCode, false); } catch (Exception e) { @@ -599,5 +599,11 @@ private char getEnvironment() { private record AuthorizationConfig(List authorizationEntities, List authorizationMetadata) { + + } + + private boolean isPSPCodeRequiredForProvidedSubscriptionAnInstitution(Subscription subscriptionCode, InstitutionResponse institution) { + return (subscriptionCode.equals(Subscription.FDR_PSP) || subscriptionCode.equals(Subscription.FDR_KPI_API)) + && !InstitutionType.PT.equals(institution.getInstitutionType()); } } From 036201a4f28a9bbd54f6a14aa1405f5ac1fb0c29 Mon Sep 17 00:00:00 2001 From: giomella Date: Mon, 16 Dec 2024 11:50:53 +0100 Subject: [PATCH 18/24] [PPANTT-223] improved tests --- .../service/ApiManagementServiceTest.java | 173 +++++++----------- 1 file changed, 70 insertions(+), 103 deletions(-) diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java index b14d03476..9fb96f9b4 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java @@ -32,6 +32,9 @@ import it.pagopa.selfcare.pagopa.backoffice.util.LegacyPspCodeUtil; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.EnumSource; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.springframework.beans.factory.annotation.Autowired; @@ -210,7 +213,7 @@ void createSubscriptionKeySuccessForNodeAuth() { when(apimClient.getApiSubscriptions(any())).thenReturn(Collections.singletonList(new InstitutionApiKeys())); InstitutionApiKeysResource result = assertDoesNotThrow(() -> - service.createSubscriptionKeys(INSTITUTION_ID, Subscription.NODOAUTH)); + service. createSubscriptionKeys(INSTITUTION_ID, Subscription.NODOAUTH)); assertNotNull(result); assertNotNull(result.getInstitutionApiKeys()); @@ -312,13 +315,14 @@ void createSubscriptionKeyFailPTPSPRequestCISubscription() { verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean()); } - @Test - void createSubscriptionKeys() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"NODOAUTH", "BIZ", "PRINT_NOTICE"}) + void createSubscriptionKeysSuccessNoAuthorizer(Subscription sub) { when(externalApiClient.getInstitution(any())).thenReturn(buildInstitutionResponse(InstitutionType.PA)); when(apimClient.getApiSubscriptions(any())).thenReturn(Collections.singletonList(new InstitutionApiKeys())); InstitutionApiKeysResource result = assertDoesNotThrow(() -> - service.createSubscriptionKeys(INSTITUTION_ID, Subscription.BIZ)); + service.createSubscriptionKeys(INSTITUTION_ID, sub)); assertNotNull(result); assertNotNull(result.getInstitutionApiKeys()); @@ -357,17 +361,21 @@ void createSubscriptionKeysWithoutAPIMUser() { verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean()); } - @Test - void createSubscriptionKeysForBOExtEC() { - it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); + @ParameterizedTest + @CsvSource({ + "BO_EXT_EC, PA", + "BO_EXT_PSP, PSP" + }) + void createSubscriptionKeysForBOExtEC(Subscription sub, InstitutionType instType) { + it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(instType); InstitutionApiKeys institutionApiKeys = - buildInstitutionApiKeys(String.format("%s%s", Subscription.BO_EXT_EC.getPrefixId(), institutionResponse.getTaxCode())); + buildInstitutionApiKeys(String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode())); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(apimClient.getApiSubscriptions(any())).thenReturn(Collections.singletonList(institutionApiKeys)); InstitutionApiKeysResource result = assertDoesNotThrow(() -> - service.createSubscriptionKeys(INSTITUTION_ID, Subscription.BO_EXT_EC)); + service.createSubscriptionKeys(INSTITUTION_ID, sub)); assertNotNull(result); assertNotNull(result.getInstitutionApiKeys()); @@ -393,11 +401,12 @@ void createSubscriptionKeysForBOExtEC() { assertTrue(captorValue.getOtherMetadata().isEmpty()); } - @Test - void createSubscriptionKeysForGPDSuccess() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"GPD", "GPD_REP", "GPD_PAY"}) + void createSubscriptionKeysForGPDSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); InstitutionApiKeys institutionApiKeys = - buildInstitutionApiKeys(String.format("%s%s", Subscription.GPD.getPrefixId(), institutionResponse.getTaxCode())); + buildInstitutionApiKeys(String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode())); List delegations = createDelegations(); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); @@ -408,7 +417,7 @@ void createSubscriptionKeysForGPDSuccess() { .thenReturn(buildCreditorInstitutionStationSegregationCodesList()); InstitutionApiKeysResource result = assertDoesNotThrow(() -> - service.createSubscriptionKeys(INSTITUTION_ID, Subscription.GPD)); + service.createSubscriptionKeys(INSTITUTION_ID, sub)); assertNotNull(result); assertNotNull(result.getInstitutionApiKeys()); @@ -434,15 +443,16 @@ void createSubscriptionKeysForGPDSuccess() { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @Test - void createSubscriptionKeysForFdrPspFailNoPSPCode() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); AppException e = assertThrows(AppException.class, () -> - service.createSubscriptionKeys(INSTITUTION_ID, Subscription.FDR_PSP)); + service.createSubscriptionKeys(INSTITUTION_ID, sub)); assertNotNull(e); assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getHttpStatus()); @@ -498,10 +508,11 @@ void createSubscriptionKeysForFdrPspSuccessWithOneDelegationExcludedForNoPSPCode assertTrue(captorValue.getOtherMetadata().isEmpty()); } - @Test - void regeneratePrimaryKeyForNoAuthSubscription() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"NODOAUTH", "BIZ", "PRINT_NOTICE"}) + void regeneratePrimaryKeyForNoAuthSubscription(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); - String subscriptionId = String.format("%s%s", Subscription.BIZ.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); @@ -516,10 +527,11 @@ void regeneratePrimaryKeyForNoAuthSubscription() { verify(authorizerConfigClient, never()).createAuthorization(any()); } - @Test - void regeneratePrimaryKeyForGPDSuccess() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"GPD", "GPD_REP", "GPD_PAY"}) + void regeneratePrimaryKeyForGPDSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); - String subscriptionId = String.format("%s%s", Subscription.GPD.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); @@ -550,10 +562,11 @@ void regeneratePrimaryKeyForGPDSuccess() { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @Test - void regeneratePrimaryKeyForFDRPSPFailNoPSPCode() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); @@ -571,10 +584,11 @@ void regeneratePrimaryKeyForFDRPSPFailNoPSPCode() { verify(authorizerConfigClient, never()).createAuthorization(any()); } - @Test - void regeneratePrimaryKeyForFDRPSPSuccess() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + void regeneratePrimaryKeyForFDRPSPSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); @@ -631,10 +645,14 @@ void regeneratePrimaryKeyFailOnAuthorizerConfigUpdateTriggerAPIKeyRecreation() { verify(authorizerConfigClient, never()).deleteAuthorization(anyString()); } - @Test - void regeneratePrimaryKeyForBOExtEC() { - it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); - String subscriptionId = String.format("%s%s", Subscription.BO_EXT_EC.getPrefixId(), institutionResponse.getTaxCode()); + @ParameterizedTest + @CsvSource({ + "BO_EXT_EC, PA", + "BO_EXT_PSP, PSP" +}) + void regeneratePrimaryKeyForBOExtEC(Subscription sub, InstitutionType instType) { + it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(instType); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); @@ -660,39 +678,11 @@ void regeneratePrimaryKeyForBOExtEC() { assertTrue(captorValue.getOtherMetadata().isEmpty()); } - @Test - void regeneratePrimaryKeyForBOExtPSP() { - it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.BO_EXT_PSP.getPrefixId(), institutionResponse.getTaxCode()); - InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); - - when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); - when(apimClient.getApiSubscriptions(any())).thenReturn(Collections.singletonList(institutionApiKeys)); - when(authorizerConfigClient.getAuthorization(anyString())).thenReturn(Authorization.builder().id(AUTH_ID).build()); - - assertDoesNotThrow(() -> service.regeneratePrimaryKey(INSTITUTION_ID, subscriptionId)); - - verify(apimClient).regeneratePrimaryKey(subscriptionId); - verify(apimClient).getApiSubscriptions(INSTITUTION_ID); - verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean()); - verify(authorizerConfigClient).deleteAuthorization(anyString()); - verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null); - verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); - verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); - - Authorization captorValue = authorizationCaptor.getValue(); - assertNotNull(captorValue); - assertNotNull(captorValue.getAuthorizedEntities()); - assertEquals(1, captorValue.getAuthorizedEntities().size()); - assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> INSTITUTION_TAX_CODE.equals(elem.getValue()))); - assertNotNull(captorValue.getOtherMetadata()); - assertTrue(captorValue.getOtherMetadata().isEmpty()); - } - - @Test - void regenerateSecondaryKeyForGPDSuccess() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"GPD", "GPD_REP", "GPD_PAY"}) + void regenerateSecondaryKeyForGPDSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); - String subscriptionId = String.format("%s%s", Subscription.GPD.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); @@ -724,10 +714,11 @@ void regenerateSecondaryKeyForGPDSuccess() { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @Test - void regenerateSecondaryKeyForFDRPSPFailNoPSPCode() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); @@ -745,10 +736,11 @@ void regenerateSecondaryKeyForFDRPSPFailNoPSPCode() { verify(authorizerConfigClient, never()).createAuthorization(any()); } - @Test - void regenerateSecondaryKeyForFDRPSPSuccess() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); @@ -778,39 +770,14 @@ void regenerateSecondaryKeyForFDRPSPSuccess() { assertTrue(captorValue.getOtherMetadata().isEmpty()); } - @Test - void regenerateSecondaryKeyForBOExtEC() { - it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); - String subscriptionId = String.format("%s%s", Subscription.BO_EXT_EC.getPrefixId(), institutionResponse.getTaxCode()); - InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); - - when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); - when(apimClient.getApiSubscriptions(any())).thenReturn(Collections.singletonList(institutionApiKeys)); - when(authorizerConfigClient.getAuthorization(anyString())).thenReturn(Authorization.builder().id(AUTH_ID).build()); - - assertDoesNotThrow(() -> service.regenerateSecondaryKey(INSTITUTION_ID, subscriptionId)); - - verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean()); - verify(apimClient).regenerateSecondaryKey(subscriptionId); - verify(apimClient).getApiSubscriptions(INSTITUTION_ID); - verify(authorizerConfigClient).deleteAuthorization(anyString()); - verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null); - verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); - verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); - - Authorization captorValue = authorizationCaptor.getValue(); - assertNotNull(captorValue); - assertNotNull(captorValue.getAuthorizedEntities()); - assertEquals(1, captorValue.getAuthorizedEntities().size()); - assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> INSTITUTION_TAX_CODE.equals(elem.getValue()))); - assertNotNull(captorValue.getOtherMetadata()); - assertTrue(captorValue.getOtherMetadata().isEmpty()); - } - - @Test - void regenerateSecondaryKeyForBOExtPSP() { - it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.BO_EXT_PSP.getPrefixId(), institutionResponse.getTaxCode()); + @ParameterizedTest + @CsvSource({ + "BO_EXT_EC, PA", + "BO_EXT_PSP, PSP" + }) + void regenerateSecondaryKeyForBOExtEC(Subscription sub, InstitutionType instType) { + it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(instType); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); From 5e55c05da3ba5baa87d06cb6c17019fd73ad8270 Mon Sep 17 00:00:00 2001 From: giomella Date: Tue, 17 Dec 2024 09:43:21 +0100 Subject: [PATCH 19/24] [PPANTT-223] updated subscription info --- .../backoffice/model/institutions/Subscription.java | 2 +- .../backoffice/service/ApiManagementService.java | 4 ++-- .../backoffice/service/ApiManagementServiceTest.java | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java index b2b522062..b6c9e3132 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java @@ -24,7 +24,7 @@ public enum Subscription { BIZ("/products/bizevents", "BIZ - Recupero ricevute Ente Creditore", "biz-", CI, null, false), FDR_ORG("/products/fdr-org", "FdR - Flussi di Rendicontazione (EC)", "fdrorg-", CI, "fdr", true), FDR_PSP("/products/fdr-psp", "FdR - Flussi di Rendicontazione (PSP)", "fdrpsp-", PSP, "fdr", true), - FDR_KPI_API("/products/fdr-", "FdR - Quality Improvement KPI API", "fdrkpiapi-", PSP, "fdr", true), + QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdr-", PSP, "qi", true), BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false), BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false), PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false), diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java index 586b6f5f2..5631b2d42 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java @@ -459,7 +459,7 @@ private AuthorizationEntity getAuthorizationEntity( String taxCode ) { String value = taxCode; - if (subscription.equals(Subscription.FDR_PSP) || subscription.equals(Subscription.FDR_KPI_API)) { + if (subscription.equals(Subscription.FDR_PSP) || subscription.equals(Subscription.QI_FDR_KPI)) { try { value = this.legacyPspCodeUtil.retrievePspCode(taxCode, false); } catch (Exception e) { @@ -603,7 +603,7 @@ private record AuthorizationConfig(List authorizationEntiti } private boolean isPSPCodeRequiredForProvidedSubscriptionAnInstitution(Subscription subscriptionCode, InstitutionResponse institution) { - return (subscriptionCode.equals(Subscription.FDR_PSP) || subscriptionCode.equals(Subscription.FDR_KPI_API)) + return (subscriptionCode.equals(Subscription.FDR_PSP) || subscriptionCode.equals(Subscription.QI_FDR_KPI)) && !InstitutionType.PT.equals(institution.getInstitutionType()); } } diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java index 9fb96f9b4..5ff9a8ac1 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java @@ -444,7 +444,7 @@ void createSubscriptionKeysForGPDSuccess(Subscription sub) { } @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); @@ -563,7 +563,7 @@ void regeneratePrimaryKeyForGPDSuccess(Subscription sub) { } @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); @@ -585,7 +585,7 @@ void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Sub } @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) void regeneratePrimaryKeyForFDRPSPSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); @@ -715,7 +715,7 @@ void regenerateSecondaryKeyForGPDSuccess(Subscription sub) { } @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); @@ -737,7 +737,7 @@ void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(S } @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "FDR_KPI_API"}) + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); From efe1f03265194a0c3252c87431ea4942f9ca85c3 Mon Sep 17 00:00:00 2001 From: giomella Date: Tue, 17 Dec 2024 09:46:25 +0100 Subject: [PATCH 20/24] [PPANTT-223] updated prefix id --- .../pagopa/backoffice/model/institutions/Subscription.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java index b6c9e3132..4d2bbc60f 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java @@ -24,7 +24,7 @@ public enum Subscription { BIZ("/products/bizevents", "BIZ - Recupero ricevute Ente Creditore", "biz-", CI, null, false), FDR_ORG("/products/fdr-org", "FdR - Flussi di Rendicontazione (EC)", "fdrorg-", CI, "fdr", true), FDR_PSP("/products/fdr-psp", "FdR - Flussi di Rendicontazione (PSP)", "fdrpsp-", PSP, "fdr", true), - QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdr-", PSP, "qi", true), + QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qi-fdr-kpi-service-", PSP, "qi", true), BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false), BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false), PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false), From 99a705984a73aa52bd493b6c300cc4e9f73491fe Mon Sep 17 00:00:00 2001 From: giomella Date: Tue, 17 Dec 2024 11:00:43 +0100 Subject: [PATCH 21/24] [PPANTT-223] removed authorized entities configuration for new key and updated tests --- .../model/institutions/Subscription.java | 2 +- .../service/ApiManagementService.java | 5 ++- .../service/ApiManagementServiceTest.java | 35 ++++++++----------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java index 4d2bbc60f..2aeac6767 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java @@ -24,7 +24,7 @@ public enum Subscription { BIZ("/products/bizevents", "BIZ - Recupero ricevute Ente Creditore", "biz-", CI, null, false), FDR_ORG("/products/fdr-org", "FdR - Flussi di Rendicontazione (EC)", "fdrorg-", CI, "fdr", true), FDR_PSP("/products/fdr-psp", "FdR - Flussi di Rendicontazione (PSP)", "fdrpsp-", PSP, "fdr", true), - QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qi-fdr-kpi-service-", PSP, "qi", true), + QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdrkpiservice-", PSP, "qi", false), BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false), BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false), PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false), diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java index 5631b2d42..a7a86cee0 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java @@ -459,7 +459,7 @@ private AuthorizationEntity getAuthorizationEntity( String taxCode ) { String value = taxCode; - if (subscription.equals(Subscription.FDR_PSP) || subscription.equals(Subscription.QI_FDR_KPI)) { + if (subscription.equals(Subscription.FDR_PSP)) { try { value = this.legacyPspCodeUtil.retrievePspCode(taxCode, false); } catch (Exception e) { @@ -603,7 +603,6 @@ private record AuthorizationConfig(List authorizationEntiti } private boolean isPSPCodeRequiredForProvidedSubscriptionAnInstitution(Subscription subscriptionCode, InstitutionResponse institution) { - return (subscriptionCode.equals(Subscription.FDR_PSP) || subscriptionCode.equals(Subscription.QI_FDR_KPI)) - && !InstitutionType.PT.equals(institution.getInstitutionType()); + return subscriptionCode.equals(Subscription.FDR_PSP) && !InstitutionType.PT.equals(institution.getInstitutionType()); } } diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java index 5ff9a8ac1..006090e0f 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java @@ -443,16 +443,15 @@ void createSubscriptionKeysForGPDSuccess(Subscription sub) { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) - void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { + @Test + void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); AppException e = assertThrows(AppException.class, () -> - service.createSubscriptionKeys(INSTITUTION_ID, sub)); + service.createSubscriptionKeys(INSTITUTION_ID, Subscription.FDR_PSP)); assertNotNull(e); assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getHttpStatus()); @@ -562,11 +561,10 @@ void regeneratePrimaryKeyForGPDSuccess(Subscription sub) { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) - void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { + @Test + void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); @@ -584,11 +582,10 @@ void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Sub verify(authorizerConfigClient, never()).createAuthorization(any()); } - @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) - void regeneratePrimaryKeyForFDRPSPSuccess(Subscription sub) { + @Test + void regeneratePrimaryKeyForFDRPSPSuccess() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); @@ -714,11 +711,10 @@ void regenerateSecondaryKeyForGPDSuccess(Subscription sub) { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) - void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { + @Test + void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); @@ -736,11 +732,10 @@ void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(S verify(authorizerConfigClient, never()).createAuthorization(any()); } - @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) - void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess(Subscription sub) { + @Test + void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); From c9f2a6291fdb25b79e3e2b8968118ccf7eee619c Mon Sep 17 00:00:00 2001 From: giomella Date: Tue, 17 Dec 2024 11:01:46 +0100 Subject: [PATCH 22/24] [PPANTT-223] updated openapi --- openapi/openapi.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi/openapi.json b/openapi/openapi.json index d74e3b67e..2494c72e5 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -8965,6 +8965,7 @@ "BIZ", "FDR_ORG", "FDR_PSP", + "QI_FDR_KPI", "BO_EXT_EC", "BO_EXT_PSP", "PRINT_NOTICE", @@ -17049,4 +17050,4 @@ } } } -} +} \ No newline at end of file From b73f28755ecf46f50e38f106cc5d57d8b2c09b85 Mon Sep 17 00:00:00 2001 From: giomella Date: Tue, 17 Dec 2024 16:16:36 +0100 Subject: [PATCH 23/24] [PPANTT-183] rollback changes --- .../model/institutions/Subscription.java | 2 +- .../service/ApiManagementService.java | 5 +-- .../service/ApiManagementServiceTest.java | 35 +++++++++++-------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java index 2aeac6767..cc05ce422 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/model/institutions/Subscription.java @@ -24,7 +24,7 @@ public enum Subscription { BIZ("/products/bizevents", "BIZ - Recupero ricevute Ente Creditore", "biz-", CI, null, false), FDR_ORG("/products/fdr-org", "FdR - Flussi di Rendicontazione (EC)", "fdrorg-", CI, "fdr", true), FDR_PSP("/products/fdr-psp", "FdR - Flussi di Rendicontazione (PSP)", "fdrpsp-", PSP, "fdr", true), - QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdrkpiservice-", PSP, "qi", false), + QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdrkpiservice-", PSP, "qi", true), BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false), BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false), PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false), diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java index a7a86cee0..5631b2d42 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java @@ -459,7 +459,7 @@ private AuthorizationEntity getAuthorizationEntity( String taxCode ) { String value = taxCode; - if (subscription.equals(Subscription.FDR_PSP)) { + if (subscription.equals(Subscription.FDR_PSP) || subscription.equals(Subscription.QI_FDR_KPI)) { try { value = this.legacyPspCodeUtil.retrievePspCode(taxCode, false); } catch (Exception e) { @@ -603,6 +603,7 @@ private record AuthorizationConfig(List authorizationEntiti } private boolean isPSPCodeRequiredForProvidedSubscriptionAnInstitution(Subscription subscriptionCode, InstitutionResponse institution) { - return subscriptionCode.equals(Subscription.FDR_PSP) && !InstitutionType.PT.equals(institution.getInstitutionType()); + return (subscriptionCode.equals(Subscription.FDR_PSP) || subscriptionCode.equals(Subscription.QI_FDR_KPI)) + && !InstitutionType.PT.equals(institution.getInstitutionType()); } } diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java index 006090e0f..5ff9a8ac1 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java @@ -443,15 +443,16 @@ void createSubscriptionKeysForGPDSuccess(Subscription sub) { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @Test - void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) + void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); AppException e = assertThrows(AppException.class, () -> - service.createSubscriptionKeys(INSTITUTION_ID, Subscription.FDR_PSP)); + service.createSubscriptionKeys(INSTITUTION_ID, sub)); assertNotNull(e); assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getHttpStatus()); @@ -561,10 +562,11 @@ void regeneratePrimaryKeyForGPDSuccess(Subscription sub) { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @Test - void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) + void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); @@ -582,10 +584,11 @@ void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() { verify(authorizerConfigClient, never()).createAuthorization(any()); } - @Test - void regeneratePrimaryKeyForFDRPSPSuccess() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) + void regeneratePrimaryKeyForFDRPSPSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); @@ -711,10 +714,11 @@ void regenerateSecondaryKeyForGPDSuccess(Subscription sub) { assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey()); } - @Test - void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) + void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class); @@ -732,10 +736,11 @@ void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() verify(authorizerConfigClient, never()).createAuthorization(any()); } - @Test - void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess() { + @ParameterizedTest + @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) + void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess(Subscription sub) { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); From 55085c10488152a0425c84af67d8257d651c7566 Mon Sep 17 00:00:00 2001 From: giomella Date: Thu, 19 Dec 2024 10:56:38 +0100 Subject: [PATCH 24/24] [PPANTT-223] update auth config --- .../service/ApiManagementService.java | 2 +- .../service/ApiManagementServiceTest.java | 80 +++++++++++++++++-- 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java index 5631b2d42..446ab4a4f 100644 --- a/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java +++ b/src/main/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementService.java @@ -560,7 +560,7 @@ private AuthorizationConfig getAuthorizationConfig( authorizationMetadata = buildAuthorizationMetadata(ciSegregationCodes); } } - if (subscription.equals(Subscription.BO_EXT_EC) || subscription.equals(Subscription.BO_EXT_PSP)) { + if (subscription.equals(Subscription.BO_EXT_EC) || subscription.equals(Subscription.BO_EXT_PSP) || subscription.equals(Subscription.QI_FDR_KPI)) { authorizationEntities.add( AuthorizationEntity.builder() .name(institution.getDescription()) diff --git a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java index 5ff9a8ac1..06142624b 100644 --- a/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java +++ b/src/test/java/it/pagopa/selfcare/pagopa/backoffice/service/ApiManagementServiceTest.java @@ -584,11 +584,10 @@ void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Sub verify(authorizerConfigClient, never()).createAuthorization(any()); } - @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) - void regeneratePrimaryKeyForFDRPSPSuccess(Subscription sub) { + @Test + void regeneratePrimaryKeyForFDRPSPSuccess() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); @@ -618,6 +617,39 @@ void regeneratePrimaryKeyForFDRPSPSuccess(Subscription sub) { assertTrue(captorValue.getOtherMetadata().isEmpty()); } + @Test + void regeneratePrimaryKeyForQIFDRKPISuccess() { + it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); + String subscriptionId = String.format("%s%s", Subscription.QI_FDR_KPI.getPrefixId(), institutionResponse.getTaxCode()); + InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); + + when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); + when(authorizerConfigClient.getAuthorization(anyString())) + .thenReturn(buildAuthorizationWithSegregationCodes(CI_TAX_CODE)); + when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); + when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenReturn(PSP_CODE_1, PSP_CODE_1); + when(legacyPspCodeUtil.retrievePspCode(TAX_CODE_1, false)).thenReturn(PSP_CODE_2); + when(externalApiClient.getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null)) + .thenReturn(createDelegations()); + + assertDoesNotThrow(() -> service.regeneratePrimaryKey(INSTITUTION_ID, subscriptionId)); + + verify(apimClient).regeneratePrimaryKey(subscriptionId); + verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); + verify(apimClient).getApiSubscriptions(INSTITUTION_ID); + verify(authorizerConfigClient).deleteAuthorization(AUTH_ID); + verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); + + Authorization captorValue = authorizationCaptor.getValue(); + assertNotNull(captorValue); + assertNotNull(captorValue.getAuthorizedEntities()); + assertEquals(3, captorValue.getAuthorizedEntities().size()); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> PSP_CODE_1.equals(elem.getValue()))); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> PSP_CODE_2.equals(elem.getValue()))); + assertNotNull(captorValue.getOtherMetadata()); + assertTrue(captorValue.getOtherMetadata().isEmpty()); + } + @Test void regeneratePrimaryKeyFailOnAuthorizerConfigUpdateTriggerAPIKeyRecreation() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA); @@ -736,11 +768,10 @@ void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(S verify(authorizerConfigClient, never()).createAuthorization(any()); } - @ParameterizedTest - @EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"}) - void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess(Subscription sub) { + @Test + void regenerateSecondaryKeyForFDRPSPSubscriptionThatRequirePSPCodeSuccess() { it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); - String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode()); + String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode()); InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); @@ -770,6 +801,39 @@ void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess(Subscription assertTrue(captorValue.getOtherMetadata().isEmpty()); } + @Test + void regenerateSecondaryKeyForQIFDRKPISubscriptionThatRequirePSPCodeSuccess() { + it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP); + String subscriptionId = String.format("%s%s", Subscription.QI_FDR_KPI.getPrefixId(), institutionResponse.getTaxCode()); + InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId); + + when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys)); + when(authorizerConfigClient.getAuthorization(anyString())) + .thenReturn(buildAuthorizationWithSegregationCodes(CI_TAX_CODE)); + when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse); + when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenReturn(PSP_CODE_1, PSP_CODE_1); + when(legacyPspCodeUtil.retrievePspCode(TAX_CODE_1, false)).thenReturn(PSP_CODE_2); + when(externalApiClient.getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null)) + .thenReturn(createDelegations()); + + assertDoesNotThrow(() -> service.regenerateSecondaryKey(INSTITUTION_ID, subscriptionId)); + + verify(apimClient).regenerateSecondaryKey(subscriptionId); + verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()); + verify(apimClient).getApiSubscriptions(INSTITUTION_ID); + verify(authorizerConfigClient).deleteAuthorization(AUTH_ID); + verify(authorizerConfigClient).createAuthorization(authorizationCaptor.capture()); + + Authorization captorValue = authorizationCaptor.getValue(); + assertNotNull(captorValue); + assertNotNull(captorValue.getAuthorizedEntities()); + assertEquals(3, captorValue.getAuthorizedEntities().size()); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> PSP_CODE_1.equals(elem.getValue()))); + assertTrue(captorValue.getAuthorizedEntities().stream().anyMatch(elem -> PSP_CODE_2.equals(elem.getValue()))); + assertNotNull(captorValue.getOtherMetadata()); + assertTrue(captorValue.getOtherMetadata().isEmpty()); + } + @ParameterizedTest @CsvSource({ "BO_EXT_EC, PA",