Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nodo): CHK-1930 add apy-key for auth nodo ws #328

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ NODO_CONNECTION_TIMEOUT=10000
NODO_CONNECTION_STRING="{\"idPSP\":\"idPsp\",\"idChannel\":\"idChannel\",\"idBrokerPSP\":\"12345678912\",\"password\":\"password\"}"
NODO_PARALLEL_REQUESTS=5
NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED=false
NODO_NODEFORPSP_API_KEY=KEY
NODO_CLOSEPAYMENT_API_KEY=KEY

PAYMENT_TRANSACTIONS_GATEWAY_URI="http://pagopa-ecommerce-traefik/transactions-gateway"
PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT=10000
Expand Down
2 changes: 1 addition & 1 deletion .env.intellij.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AFM_CONNECTION_TIMEOUT=10000;AFM_KEY=key;AFM_READ_TIMEOUT=10000;AFM_URI=http://pagopa-gec-mock:3000/afm/node/calculator-service/v1/fees;CLOSURE_RETRY_INTERVAL=30;ECOMMERCE_PAYMENT_INSTRUMENTS_CONNECTION_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_READ_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_URI=http://pagopa-ecommerce-payment-methods-service:8083;ECOMMERCE_PAYMENT_METHODS_APY_KEY=payment-methods-key;ECOMMERCE_PAYMENT_METHODS_CONNECTION_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_READ_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_URI=http://localhost:3000;ECOMMERCE_STORAGE_TRANSIENT_CONNECTION_STRING=DefaultEndpointsProtocol=http\;AccountName=devstoreaccount1\;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==\;QueueEndpoint=http://storage:10001/devstoreaccount1;JWT_SECRET=ODMzNUZBNTZENDg3NTYyREUyNDhGNDdCRUZDNzI3NDMzMzQwNTFEREZGQ0MyQzA5Mjc1RjY2NTQ1NDk5MDMxNzU5NDc0NUVFMTdDMDhGNzk4Q0Q3RENFMEJBODE1NURDREExNEY2Mzk4QzFEMTU0NTExNjUyMEExMzMwMTdDMDk;JWT_TOKEN_VALIDITY_TIME_MILLIS=600000;LOGO_CARD_BRANDING_MAPPING={VISA:'https://dev.checkout.pagopa.it/assets/creditcard/carta_visa.png',MASTERCARD:'https://dev.checkout.pagopa.it/assets/creditcard/carta_mc.png',DINERS:'https://dev.checkout.pagopa.it/assets/creditcard/carta_diners.png',MAESTRO:'https://dev.checkout.pagopa.it/assets/creditcard/carta_maestro.png',AMEX:'https://dev.checkout.pagopa.it/assets/creditcard/carta_amex.png',UNKNOWN:'https://dev.checkout.pagopa.it/assets/creditcard/generic.png'};MONGO_HOST=pagopa-ecommerce-mongo;MONGO_PASSWORD=password;MONGO_PORT=27017;MONGO_USERNAME=admin;NODE_FOR_PSP_URI=/webservices/pof/PagamentiTelematiciPspNodoservice;NODO_CONNECTION_STRING={"idPSP":"idPsp","idChannel":"idChannel","idBrokerPSP":"12345678912","password":"password"};NODO_CONNECTION_TIMEOUT=10000;NODO_HOSTNAME=http://pagopa-node-mock:3002;NODO_PARALLEL_REQUESTS=5;NODO_READ_TIMEOUT=10000;NODOPERPM_CONNECTION_TIMEOUT=10000;NODOPERPM_READ_TIMEOUT=10000;NODOPERPM_URI=/nodo/nodo-per-pm/v1/informazioniPagamento;NOTIFICATIONS_SERVICE_API_KEY=api-key;NOTIFICATIONS_SERVICE_CONNECTION_TIMEOUT=10000;NOTIFICATIONS_SERVICE_READ_TIMEOUT=10000;NOTIFICATIONS_SERVICE_URI=http://pagopa-ecommerce-traefik/notifications-service;PAYMENT_TOKEN_VALIDITY_TIME=120;PAYMENT_TRANSACTIONS_GATEWAY_API_KEY=key;PAYMENT_TRANSACTIONS_GATEWAY_CONNECTION_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_URI=http://pagopa-ecommerce-traefik/transactions-gateway;PERSONAL_DATA_VAULT_API_BASE_PATH=http://pagopa-pdv-mock:8092;PERSONAL_DATA_VAULT_API_KEY=personal-data-vault-api-key;QueueEndpoint=http://storage:10001/devstoreaccount1;REDIS_HOST=pagopa-ecommerce-redis;REDIS_PASSWORD=redis_password;REDIS_PORT=6379;REDIS_SSL_ENABLED=false;TRANSACTION_CLOSE_PAYMENT_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-queue;TRANSACTION_CLOSE_PAYMENT_RETRY_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-retry-queue;TRANSACTION_EXPIRATION_QUEUE_NAME=pagopa-ecommerce-transactions-expiration-queue;TRANSACTION_NOTIFICATIONS_QUEUE_NAME=pagopa-ecommerce-transactions-notifications-queue;TRANSACTION_REFUND_QUEUE_NAME=pagopa-ecommerce-transactions-refund-queue;TRANSACTIONS_RETRY_OFFSET=60;NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED=false
AFM_CONNECTION_TIMEOUT=10000;AFM_KEY=key;AFM_READ_TIMEOUT=10000;AFM_URI=http://pagopa-gec-mock:3000/afm/node/calculator-service/v1/fees;CLOSURE_RETRY_INTERVAL=30;ECOMMERCE_PAYMENT_INSTRUMENTS_CONNECTION_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_READ_TIMEOUT=10000;ECOMMERCE_PAYMENT_INSTRUMENTS_URI=http://pagopa-ecommerce-payment-methods-service:8083;ECOMMERCE_PAYMENT_METHODS_APY_KEY=payment-methods-key;ECOMMERCE_PAYMENT_METHODS_CONNECTION_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_READ_TIMEOUT=600;ECOMMERCE_PAYMENT_METHODS_URI=http://localhost:3000;ECOMMERCE_STORAGE_TRANSIENT_CONNECTION_STRING=DefaultEndpointsProtocol=http\;AccountName=devstoreaccount1\;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==\;QueueEndpoint=http://storage:10001/devstoreaccount1;JWT_SECRET=ODMzNUZBNTZENDg3NTYyREUyNDhGNDdCRUZDNzI3NDMzMzQwNTFEREZGQ0MyQzA5Mjc1RjY2NTQ1NDk5MDMxNzU5NDc0NUVFMTdDMDhGNzk4Q0Q3RENFMEJBODE1NURDREExNEY2Mzk4QzFEMTU0NTExNjUyMEExMzMwMTdDMDk;JWT_TOKEN_VALIDITY_TIME_MILLIS=600000;LOGO_CARD_BRANDING_MAPPING={VISA:'https://dev.checkout.pagopa.it/assets/creditcard/carta_visa.png',MASTERCARD:'https://dev.checkout.pagopa.it/assets/creditcard/carta_mc.png',DINERS:'https://dev.checkout.pagopa.it/assets/creditcard/carta_diners.png',MAESTRO:'https://dev.checkout.pagopa.it/assets/creditcard/carta_maestro.png',AMEX:'https://dev.checkout.pagopa.it/assets/creditcard/carta_amex.png',UNKNOWN:'https://dev.checkout.pagopa.it/assets/creditcard/generic.png'};MONGO_HOST=pagopa-ecommerce-mongo;MONGO_PASSWORD=password;MONGO_PORT=27017;MONGO_USERNAME=admin;NODE_FOR_PSP_URI=/webservices/pof/PagamentiTelematiciPspNodoservice;NODO_CONNECTION_STRING={"idPSP":"idPsp","idChannel":"idChannel","idBrokerPSP":"12345678912","password":"password"};NODO_CONNECTION_TIMEOUT=10000;NODO_HOSTNAME=http://pagopa-node-mock:3002;NODO_PARALLEL_REQUESTS=5;NODO_READ_TIMEOUT=10000;NODO_NODEFORPSP_API_KEY=KEY;NODO_CLOSEPAYMENT_API_KEY=KEY;NODOPERPM_CONNECTION_TIMEOUT=10000;NODOPERPM_READ_TIMEOUT=10000;NODOPERPM_URI=/nodo/nodo-per-pm/v1/informazioniPagamento;NOTIFICATIONS_SERVICE_API_KEY=api-key;NOTIFICATIONS_SERVICE_CONNECTION_TIMEOUT=10000;NOTIFICATIONS_SERVICE_READ_TIMEOUT=10000;NOTIFICATIONS_SERVICE_URI=http://pagopa-ecommerce-traefik/notifications-service;PAYMENT_TOKEN_VALIDITY_TIME=120;PAYMENT_TRANSACTIONS_GATEWAY_API_KEY=key;PAYMENT_TRANSACTIONS_GATEWAY_CONNECTION_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT=10000;PAYMENT_TRANSACTIONS_GATEWAY_URI=http://pagopa-ecommerce-traefik/transactions-gateway;PERSONAL_DATA_VAULT_API_BASE_PATH=http://pagopa-pdv-mock:8092;PERSONAL_DATA_VAULT_API_KEY=personal-data-vault-api-key;QueueEndpoint=http://storage:10001/devstoreaccount1;REDIS_HOST=pagopa-ecommerce-redis;REDIS_PASSWORD=redis_password;REDIS_PORT=6379;REDIS_SSL_ENABLED=false;TRANSACTION_CLOSE_PAYMENT_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-queue;TRANSACTION_CLOSE_PAYMENT_RETRY_QUEUE_NAME=pagopa-ecommerce-transactions-close-payment-retry-queue;TRANSACTION_EXPIRATION_QUEUE_NAME=pagopa-ecommerce-transactions-expiration-queue;TRANSACTION_NOTIFICATIONS_QUEUE_NAME=pagopa-ecommerce-transactions-notifications-queue;TRANSACTION_REFUND_QUEUE_NAME=pagopa-ecommerce-transactions-refund-queue;TRANSACTIONS_RETRY_OFFSET=60;NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED=false
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ These are all environment variables needed by the application:
| NODO_READ_TIMEOUT | | Timeout for requests towards Nodo | number | |
| NODO_CONNECTION_TIMEOUT | | Timeout for establishing connections towards Nodo | number | |
| NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED | | Flag to enable light check for allCCP. If true it checks only all transfers' iban. If false, it checks also metadata | boolean | |
| NODO_NODEFORPSP_API_KEY | | API Key for NODE FOR PSP WS | string | |
| NODO_CLOSEPAYMENT_API_KEY | | API Key for Nodo closePayment API | string | |
| ECOMMERCE_PAYMENT_METHODS_URI | | eCommerce payment methods service connection URI | string | |
| ECOMMERCE_PAYMENT_METHODS_READ_TIMEOUT | | Timeout for requests towards eCommerce payment methods service | number | |
| ECOMMERCE_PAYMENT_METHODS_CONNECTION_TIMEOUT | | Timeout for establishing connections towards eCommerce payment methods service | number | |
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.dev.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing NODO_NODEFORPSP_API_KEY and NODO_CLOSEPAYMENT_API_KEY env secrets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down
4 changes: 2 additions & 2 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down Expand Up @@ -147,7 +147,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down
4 changes: 2 additions & 2 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.uat.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down Expand Up @@ -146,7 +146,7 @@ microservice-chart:
REDIS_PORT: "6380"
REDIS_SSL_ENABLED: "true"
NODO_HOSTNAME: https://api.uat.platform.pagopa.it
NODE_FOR_PSP_URI: /nodo/node-for-psp/v1
NODE_FOR_PSP_URI: /nodo-auth/node-for-psp/v1
NODO_READ_TIMEOUT: "10000"
NODO_CONNECTION_TIMEOUT: "10000"
NODO_PARALLEL_REQUESTS: "5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class NodeForPspClient {
@Value("${nodo.nodeforpsp.uri}")
private String nodoPerPspUri;

@Value("${nodo.nodeforpsp.apikey}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here we can refactor this class to use constructor injection? what do you think? this way we can avoid reflection to set those api key into test class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but better to do it in a dedicated PR

private String nodoPerPspApiKey;

@Value("${nodo.closepayment.apikey}")
private String nodoClosePaymentApiKey;

public Mono<ActivatePaymentNoticeV2Response> activatePaymentNoticeV2(
JAXBElement<ActivatePaymentNoticeV2Request> request
) {
Expand All @@ -41,6 +47,7 @@ public Mono<ActivatePaymentNoticeV2Response> activatePaymentNoticeV2(
.uri(nodoPerPspUri)
.header("Content-Type", MediaType.TEXT_XML_VALUE)
.header("SOAPAction", "activatePaymentNoticeV2")
.header("ocp-apim-subscription-key", nodoPerPspApiKey)
.body(Mono.just(new SoapEnvelope("", request)), SoapEnvelope.class)
.retrieve()
.onStatus(
Expand Down Expand Up @@ -81,10 +88,11 @@ public Mono<ClosePaymentResponseDto> closePaymentV2(ClosePaymentRequestV2Dto req
);
return nodoWebClient.post()
.uri(
uriBuilder -> uriBuilder.path("/nodo/nodo-per-pm/v2/closepayment")
uriBuilder -> uriBuilder.path("/nodo-auth/nodo-per-pm/v2/closepayment")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would parameterized (maybe in another PR) this path in order to change it's value upgrading helm instead of modifying code. What do you think?

.queryParam("clientId", CLOSE_PAYMENT_CLIENT_ID).build()
)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header("ocp-apim-subscription-key", nodoClosePaymentApiKey)
.body(Mono.just(request), ClosePaymentRequestV2Dto.class)
.retrieve()
.onStatus(
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ nodo.connectionTimeout=${NODO_CONNECTION_TIMEOUT}
nodo.connection.string=${NODO_CONNECTION_STRING}
nodo.parallelRequests=${NODO_PARALLEL_REQUESTS}
nodo.allCCPOnTransferIbanEnabled=${NODO_ALL_CCP_ON_TRANSFER_IBAN_ENABLED}

nodo.nodeforpsp.apikey=${NODO_NODEFORPSP_API_KEY}
nodo.closepayment.apikey=${NODO_CLOSEPAYMENT_API_KEY}
paymentTransactionsGateway.uri=${PAYMENT_TRANSACTIONS_GATEWAY_URI}/
paymentTransactionsGateway.readTimeout=${PAYMENT_TRANSACTIONS_GATEWAY_READ_TIMEOUT}
paymentTransactionsGateway.connectionTimeout=${PAYMENT_TRANSACTIONS_GATEWAY_CONNECTION_TIMEOUT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec;
import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec;
Expand Down Expand Up @@ -59,6 +60,8 @@ class NodeForPspClientTest {
@Mock
private ResponseSpec responseSpec;

private String nodoClosePaymentApiKey = "key";

@Test
void shouldReturnActivatePaymentResponseGivenValidPaymentNoticeTest() {

Expand Down Expand Up @@ -196,6 +199,8 @@ void shouldReturnResponseStatusExceptionOnActivatev2() {

@Test
void shouldReturnOKClosePaymentResponse() {
ReflectionTestUtils.setField(client, "nodoClosePaymentApiKey", "key");

ClosePaymentRequestV2Dto closePaymentRequest = new ClosePaymentRequestV2Dto()
.paymentTokens(List.of("paymentToken"))
.outcome(ClosePaymentRequestV2Dto.OutcomeEnum.OK)
Expand All @@ -214,6 +219,7 @@ void shouldReturnOKClosePaymentResponse() {
/* preconditions */
when(nodoWebClient.post()).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(MediaType.APPLICATION_JSON_VALUE))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(nodoClosePaymentApiKey))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.uri(any(Function.class))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.body(any(), eq(ClosePaymentRequestV2Dto.class))).thenReturn(requestHeadersSpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
Expand All @@ -228,6 +234,8 @@ void shouldReturnOKClosePaymentResponse() {

@Test
void shouldReturnOKClosePaymentResponseAdditionalInfo() {
ReflectionTestUtils.setField(client, "nodoClosePaymentApiKey", "key");

AdditionalPaymentInformationsDto additionalPaymentInformationsDto = new AdditionalPaymentInformationsDto()
.outcomePaymentGateway(AdditionalPaymentInformationsDto.OutcomePaymentGatewayEnum.OK)
.totalAmount(new BigDecimal((101)).toString())
Expand Down Expand Up @@ -255,6 +263,8 @@ void shouldReturnOKClosePaymentResponseAdditionalInfo() {
/* preconditions */
when(nodoWebClient.post()).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(MediaType.APPLICATION_JSON_VALUE))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(nodoClosePaymentApiKey))).thenReturn(requestBodyUriSpec);

when(requestBodyUriSpec.uri(any(Function.class))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.body(any(), eq(ClosePaymentRequestV2Dto.class))).thenReturn(requestHeadersSpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
Expand All @@ -269,6 +279,8 @@ void shouldReturnOKClosePaymentResponseAdditionalInfo() {

@Test
void shouldReturnKOClosePaymentResponse() {
ReflectionTestUtils.setField(client, "nodoClosePaymentApiKey", "key");

ClosePaymentRequestV2Dto closePaymentRequest = new ClosePaymentRequestV2Dto()
.paymentTokens(List.of("paymentToken"))
.outcome(ClosePaymentRequestV2Dto.OutcomeEnum.OK)
Expand All @@ -287,6 +299,7 @@ void shouldReturnKOClosePaymentResponse() {
/* preconditions */
when(nodoWebClient.post()).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(MediaType.APPLICATION_JSON_VALUE))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(nodoClosePaymentApiKey))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.uri(any(Function.class))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.body(any(), eq(ClosePaymentRequestV2Dto.class))).thenReturn(requestHeadersSpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
Expand All @@ -301,6 +314,8 @@ void shouldReturnKOClosePaymentResponse() {

@Test
void shouldMapClosePaymentErrorToBadGatewayException() {
ReflectionTestUtils.setField(client, "nodoClosePaymentApiKey", "key");

ClosePaymentRequestV2Dto closePaymentRequest = new ClosePaymentRequestV2Dto()
.paymentTokens(List.of("paymentToken"))
.outcome(ClosePaymentRequestV2Dto.OutcomeEnum.OK)
Expand All @@ -319,6 +334,7 @@ void shouldMapClosePaymentErrorToBadGatewayException() {
/* preconditions */
when(nodoWebClient.post()).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(MediaType.APPLICATION_JSON_VALUE))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(any(), eq(nodoClosePaymentApiKey))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.uri(any(Function.class))).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.body(any(), eq(ClosePaymentRequestV2Dto.class))).thenReturn(requestHeadersSpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/application-tests.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ nodo.retry=2
nodo.connection.string={"idPSP":"idPsp","idChannel":"idChannel","idBrokerPSP":"idBrokerPSP","password":"password"}
nodo.parallelRequests=5
nodo.allCCPOnTransferIbanEnabled=true
nodo.nodeforpsp.apikey=KEY
nodo.closepayment.apikey=KEY

nodoPerPM.uri=https://localhost/nodo/informazioniPagamento
nodoPerPM.readTimeout=10000
Expand Down