Skip to content

Commit

Permalink
Merge branch 'main' into NOD-793-dismissione-wisp-converter-gestione-…
Browse files Browse the repository at this point in the history
…pagina-html-errore
  • Loading branch information
andrea-deri committed Apr 15, 2024
2 parents 3ea4f7d + e8037e6 commit d3e6b2b
Show file tree
Hide file tree
Showing 31 changed files with 50 additions and 43 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pagoPA WISP Converter

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TODO-set-your-id&metric=alert_status)](https://sonarcloud.io/dashboard?id=TODO-set-your-id)
[![Integration Tests](https://github.com/pagopa/<TODO-repo>/actions/workflows/integration_test.yml/badge.svg?branch=main)](https://github.com/pagopa/<TODO-repo>/actions/workflows/integration_test.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pagopa_pagopa-wisp-converter&metric=alert_status)](https://sonarcloud.io/dashboard?id=pagopa_pagopa-wisp-converter)
[![Integration Tests](https://github.com/pagopa/pagopa-wisp-converter/actions/workflows/integration_test.yml/badge.svg?branch=main)](https://github.com/pagopa/pagopa-wisp-converter/actions/workflows/integration_test.yml)

A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing
them with GPD system
Expand Down Expand Up @@ -59,7 +59,13 @@ To run the **Junit** tests:

#### Integration testing

From `./integration-test/src`
For automatic execution of simple tests for checking the correct workflow between the various components, execute the
following commands from `./integration-test/system-test`:

`sh run.sh dev TESTCASE SUBKEY`

A more wide information about this test can be found in Readme file in the same folder.
For classical integration tests with Cucumber, execute the following commands from `./integration-test/cucumber/src`:

1. `yarn install`
2. `yarn test`
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-wisp-converter
description: A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing them with GPD system
type: application
version: 0.16.0
appVersion: 0.0.10
version: 0.20.0
appVersion: 0.0.11
dependencies:
- name: microservice-chart
version: 3.0.0
Expand Down
6 changes: 3 additions & 3 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.0.10"
tag: "0.0.11"
pullPolicy: Always
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 90
initialDelaySeconds: 180
failureThreshold: 6
periodSeconds: 10
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 90
initialDelaySeconds: 180
failureThreshold: 6
periodSeconds: 10
deployment:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.0.10"
tag: "0.0.11"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-wisp-converter
tag: "0.0.10"
tag: "0.0.11"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions integration-test/system-test/src/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.5.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wisp_converter_soap_host=https://api.dev.platform.pagopa.it/wisp-soap-converter/soap/v1
wisp_converter_soap_host=https://api.dev.platform.pagopa.it/nodo-auth/nodo-per-pa/v1

// temporary
wisp_converter_host=https://dev.wisp2.pagopa.it/wisp-converter/redirect/api/v1/payments?sessionId
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function call(method, url, body, headers) {
}

async function get(url, headers) {
return await axios.get(url, headers)
return await axios.get(url, { headers: headers })
.then(res => {
return res;
})
Expand All @@ -26,7 +26,7 @@ async function get(url, headers) {
}

async function post(url, body, headers) {
return await axios.post(url, body, headers)
return await axios.post(url, body, { headers: headers })
.then(res => {
return res;
})
Expand All @@ -36,7 +36,7 @@ async function post(url, body, headers) {
}

async function put(url, body, headers) {
return await axios.put(url, body, headers)
return await axios.put(url, body, { headers: headers })
.then(res => {
return res;
})
Expand All @@ -46,7 +46,7 @@ async function put(url, body, headers) {
}

async function del(url, headers) {
return await axios.delete(url, headers)
return await axios.delete(url, { headers: headers })
.then(res => {
return res;
})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ const {DOMParser} = require('xmldom');
const {env} = require("dotenv");


const nodoInviaRPTPrimitive = "NodoInviaRPT";
const nodoInviaCarrelloRPTPrimitive = "NodoInviaCarrelloRPT";
const nodoInviaRPTPrimitive = "nodoInviaRPT";
const nodoInviaCarrelloRPTPrimitive = "nodoInviaCarrelloRPT";

const file = process.argv[2];
const subkey = process.argv[3];

console.log("Executing test case [", file, "]");
main();


Expand All @@ -19,36 +21,37 @@ async function main() {
let request = getRequest();
let responseFromSOAPConverter = await callWispSoapConverter(request);

if (responseFromSOAPConverter.status !== 200) {
console.log('Error [', responseFromSOAPConverter.data, ']\n=====================\n');
return;
}

const parser = new DOMParser();
const xmlDoc = parser.parseFromString(responseFromSOAPConverter.data, "text/xml");
const outcome = xmlDoc.getElementsByTagName("esito")[0].textContent;
console.log('==Response:==\nStatus: [', responseFromSOAPConverter.status, ']\n=====================\n');


let url = "";
let isOK = false;
if (outcome === "OK") {
isOK = true;
url = xmlDoc.getElementsByTagName("url")[0].textContent;
} else {
const faultCode = xmlDoc.getElementsByTagName("faultCode")[0].textContent;
const description = xmlDoc.getElementsByTagName("description")[0].textContent;
console.log('Error [', faultCode, ']: ', description, "\n=====================\n");
return;
}

if (isOK) {
// temporary replacement
url = url.replace(/http:\/\/adapterecommerce\.pagopa\.it\?idSession/g, process.env.wisp_converter_host);
// temporary replacement
url = url.replace(/http:\/\/adapterecommerce\.pagopa\.it\?idSession/g, process.env.wisp_converter_host);

console.log('Calling WISP Converter at URL [', url, ']\n=====================\n');
let responseFromConverter = await call("GET", url, {});
console.log('Calling WISP Converter at URL [', url, ']\n=====================\n');
let responseFromConverter = await call("GET", url, {});

console.log('==Response:==\nStatus: [', responseFromConverter.status, ']\n');
if (responseFromConverter.status !== 200) {
console.log(responseFromConverter.data);
}
console.log('\n=====================\n');
console.log('==Response:==\nStatus: [', responseFromConverter.status, ']\n');
if (responseFromConverter.status !== 200) {
console.log(responseFromConverter.data);
}
console.log('\n=====================\n');
}

function getRequest() {
Expand All @@ -68,10 +71,12 @@ function getRequest() {
}

async function callWispSoapConverter(request) {
console.log('==Request:==\nContent: ', request[1], "\n=====================\n");
let url = process.env.wisp_converter_soap_host;
let headers = {
"SOAPAction": request[0],
"Ocp-Apim-Subscription-Key": subkey
"Ocp-Apim-Subscription-Key": `${subkey};product=nodo-auth-wisp`
}
console.log('==Request:==\nURL: [', url, ']\nContent: ', request[1], "\nHeaders: ", headers, "\n=====================\n");
return await call("POST", process.env.wisp_converter_soap_host, request[1], headers);
}
}

2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments.\n\n**STANDARD ERRORS:**\nNAME | CODE | DESCRIPTION\n- | - | -\n**WIC-500** | *ERROR* | *...error description...*\n**WIC-1000** | *GENERIC_ERROR* | Error while executing conversion flow. *...error description...*\n**WIC-1001** | *PARSING_GENERIC_ERROR* | Error while parsing payload. *...error description...*\n**WIC-1002** | *PARSING_INVALID_HEADER* | Error while parsing payload. The SOAP header in payload is invalid: *...error description...*\n**WIC-1003** | *PARSING_INVALID_BODY* | Error while parsing payload. The SOAP body in payload is invalid: *...error description...*\n**WIC-1004** | *PARSING_INVALID_XML_NODES* | Error while parsing payload. The list of nodes extracted from document must be greater than zero, but currently it is zero.\n**WIC-1005** | *PARSING_INVALID_ZIPPED_PAYLOAD* | Error while parsing payload. Cannot unzip payload correctly.\n**WIC-1006** | *PARSING_PRIMITIVE_NOT_VALID* | Error while checking primitive. Primitive [*...content...*] not valid.\n**WIC-1100** | *VALIDATION_INVALID_MULTIBENEFICIARY_CART* | Error while generating debt position for GPD service. The cart is defined as multi-beneficiary but there are a number of RPTs lower than 2.\n**WIC-1101** | *VALIDATION_INVALID_IBANS* | Error while generating debt position for GPD service. The IBAN field must be set if digital stamp is not defined for the transfer.\n**WIC-1102** | *VALIDATION_INVALID_DEBTOR* | Error while generating debt position for GPD service. The debtor subject information is different between the various RPT of the cart.\n**WIC-1103** | *VALIDATION_INVALID_CREDITOR_INSTITUTION* | Error while generating debt position for GPD service. The creditor institution information is different between the various RPT of the cart.\n**WIC-1200** | *CONFIGURATION_INVALID_STATION* | Error while generating cart for Checkout service. No valid station found with code [*...content...*].\n**WIC-1201** | *CONFIGURATION_INVALID_STATION_REDIRECT_URL* | Error while generating cart for Checkout service. The station with code [*...content...*] contains wrong redirect URL and it is not possible to generate valid URI.\n**WIC-2000** | *PERSISTENCE_RPT_NOT_FOUND* | Error while retrieving RPT. RPT with sessionId [*...content...*] not found.\n**WIC-2001** | *PERSISTENCE_REQUESTID_CACHING_ERROR* | Error while caching RequestID. *...error description...*\n**WIC-3000** | *CLIENT_APICONFIGCACHE* | Error while communicating with APIConfig cache service. *...error description...*\n**WIC-3001** | *CLIENT_GPD* | Error while communicating with GPD service. *...error description...*\n**WIC-3002** | *CLIENT_IUVGENERATOR* | Error while communicating with IUV Generator service. *...error description...*\n**WIC-3003** | *CLIENT_DECOUPLER_CACHING* | Error while communicating with decoupler caching API. *...error description...*\n**WIC-3004** | *CLIENT_CHECKOUT* | Error while communicating with Checkout service. *...error description...*\n**WIC-3005** | *CLIENT_CHECKOUT_NO_REDIRECT_LOCATION* | Error while communicating with Checkout service. No valid 'Location' header was found,\n**WIC-3006** | *CLIENT_CHECKOUT_INVALID_REDIRECT_LOCATION* | Error while communicating with Checkout service. An empty 'Location' header was found.\n",
"termsOfService": "https://www.pagopa.gov.it/",
"title": "WISP Converter",
"version": "0.0.10"
"version": "0.0.11"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>wisp-converter</artifactId>
<version>0.0.10</version>
<version>0.0.11</version>
<name>pagoPA WISP Converter</name>
<description>A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
@RequiredArgsConstructor
public class CacheService {

private static final String COMPOSITE_TWOVALUES_KEY_TEMPLATE = "%s_%s";

private static final String CACHING_KEY_TEMPLATE = "wisp_" + COMPOSITE_TWOVALUES_KEY_TEMPLATE;
private static final String CACHING_KEY_TEMPLATE = "wisp_%s_%s";

private final it.gov.pagopa.gen.wispconverter.client.decouplercaching.invoker.ApiClient decouplerCachingClient;

Expand All @@ -43,7 +41,7 @@ public void storeRequestMappingInCache(CommonRPTFieldsDTO commonRPTFieldsDTO, St

// communicating with APIM policy for caching data for decoupler
it.gov.pagopa.gen.wispconverter.client.decouplercaching.model.DecouplerCachingKeysDto decouplerCachingKeys = new it.gov.pagopa.gen.wispconverter.client.decouplercaching.model.DecouplerCachingKeysDto();
noticeNumbers.forEach(noticeNumber -> decouplerCachingKeys.addKeysItem(String.format(COMPOSITE_TWOVALUES_KEY_TEMPLATE, creditorInstitutionId, noticeNumber)));
noticeNumbers.forEach(noticeNumber -> decouplerCachingKeys.addKeysItem(String.format(CACHING_KEY_TEMPLATE, creditorInstitutionId, noticeNumber)));
it.gov.pagopa.gen.wispconverter.client.decouplercaching.api.DefaultApi apiInstance = new it.gov.pagopa.gen.wispconverter.client.decouplercaching.api.DefaultApi(decouplerCachingClient);
apiInstance.saveMapping(decouplerCachingKeys, MDC.get(Constants.MDC_REQUEST_ID));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.gov.pagopa.wispconverter.service;

import io.netty.channel.ConnectTimeoutException;
import it.gov.pagopa.wispconverter.exception.AppErrorCodeMessageEnum;
import it.gov.pagopa.wispconverter.exception.AppException;
import it.gov.pagopa.wispconverter.service.mapper.DebtPositionMapper;
Expand All @@ -15,8 +14,6 @@
import org.springframework.web.client.RestClientException;

import java.math.BigDecimal;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -181,7 +178,7 @@ private String getNAVCodeFromIUVGenerator(String creditorInstitutionCode) {
it.gov.pagopa.gen.wispconverter.client.iuvgenerator.api.GenerationApi apiInstance = new it.gov.pagopa.gen.wispconverter.client.iuvgenerator.api.GenerationApi(iuvGeneratorClient);
it.gov.pagopa.gen.wispconverter.client.iuvgenerator.model.IUVGenerationResponseDto response = apiInstance.generateIUV(creditorInstitutionCode, request);

navCode = response.getIuv();
navCode = this.auxDigit + response.getIuv();
} catch (RestClientException e) {
throw new AppException(AppErrorCodeMessageEnum.CLIENT_IUVGENERATOR,
String.format("RestClientException ERROR [%s] - %s", e.getCause().getClass().getCanonicalName(), e.getMessage()));
Expand Down

0 comments on commit d3e6b2b

Please sign in to comment.