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
diff --git a/helm/Chart.yaml b/helm/Chart.yaml
index 6cf099d97..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.435.0
-appVersion: "2.32.2-1-next"
+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 e7ed54c3d..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.32.2-1-next"
+ tag: "2.34.1"
pullPolicy: Always
livenessProbe:
httpGet:
@@ -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 bcf96c6ad..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.32.2-1-next" #improve
+ tag: "2.34.1" #improve
pullPolicy: Always
livenessProbe:
httpGet:
@@ -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 5e935debe..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.32.2-1-next" #improve
+ tag: "2.34.1" #improve
pullPolicy: Always
livenessProbe:
httpGet:
@@ -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/openapi/openapi.json b/openapi/openapi.json
index 1adb50a8b..2494c72e5 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-1-next"
+ "version": "2.34.1"
},
"servers": [
{
@@ -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
diff --git a/pom.xml b/pom.xml
index 68a80e02b..b11cbb9ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
2.5.14
pagopa-selfcare-ms-backoffice
- 2.32.2-1-next
+ 2.34.1
SelfCare Backoffice
Microservice to manage PagoPA Backoffice
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..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
@@ -34,6 +34,8 @@ public class AwsSesClient {
private final String environment;
+ private final Boolean enableSendEmail;
+
private final String testEmailAddress;
private final String pagopaOperatorEmailAddress;
@@ -46,8 +48,8 @@ public AwsSesClient(
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;
@@ -55,6 +57,7 @@ public AwsSesClient(
this.environment = environment;
this.testEmailAddress = testEmailAddress;
this.pagopaOperatorEmailAddress = pagopaOperatorEmailAddress;
+ this.enableSendEmail = enableSendEmail;
}
/**
@@ -72,7 +75,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;
}
@@ -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()))
@@ -132,7 +136,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 +162,11 @@ 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 isNotProd() {
+ return !this.environment.equals("PROD");
}
- 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/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..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,10 +24,11 @@ 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", 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),
- 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;
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/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/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);
}
}
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..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
@@ -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.QI_FDR_KPI)) {
try {
value = this.legacyPspCodeUtil.retrievePspCode(taxCode, false);
} catch (Exception e) {
@@ -560,6 +560,13 @@ private AuthorizationConfig getAuthorizationConfig(
authorizationMetadata = buildAuthorizationMetadata(ciSegregationCodes);
}
}
+ 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())
+ .value(institution.getTaxCode())
+ .build());
+ }
return new AuthorizationConfig(authorizationEntities, authorizationMetadata);
}
@@ -592,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.QI_FDR_KPI))
+ && !InstitutionType.PT.equals(institution.getInstitutionType());
}
}
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 04d06edba..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
*/
@@ -363,8 +376,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 +401,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));
}
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/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/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 f9fb067e1..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
@@ -48,6 +48,7 @@ class AwsSesClientTest {
@Test
void sendEmailPRODSuccess() {
+ ReflectionTestUtils.setField(sut, "enableSendEmail", true);
ReflectionTestUtils.setField(sut, "environment", "PROD");
Institutions institutions = buildInstitutions();
@@ -68,7 +69,8 @@ void sendEmailPRODSuccess() {
@Test
void sendEmailNotPRODSuccess() {
- ReflectionTestUtils.setField(sut, "environment", "DEV");
+ 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());
@@ -86,6 +88,7 @@ void sendEmailNotPRODSuccess() {
@Test
void sendEmailPRODFail() {
+ ReflectionTestUtils.setField(sut, "enableSendEmail", true);
ReflectionTestUtils.setField(sut, "environment", "PROD");
Institutions institutions = buildInstitutions();
@@ -106,8 +109,9 @@ void sendEmailPRODFail() {
@Test
void sendEmailPRODNoInstitutionTaxCodeSkipped() {
- ReflectionTestUtils.setField(sut, "environment", "PROD");
+ ReflectionTestUtils.setField(sut, "enableSendEmail", true);
ReflectionTestUtils.setField(sut, "testEmailAddress", "test@mail.it");
+ ReflectionTestUtils.setField(sut, "environment", "PROD");
assertDoesNotThrow(() -> sut.sendEmail(buildEmailMessageDetail(null)));
@@ -124,6 +128,7 @@ void sendEmailPRODNoInstitutionTaxCodeSkipped() {
@Test
void sendEmailNoInstitutionFoundSkipped() {
+ ReflectionTestUtils.setField(sut, "enableSendEmail", true);
ReflectionTestUtils.setField(sut, "environment", "PROD");
when(externalApiClient.getInstitutionsFiltered(INSTITUTION_TAX_CODE))
@@ -143,6 +148,7 @@ void sendEmailNoInstitutionFoundSkipped() {
@Test
void sendEmailNoDestinationSkipped() {
+ ReflectionTestUtils.setField(sut, "enableSendEmail", true);
ReflectionTestUtils.setField(sut, "environment", "PROD");
Institutions institutions = buildInstitutions();
@@ -163,8 +169,9 @@ void sendEmailNoDestinationSkipped() {
@Test
void sendEmailNotPRODAndNoTestEmailSkipped() {
- ReflectionTestUtils.setField(sut, "environment", "DEV");
+ ReflectionTestUtils.setField(sut, "enableSendEmail", false);
ReflectionTestUtils.setField(sut, "testEmailAddress", null);
+ ReflectionTestUtils.setField(sut, "environment", "UAT");
assertDoesNotThrow(() -> sut.sendEmail(buildEmailMessageDetail(INSTITUTION_TAX_CODE)));
@@ -181,6 +188,7 @@ void sendEmailNotPRODAndNoTestEmailSkipped() {
@Test
void sendEmailPRODSWithPagopaOperatorSuccess() {
+ ReflectionTestUtils.setField(sut, "enableSendEmail", true);
ReflectionTestUtils.setField(sut, "environment", "PROD");
Institutions institutions = buildInstitutions();
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..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
@@ -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;
@@ -40,7 +43,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;
@@ -211,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());
@@ -313,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());
@@ -358,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());
@@ -378,17 +385,28 @@ 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
- 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);
@@ -399,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());
@@ -425,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", "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());
@@ -489,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);
@@ -507,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));
@@ -541,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", "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);
@@ -596,57 +618,73 @@ void regeneratePrimaryKeyForFDRPSPSuccess() {
}
@Test
- void regeneratePrimaryKeyFailOnAuthorizerConfigUpdateTriggerAPIKeyRecreation() {
- it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PA);
- String subscriptionId = String.format("%s%s", Subscription.GPD.getPrefixId(), institutionResponse.getTaxCode());
+ 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))
- .thenReturn(Collections.singletonList(institutionApiKeys));
+ when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys));
when(authorizerConfigClient.getAuthorization(anyString()))
- .thenThrow(FeignException.NotFound.class)
- .thenReturn(Authorization.builder().id(AUTH_ID).build());
+ .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());
- when(apiConfigSelfcareIntegrationClient.getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()))
- .thenReturn(buildCreditorInstitutionStationSegregationCodesList());
assertDoesNotThrow(() -> service.regeneratePrimaryKey(INSTITUTION_ID, subscriptionId));
verify(apimClient).regeneratePrimaryKey(subscriptionId);
+ verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString());
verify(apimClient).getApiSubscriptions(INSTITUTION_ID);
- verify(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean());
- verify(authorizerConfigClient).createAuthorization(any());
- verify(authorizerConfigClient, never()).deleteAuthorization(anyString());
+ 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 regeneratePrimaryKeyForBOExtEC() {
+ void regeneratePrimaryKeyFailOnAuthorizerConfigUpdateTriggerAPIKeyRecreation() {
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());
+ String subscriptionId = String.format("%s%s", Subscription.GPD.getPrefixId(), institutionResponse.getTaxCode());
InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId);
+ when(apimClient.getApiSubscriptions(anyString()))
+ .thenReturn(Collections.singletonList(institutionApiKeys))
+ .thenReturn(Collections.singletonList(institutionApiKeys));
+ when(authorizerConfigClient.getAuthorization(anyString()))
+ .thenThrow(FeignException.NotFound.class)
+ .thenReturn(Authorization.builder().id(AUTH_ID).build());
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());
+ when(externalApiClient.getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null))
+ .thenReturn(createDelegations());
+ when(apiConfigSelfcareIntegrationClient.getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString()))
+ .thenReturn(buildCreditorInstitutionStationSegregationCodesList());
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(authorizerConfigClient).createAuthorization(any());
- verify(externalApiClient, never()).getBrokerDelegation(null, INSTITUTION_ID, "prod-pagopa", "FULL", null);
- verify(apiConfigSelfcareIntegrationClient, never()).getCreditorInstitutionsSegregationCodeAssociatedToBroker(anyString());
+ verify(authorizerConfigClient, never()).deleteAuthorization(anyString());
}
- @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());
+ @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);
@@ -659,15 +697,24 @@ 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
- 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);
@@ -699,10 +746,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", "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);
@@ -721,7 +769,7 @@ void regenerateSecondaryKeyForFDRPSPFailNoPSPCode() {
}
@Test
- void regenerateSecondaryKeyForFDRPSPSuccess() {
+ void regenerateSecondaryKeyForFDRPSPSubscriptionThatRequirePSPCodeSuccess() {
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());
InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId);
@@ -754,30 +802,46 @@ void regenerateSecondaryKeyForFDRPSPSuccess() {
}
@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());
+ 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(apimClient.getApiSubscriptions(any())).thenReturn(Collections.singletonList(institutionApiKeys));
- when(authorizerConfigClient.getAuthorization(anyString())).thenReturn(Authorization.builder().id(AUTH_ID).build());
+ 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(legacyPspCodeUtil, never()).retrievePspCode(anyString(), anyBoolean());
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(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 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);
@@ -790,9 +854,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
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