Skip to content

Commit

Permalink
Merge branch 'PAGOPA-1327-psp-whitelist' of
Browse files Browse the repository at this point in the history
https://github.com/pagopa/pagopa-afm-calculator into
PAGOPA-1327-psp-whitelist

Conflicts:
	helm/Chart.yaml
	helm/values-dev.yaml
	helm/values-prod.yaml
	helm/values-uat.yaml
	openapi/openapi-node.json
	openapi/openapi.json
	pom.xml
	src/test/resources/application.properties
  • Loading branch information
aacitelli committed Feb 7, 2024
2 parents 19f54e5 + 26ac509 commit ed9bfa2
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion integration-test/src/config/.env.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AFM_HOST=https://api.dev.platform.pagopa.it/afm/calculator-service/v1
ID_PSP_POSTE=BPPIITRRZZZ
AMEX_ABI=AMREX
AMEX_ABI=AMREX
PSP_WHITELIST=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019
1 change: 1 addition & 0 deletions integration-test/src/config/.env.local
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions integration-test/src/config/.env.prod
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
AFM_HOST=https://api.platform.pagopa.it/afm/calculator-service/v1
PSP_WHITELIST=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019

3 changes: 2 additions & 1 deletion integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AFM_HOST=https://api.uat.platform.pagopa.it/afm/calculator-service/v1
ID_PSP_POSTE=BPPIITRRXXX
AMEX_ABI=AMREX
AMEX_ABI=AMREX
PSP_WHITELIST=PPAYITR1XXX,BPPIITRRXXX,CIPBITMM,UNCRITMM,BNLIITRR,BCITITMM,BIC36019
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,6 +37,11 @@ public class CosmosRepository {

@Value("${pspPoste.id}")
private String pspPosteId;

@Value("#{'${psp.whitelist}'.split(',')}")
private List<String> pspWhitelist;

private static final String ID_PSP_PARAM = "idPsp";

/**
* @param ciFiscalCode fiscal code of the CI
Expand Down Expand Up @@ -136,9 +142,15 @@ private Iterable<ValidBundle> 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");
Expand Down Expand Up @@ -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()));
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}
3 changes: 3 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed9bfa2

Please sign in to comment.