diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 786beacb..aa24099a 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: pagopa-afm-calculator description: Microservice that handles calculation for pagoPA Advanced Fees Management type: application -version: 2.14.0 +version: 2.15.0 appVersion: 2.10.4 dependencies: - name: microservice-chart diff --git a/integration-test/src/config/.env.dev b/integration-test/src/config/.env.dev index f725d14a..37739694 100644 --- a/integration-test/src/config/.env.dev +++ b/integration-test/src/config/.env.dev @@ -1,3 +1,4 @@ AFM_HOST=https://api.dev.platform.pagopa.it/afm/calculator-service/v1 ID_PSP_POSTE=BPPIITRRZZZ -AMEX_ABI=AMREX \ No newline at end of file +AMEX_ABI=AMREX +PSP_WHITELIST=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019 \ No newline at end of file diff --git a/integration-test/src/config/.env.local b/integration-test/src/config/.env.local index 40f1e681..c11eb550 100644 --- a/integration-test/src/config/.env.local +++ b/integration-test/src/config/.env.local @@ -1,3 +1,4 @@ AFM_HOST=http://localhost:8080 ID_PSP_POSTE=BPPIITRRZZZ AMEX_ABI=AMREX +PSP_WHITELIST=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019 diff --git a/integration-test/src/config/.env.prod b/integration-test/src/config/.env.prod index 85583d34..5a6d6e90 100644 --- a/integration-test/src/config/.env.prod +++ b/integration-test/src/config/.env.prod @@ -1,2 +1,3 @@ AFM_HOST=https://api.platform.pagopa.it/afm/calculator-service/v1 +PSP_WHITELIST=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019 diff --git a/integration-test/src/config/.env.uat b/integration-test/src/config/.env.uat index dd945b24..2ed1e555 100644 --- a/integration-test/src/config/.env.uat +++ b/integration-test/src/config/.env.uat @@ -1,3 +1,4 @@ AFM_HOST=https://api.uat.platform.pagopa.it/afm/calculator-service/v1 ID_PSP_POSTE=BPPIITRRXXX -AMEX_ABI=AMREX \ No newline at end of file +AMEX_ABI=AMREX +PSP_WHITELIST=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019 \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/afm/calculator/repository/CosmosRepository.java b/src/main/java/it/gov/pagopa/afm/calculator/repository/CosmosRepository.java index 1146bb4e..80c541be 100644 --- a/src/main/java/it/gov/pagopa/afm/calculator/repository/CosmosRepository.java +++ b/src/main/java/it/gov/pagopa/afm/calculator/repository/CosmosRepository.java @@ -19,6 +19,7 @@ import org.springframework.cache.annotation.Cacheable; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Repository; +import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; @@ -36,6 +37,11 @@ public class CosmosRepository { @Value("${pspPoste.id}") private String pspPosteId; + + @Value("#{'${psp.whitelist}'.split(',')}") + private List pspWhitelist; + + private static final String ID_PSP_PARAM = "idPsp"; /** * @param ciFiscalCode fiscal code of the CI @@ -136,9 +142,15 @@ private Iterable findValidBundles(PaymentOption paymentOption, bool // add filter for Poste bundles if (!allCcp) { - var allCcpFilter = isNotEqual("idPsp", pspPosteId); + var allCcpFilter = isNotEqual(ID_PSP_PARAM, pspPosteId); queryResult = and(queryResult, allCcpFilter); } + + // add filter for PSP whitelist + if (!CollectionUtils.isEmpty(pspWhitelist)) { + var pspIn = in(ID_PSP_PARAM, pspWhitelist); + queryResult = and(queryResult, pspIn); + } // execute the query return cosmosTemplate.find(new CosmosQuery(queryResult), ValidBundle.class, "validbundles"); @@ -230,7 +242,7 @@ private Criteria getPspFilterCriteria( Criteria queryTmp = null; while (iterator.hasNext()) { var pspSearch = iterator.next(); - var queryItem = isEqual("idPsp", pspSearch.getIdPsp()); + var queryItem = isEqual(ID_PSP_PARAM, pspSearch.getIdPsp()); if (StringUtils.isNotEmpty(pspSearch.getIdChannel())) { queryItem = and(queryItem, isEqual("idChannel", pspSearch.getIdChannel())); } diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 06806e86..f395d75c 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -26,3 +26,6 @@ pspPoste.id=BPPIITRRZZZ # AMEX (American Express) payment ABI pspAmex.abi=AMREX + +# PSP whitelist to manage which bundles must be filtered +psp.whitelist=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4b13cd25..55745ec4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -55,3 +55,6 @@ pspPoste.id=${ID_PSP_POSTE} # AMEX (American Express) payment ABI pspAmex.abi=${AMEX_ABI} + +# PSP whitelist to manage which bundles must be filtered +psp.whitelist=${PSP_WHITELIST} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index dee92202..04804de0 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -43,6 +43,9 @@ payment.amount.threshold=0 # PSP Poste pspPoste.id=testIdPspPoste +# PSP whitelist to manage which bundles must be filtered +psp.whitelist=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019 + # Openapi springdoc.writer-with-order-by-keys=false springdoc.writer-with-default-pretty-printer=true