From f20507743bd876928c57dd1a3ce3e1e8c614e6f1 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Tue, 9 Apr 2024 09:50:50 +0200 Subject: [PATCH 01/20] fix: updated mapping for cache and debt position --- .../wispconverter/service/CacheService.java | 19 ++++++++++++++++--- .../service/ConverterService.java | 3 --- .../service/DebtPositionService.java | 10 +++++----- .../service/RPTExtractorService.java | 12 +++++++++++- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java index f22bd152..4bae9d2e 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java @@ -6,6 +6,7 @@ import it.gov.pagopa.wispconverter.repository.CacheRepository; import it.gov.pagopa.wispconverter.service.model.CommonRPTFieldsDTO; import it.gov.pagopa.wispconverter.service.model.PaymentNoticeContentDTO; +import it.gov.pagopa.wispconverter.service.model.RPTContentDTO; import it.gov.pagopa.wispconverter.util.Constants; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -15,6 +16,8 @@ import org.springframework.web.client.RestClientException; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; @Service @Slf4j @@ -34,20 +37,30 @@ public class CacheService { public void storeRequestMappingInCache(CommonRPTFieldsDTO commonRPTFieldsDTO, String sessionId) { try { - String idIntermediarioPA = commonRPTFieldsDTO.getCreditorInstitutionBrokerId(); + String creditorInstitutionBrokerId = commonRPTFieldsDTO.getCreditorInstitutionBrokerId(); List noticeNumbers = commonRPTFieldsDTO.getPaymentNotices().stream() .map(PaymentNoticeContentDTO::getNoticeNumber) .toList(); // 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, idIntermediarioPA, noticeNumber))); + noticeNumbers.forEach(noticeNumber -> decouplerCachingKeys.addKeysItem(String.format(COMPOSITE_TWOVALUES_KEY_TEMPLATE, creditorInstitutionBrokerId, 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)); // save in Redis cache the mapping of the request identifier needed for RT generation in next steps + /* for (String noticeNumber : noticeNumbers) { - String requestIDForRTHandling = String.format(CACHING_KEY_TEMPLATE, idIntermediarioPA, noticeNumber); + String requestIDForRTHandling = String.format(CACHING_KEY_TEMPLATE, creditorInstitutionBrokerId, noticeNumber); + this.cacheRepository.insert(requestIDForRTHandling, sessionId, this.requestIDMappingTTL); + } + */ + String creditorInstitutionId = commonRPTFieldsDTO.getCreditorInstitutionId(); + Set iuvs = commonRPTFieldsDTO.getRpts().stream() + .map(RPTContentDTO::getIuv) + .collect(Collectors.toSet()); + for (String iuv : iuvs) { + String requestIDForRTHandling = String.format(CACHING_KEY_TEMPLATE, creditorInstitutionId, iuv); this.cacheRepository.insert(requestIDForRTHandling, sessionId, this.requestIDMappingTTL); } diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/ConverterService.java b/src/main/java/it/gov/pagopa/wispconverter/service/ConverterService.java index 50d5d636..1a6dcf1f 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/ConverterService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/ConverterService.java @@ -47,9 +47,6 @@ public String convert(String sessionId) { // calling GPD creation API in order to generate the debt position associated to RPTs this.debtPositionService.createDebtPositions(commonRPTFieldsDTO); - - - // call APIM policy for save key for decoupler and save in Redis cache the mapping of the request identifier needed for RT generation in next steps this.cacheService.storeRequestMappingInCache(commonRPTFieldsDTO, sessionId); diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/DebtPositionService.java b/src/main/java/it/gov/pagopa/wispconverter/service/DebtPositionService.java index 78a06595..08eb6f2d 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/DebtPositionService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/DebtPositionService.java @@ -38,10 +38,10 @@ public class DebtPositionService { private String posteItalianeABICode; @Value("${wisp-converter.aux-digit}") - private Long auxDigit; + private Integer auxDigit; @Value("${wisp-converter.segregation-code}") - private Long segregationCode; + private Integer segregationCode; public void createDebtPositions(CommonRPTFieldsDTO rptContentDTOs) { @@ -171,13 +171,13 @@ private String getNAVCodeFromIUVGenerator(String creditorInstitutionCode) { String navCode; try { - it.gov.pagopa.gen.wispconverter.client.iuvgenerator.model.IuvGenerationModelDto request = new it.gov.pagopa.gen.wispconverter.client.iuvgenerator.model.IuvGenerationModelDto(); + it.gov.pagopa.gen.wispconverter.client.iuvgenerator.model.IUVGenerationRequestDto request = new it.gov.pagopa.gen.wispconverter.client.iuvgenerator.model.IUVGenerationRequestDto(); request.setAuxDigit(this.auxDigit); request.setSegregationCode(this.segregationCode); // communicating with IUV Generator service in order to retrieve response - it.gov.pagopa.gen.wispconverter.client.iuvgenerator.api.IuvGeneratorApiApi apiInstance = new it.gov.pagopa.gen.wispconverter.client.iuvgenerator.api.IuvGeneratorApiApi(iuvGeneratorClient); - it.gov.pagopa.gen.wispconverter.client.iuvgenerator.model.IuvGenerationModelResponseDto response = apiInstance.generateIUV(creditorInstitutionCode, request); + 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(); } catch (RestClientException e) { diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java b/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java index 331c4ff0..ae9702c1 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java @@ -70,6 +70,16 @@ private CommonRPTFieldsDTO extractRPTContentDTOsFromNodoInviaRPT(Envelope envelo .payerType(rpt.getPayer().getSubjectUniqueIdentifier().getType()) .payerFiscalCode(rpt.getPayer().getSubjectUniqueIdentifier().getCode()) .payerFullName(rpt.getPayer().getName()) + .payerType(rpt.getPayer().getSubjectUniqueIdentifier().getType()) + .payerFiscalCode(rpt.getPayer().getSubjectUniqueIdentifier().getCode()) + .payerFullName(rpt.getPayer().getName()) + .payerAddressStreetName(rpt.getPayer().getAddress()) + .payerAddressStreetNumber(rpt.getPayer().getStreetNumber()) + .payerAddressPostalCode(rpt.getPayer().getPostalCode()) + .payerAddressCity(rpt.getPayer().getCity()) + .payerAddressProvince(rpt.getPayer().getProvince()) + .payerAddressNation(rpt.getPayer().getNation()) + .payerEmail(rpt.getPayer().getEmail()) .isMultibeneficiary(false) .containsDigitalStamp(containsDigitalStamp) .paymentNotices(new ArrayList<>()) @@ -87,7 +97,7 @@ private CommonRPTFieldsDTO extractRPTContentDTOsFromNodoInviaCarrelloRPT(Envelop NodoInviaCarrelloRPT soapBody = this.jaxbElementUtil.getSoapBody(envelope, NodoInviaCarrelloRPT.class); // initializing common fields - boolean isMultibeneficiary = soapBody.isMultiBeneficiario() !=null && soapBody.isMultiBeneficiario(); + boolean isMultibeneficiary = soapBody.isMultiBeneficiario() != null && soapBody.isMultiBeneficiario(); String creditorInstitutionId = null; String payerType = null; String payerFiscalCode = null; From f54275f3b420091514acb8bca3d5918630038eb4 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Tue, 9 Apr 2024 09:51:53 +0200 Subject: [PATCH 02/20] fix: updated IUV Generation OpenAPI for SubKey inclusion --- openapi-client/iuv-generator/openapi.json | 212 ++++++++---------- .../client/IuvGeneratorClientConfig.java | 2 +- 2 files changed, 98 insertions(+), 116 deletions(-) diff --git a/openapi-client/iuv-generator/openapi.json b/openapi-client/iuv-generator/openapi.json index 383e02c8..208e787d 100644 --- a/openapi-client/iuv-generator/openapi.json +++ b/openapi-client/iuv-generator/openapi.json @@ -1,111 +1,68 @@ { "openapi": "3.0.1", "info": { - "title": "OpenAPI definition - Iuv Generator", - "version": "0.0.1-19" + "description": "A service that permits to generate unique IUV codes for each creditor institution.\n\n**STANDARD ERRORS:**\nNAME | CODE | DESCRIPTION\n- | - | -\n**IUVG-1000** | *GENERIC_ERROR* | Error while generating IUV. *...error description...*\n**IUVG-1001** | *VALIDATION_ERROR* | Error while validating IUV generation request. *...error description...*\n**IUVG-1101** | *GENERATION_MAX_RETRIES_REACHED* | Error while generating IUV. Reached the maximum number of internal automatic attempts [*...content...*] to generate a unique IUV for creditor institution [*...content...*]. Please, try again later.\n**IUVG-1102** | *GENERATION_AUXDIGIT_ALGORITHM_INVALID_PATTERN* | Error while generating IUV. The IUV code's section generated by timestamp in milliseconds is not correctly composited of 13 digits.\n", + "termsOfService": "https://www.pagopa.gov.it/", + "title": "IUV Generator", + "version": "0.2.4" }, "servers": [ { - "url": "https://api.uat.platform.pagopa.it/shared/iuv-generator-service/v1", - "description": "Generated server url" + "url": "${host}", + "description": "Generated server URL" + }, + { + "url": "http://localhost:8080", + "description": "Local server URL" + } + ], + "tags": [ + { + "description": "Application info APIs", + "name": "Home" + }, + { + "description": "IUV Generation APIs", + "name": "Generation" } ], "paths": { "/info": { "get": { - "tags": [ - "Home" - ], - "summary": "Health Check", - "description": "Return OK if application is started", "operationId": "healthCheck", "responses": { "200": { - "description": "OK", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - }, "content": { - "application/json": {} - } - }, - "401": { - "description": "Unauthorized", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "403": { - "description": "Forbidden", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "429": { - "description": "Too many requests", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", - "schema": { - "type": "string" - } - } - } - }, - "500": { - "description": "Service unavailable", - "headers": { - "X-Request-Id": { - "description": "This header identifies the call", + "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/AppInfoResponse" } } }, - "content": { - "application/json": {} - } + "description": "OK." } - } - }, - "parameters": [ - { - "name": "X-Request-Id", - "in": "header", - "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", - "schema": { - "type": "string" + }, + "security": [ + { + "ApiKey": [] } - } - ] + ], + "summary": "Return OK if application is started", + "tags": [ + "Home" + ] + } }, - "/organizations/{organizationfiscalcode}/iuv": { + "/organizations/{organization-fiscal-code}/iuv": { "post": { - "tags": [ - "Iuv Generator API" - ], - "summary": "Generate a unique IUV.", + "description": "**Description:** \nGenerate a new unique IUV code without aux-digit at the start. \n\n**API properties:**\nProperty | Value\n- | -\nInternal | Y\nExternal | N\nSynchronous | SYNC\nAuthorization | NONE\nAuthentication | APIKEY\nTPS | 1.0/sec\nIdempotency | N\nStateless | Y\nRead/Write Intense | Read and Write\nCacheable | N\n", "operationId": "generateIUV", "parameters": [ { - "name": "organizationfiscalcode", + "description": "The fiscal code of the creditor institution", + "example": 77777777777, "in": "path", - "description": "The fiscal code of the organization.", + "name": "organization-fiscal-code", "required": true, "schema": { "type": "string" @@ -116,7 +73,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IuvGenerationModel" + "$ref": "#/components/schemas/IUVGenerationRequest" } } }, @@ -124,61 +81,86 @@ }, "responses": { "201": { - "description": "Created a valid iuv.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/IuvGenerationModelResponse" + "$ref": "#/components/schemas/IUVGenerationResponse" } } - } - }, - "400": { - "description": "Malformed request.", - "content": { - "application/json": {} - } - }, - "429": { - "description": "Too many requests" - }, - "500": { - "description": "Service unavailable.", - "content": { - "application/json": {} - } + }, + "description": "Created." } - } + }, + "security": [ + { + "ApiKey": [] + } + ], + "summary": "Generate new IUV for organization", + "tags": [ + "Generation" + ] } } }, "components": { "schemas": { - "IuvGenerationModel": { - "required": [ - "auxDigit", - "segregationCode" - ], + "AppInfoResponse": { "type": "object", "properties": { - "segregationCode": { - "type": "integer", - "format": "int64" + "environment": { + "type": "string" }, + "name": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "IUVGenerationRequest": { + "type": "object", + "properties": { "auxDigit": { "type": "integer", - "format": "int64" + "description": "The value of the AUX digit related to the IUV.", + "format": "int32", + "example": 3 + }, + "segregationCode": { + "type": "integer", + "description": "The value of the segregation related to the IUV.", + "format": "int32", + "example": 48 } - } + }, + "required": [ + "auxDigit", + "segregationCode" + ] }, - "IuvGenerationModelResponse": { + "IUVGenerationResponse": { "type": "object", "properties": { "iuv": { - "type": "string" + "type": "string", + "description": "The unique IUV generated from computation for the creditor institution.", + "example": "584756566583" } - } + }, + "required": [ + "iuv" + ] + } + }, + "securitySchemes": { + "ApiKey": { + "description": "The API key to access this function app.", + "in": "header", + "name": "Ocp-Apim-Subscription-Key", + "type": "apiKey" } } } -} +} \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/wispconverter/config/client/IuvGeneratorClientConfig.java b/src/main/java/it/gov/pagopa/wispconverter/config/client/IuvGeneratorClientConfig.java index e0388401..089167ca 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/config/client/IuvGeneratorClientConfig.java +++ b/src/main/java/it/gov/pagopa/wispconverter/config/client/IuvGeneratorClientConfig.java @@ -62,7 +62,7 @@ public it.gov.pagopa.gen.wispconverter.client.iuvgenerator.invoker.ApiClient iuv it.gov.pagopa.gen.wispconverter.client.iuvgenerator.invoker.ApiClient client = new it.gov.pagopa.gen.wispconverter.client.iuvgenerator.invoker.ApiClient(restTemplate); client.setBasePath(basePath); -// client.setApiKey(apiKey); + client.setApiKey(apiKey); return client; } From 0a00666a0a02a2c20cd87f54339f47bc287bbedd Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Tue, 9 Apr 2024 14:43:48 +0200 Subject: [PATCH 03/20] [NOD_781] fix: explicitly set deserializer for OffsetDateTime --- .../config/client/GpdClientConfig.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/config/client/GpdClientConfig.java b/src/main/java/it/gov/pagopa/wispconverter/config/client/GpdClientConfig.java index a3e6565b..8ac09e85 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/config/client/GpdClientConfig.java +++ b/src/main/java/it/gov/pagopa/wispconverter/config/client/GpdClientConfig.java @@ -1,5 +1,11 @@ package it.gov.pagopa.wispconverter.config.client; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import it.gov.pagopa.wispconverter.service.ReService; import it.gov.pagopa.wispconverter.util.client.ClientLoggingProperties; import it.gov.pagopa.wispconverter.util.client.gpd.GpdClientLoggingInterceptor; @@ -8,15 +14,20 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.DefaultUriBuilderFactory; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; @Configuration @@ -68,7 +79,24 @@ public it.gov.pagopa.gen.wispconverter.client.gpd.invoker.ApiClient gpdClient() } private RestTemplate restTemplate() { - RestTemplate restTemplate = new RestTemplate(); + + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + SimpleModule module = new SimpleModule(); + module.addSerializer(OffsetDateTime.class, new JsonSerializer<>() { + @Override + public void serialize(OffsetDateTime date, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException { + String formattedDate = date.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); + jsonGenerator.writeString(formattedDate); + } + }); + objectMapper.registerModule(module); + + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + converter.setObjectMapper(objectMapper); + + RestTemplate restTemplate = new RestTemplateBuilder().messageConverters(converter).build(); + // This allows us to read the response more than once - Necessary for debugging. restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(getSimpleClientHttpRequestFactory(restTemplate.getRequestFactory()))); From dd80b741da2af0f8d4af2ebfa813c7073e37755d Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Tue, 9 Apr 2024 14:44:36 +0200 Subject: [PATCH 04/20] fix: changed API path from 'redirect' to 'payments' --- .../controller/RedirectController.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java index b8fc0b12..49891ff7 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java @@ -29,7 +29,9 @@ import org.springframework.ui.Model; import org.springframework.validation.annotation.Validated; import org.springframework.web.ErrorResponse; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import java.time.Instant; import java.util.Map; @@ -42,18 +44,17 @@ @Slf4j public class RedirectController { + private static final String BO_REDIRECT = "redirect"; private final ConverterService converterService; private final ErrorUtil errorUtil; private final MessageSource messageSource; - private static final String BO_REDIRECT = "redirect"; - @Operation(summary = "", description = "", security = {@SecurityRequirement(name = "ApiKey")}, tags = {"Redirect"}) @ApiResponses(value = { @ApiResponse(responseCode = "302", description = "Redirect to Checkout service.", content = @Content(schema = @Schema())) }) - @GetMapping(value = "/redirect") - @TraceReEvent(businessProcess=BO_REDIRECT) + @GetMapping(value = "/payments") + @TraceReEvent(businessProcess = BO_REDIRECT) public String redirect(@Parameter(description = "", example = "identificativoIntermediarioPA_sessionId") @NotBlank(message = "{redirect.session-id.not-blank}") @RequestParam("sessionId") String sessionId, @@ -93,7 +94,7 @@ public String redirect(@Parameter(description = "", example = "identificativoInt @ApiResponse(responseCode = "200", description = "Redirect info to Checkout service.", content = @Content(schema = @Schema(implementation = RedirectResponse.class))) }) @GetMapping(value = "/redirect", consumes = MediaType.APPLICATION_JSON_VALUE) - @TraceReEvent(businessProcess=BO_REDIRECT) + @TraceReEvent(businessProcess = BO_REDIRECT) public ResponseEntity redirectInfo(@Parameter(description = "", example = "identificativoIntermediarioPA_sessionId") @NotBlank(message = "{redirect.session-id.not-blank}") @RequestParam("sessionId") String sessionId) { From 877008cc6423c5d3c73ee4bdb154884a75500e50 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Tue, 9 Apr 2024 15:00:06 +0200 Subject: [PATCH 05/20] break: migration of infrastructure resources in infra repo --- infra/.terraform.lock.hcl | 62 --------- infra/04_apim_api.tf | 54 -------- infra/99_locals.tf | 10 -- infra/99_main.tf | 28 ---- infra/99_variables.tf | 72 ----------- infra/env/weu-dev/backend.ini | 1 - infra/env/weu-dev/backend.tfvars | 4 - infra/env/weu-dev/terraform.tfvars | 18 --- infra/env/weu-prod/backend.ini | 1 - infra/env/weu-prod/backend.tfvars | 4 - infra/env/weu-prod/terraform.tfvars | 15 --- infra/env/weu-uat/backend.ini | 1 - infra/env/weu-uat/backend.tfvars | 4 - infra/env/weu-uat/terraform.tfvars | 15 --- infra/policy/_base_policy.xml | 15 --- infra/terraform.sh | 191 ---------------------------- 16 files changed, 495 deletions(-) delete mode 100644 infra/.terraform.lock.hcl delete mode 100644 infra/04_apim_api.tf delete mode 100644 infra/99_locals.tf delete mode 100644 infra/99_main.tf delete mode 100644 infra/99_variables.tf delete mode 100644 infra/env/weu-dev/backend.ini delete mode 100644 infra/env/weu-dev/backend.tfvars delete mode 100644 infra/env/weu-dev/terraform.tfvars delete mode 100644 infra/env/weu-prod/backend.ini delete mode 100644 infra/env/weu-prod/backend.tfvars delete mode 100644 infra/env/weu-prod/terraform.tfvars delete mode 100644 infra/env/weu-uat/backend.ini delete mode 100644 infra/env/weu-uat/backend.tfvars delete mode 100644 infra/env/weu-uat/terraform.tfvars delete mode 100644 infra/policy/_base_policy.xml delete mode 100755 infra/terraform.sh diff --git a/infra/.terraform.lock.hcl b/infra/.terraform.lock.hcl deleted file mode 100644 index 2ae265b9..00000000 --- a/infra/.terraform.lock.hcl +++ /dev/null @@ -1,62 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/azure/azapi" { - version = "1.3.0" - constraints = "1.3.0" - hashes = [ - "h1:OWZNYEGEIunmpxEcbGveH+kkdELQfMCUYxLt1b25UOc=", - "zh:0923b297c5b71ed584e5f3a0b2393e80244076e85102a90438159833353274b0", - "zh:11fa2922aa98ca55beaf7cc33c7edbde81bbd405fdfea2955276c7f5a8537240", - "zh:14af830fb6091d084bfc2711c8e9c7bf05aa3c56fe8fd8e2fb4eddeb345be88d", - "zh:25258425ecbffbdf09b0c8131d2c680cddd19b504e0036ee5f83972dcae7df0a", - "zh:2922b535fe4d4f0963189548f2f8360a0aaf951fd411354f2269a111d8a0c1ad", - "zh:32c9360305e00c25d0f9d0a84dfbdbad8da2465be769a9c1f11f132c0225358e", - "zh:4ddd3ee23c340d5000839d8d30ba7f94e695476d63075f95cfb041e67d8f6ef6", - "zh:5c1514392a5c3dd51084aa70cb6c4dcc8b027c4508b5e4eb9f8c3990fd403213", - "zh:6b3ecac7099ab86c007b5ad636bd029f5e5f3e9bd06b0f74c82f0451a7995ecc", - "zh:6cb7081745b378e910e0cf09fb5717a2ad35e629ce3e07415d6682c1c1407872", - "zh:7107eda5125c1b983380f1f6418c592fb7fb2eb5b589ad0e08f6c47341f36318", - "zh:c6fa7af32a7a47d23a85e0eea4d4cbb065378ae75aed8c9c628fb625b04bc619", - ] -} - -provider "registry.terraform.io/hashicorp/azuread" { - version = "2.30.0" - constraints = "2.30.0" - hashes = [ - "h1:Uw4TcmJBEJ71h+oCwwidlkk5jFpyFRDPAFCMs/bT/cw=", - "zh:1c3e89cf19118fc07d7b04257251fc9897e722c16e0a0df7b07fcd261f8c12e7", - "zh:2e62c193030e04ebb10cc0526119cf69824bf2d7e4ea5a2f45bd5d5fb7221d36", - "zh:2f3c7a35257332d68b778cefc5201a5f044e4914dd03794a4da662ddfe756483", - "zh:35d0d3a1b58fdb8b8c4462d6b7e7016042da43ea9cc734ce897f52a73407d9b0", - "zh:47ede0cd0206ec953d40bf4a80aa6e59af64e26cbbd877614ac424533dbb693b", - "zh:48c190307d4d42ea67c9b8cc544025024753f46cef6ea64db84735e7055a72da", - "zh:6fff9b2c6a962252a70a15b400147789ab369b35a781e9d21cce3804b04d29af", - "zh:7646980cf3438bff29c91ffedb74458febbb00a996638751fbd204ab1c628c9b", - "zh:77aa2fa7ca6d5446afa71d4ff83cb87b70a2f3b72110fc442c339e8e710b2928", - "zh:e20b2b2c37175b89dd0db058a096544d448032e28e3b56e2db368343533a9684", - "zh:eab175b1dfe9865ad9404dccb6d5542899f8c435095aa7c679314b811c717ce7", - "zh:efc862bd78c55d2ff089729e2a34c1831ab4b0644fc11b36ee4ebed00a4797ba", - ] -} - -provider "registry.terraform.io/hashicorp/azurerm" { - version = "3.44.1" - constraints = ">= 3.30.0, <= 3.44.1, <= 3.53.0" - hashes = [ - "h1:dq7s/3sZrI4oLWL/NUlOcOD3HGkzimRmEvFiWX+ENRw=", - "zh:0a1761b5aeec47d5019114976de5eb9832dea1d57d632ca6fa464b99b782d1c1", - "zh:0e9c96fa7ed6d55a3f3a646ff346298c8b7728331bb3a74875f78ecb7d245c16", - "zh:1aa953a692c7b5b10219343f0238f4624ac988e247721b6ec6b1bed2b81f7ceb", - "zh:237258af1a1ce8a0aed8f6cdb03c69ea83ff4f3a46d5bd1466cd503f0b5aded8", - "zh:542067eeeb3b4e286e92d646e0f40426e204ed268973343e585aa521f075f8dc", - "zh:8326d52460252fd335ae97d0fabd9f5d90061a4fbeb273618f4067be3eb4e75a", - "zh:97a2b802bf6e204476131ddb7a91e832568ee8da3b0515ed23361c9f72ca9706", - "zh:9ae5a52ec85e0ad218e2ce9d33859f17afbb2fb2a690bf60d5f48fc7680e7fb0", - "zh:b17e77aff310e232f541334ba1858b5125ea0e527a5d6824de017192d8d8a3a2", - "zh:c469ba6681535c07c58dad6c1b59b056912300a7c91137ddc0103ef16b1d5697", - "zh:cea6026ef8fb5512d14c1ba6fdf36b90a09de536d4e4afad96b926af39114f74", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - ] -} diff --git a/infra/04_apim_api.tf b/infra/04_apim_api.tf deleted file mode 100644 index 58be9da5..00000000 --- a/infra/04_apim_api.tf +++ /dev/null @@ -1,54 +0,0 @@ -locals { - - apim_wisp_converter_rest_api = { - project_name = "wisp-converter" - repo_name = "pagopa-wisp-converter" - display_name = "WISP Converter" - description = "API for WISP Converter" - path = "wisp-converter/api" - subscription_required = true - host = "api.${var.apim_dns_zone_prefix}.${var.external_domain}" - hostname = var.hostname - } - -} - - -# WISP Converter - REST APIs - -resource "azurerm_api_management_api_version_set" "api_version_set_wisp_converter" { - name = "${var.prefix}-${var.env_short}-${var.location_short}-${local.apim_wisp_converter_rest_api.project_name}" - resource_group_name = local.apim.rg - api_management_name = local.apim.name - display_name = local.apim_wisp_converter_rest_api.display_name - versioning_scheme = "Segment" -} - -module "wisp_converter_api_v1" { - source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management_api?ref=v6.7.0" - - name = format("%s-wisp-converter-api", var.env_short) - api_management_name = local.apim.name - resource_group_name = local.apim.rg - product_ids = [local.apim.product_id] - subscription_required = true - - version_set_id = azurerm_api_management_api_version_set.api_version_set_wisp_converter.id - api_version = "v1" - - description = local.apim_wisp_converter_rest_api.description - display_name = local.apim_wisp_converter_rest_api.display_name - path = local.apim_wisp_converter_rest_api.path - protocols = ["https"] - - service_url = null - - content_format = "openapi" - content_value = templatefile("../openapi/openapi.json", { - host = local.apim_wisp_converter_rest_api.host - }) - - xml_content = templatefile("./policy/_base_policy.xml", { - hostname = var.hostname - }) -} \ No newline at end of file diff --git a/infra/99_locals.tf b/infra/99_locals.tf deleted file mode 100644 index a316c4b8..00000000 --- a/infra/99_locals.tf +++ /dev/null @@ -1,10 +0,0 @@ -locals { - product = "${var.prefix}-${var.env_short}" - project = "${var.prefix}-${var.env_short}-${var.location_short}-${var.domain}" - - apim = { - name = "${local.product}-apim" - rg = "${local.product}-api-rg" - product_id = "pagopa-wisp-converter" - } -} diff --git a/infra/99_main.tf b/infra/99_main.tf deleted file mode 100644 index a5df0fbe..00000000 --- a/infra/99_main.tf +++ /dev/null @@ -1,28 +0,0 @@ -terraform { - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = ">= 3.30.0" - } - azuread = { - source = "hashicorp/azuread" - version = "2.30.0" - } - azapi = { - source = "Azure/azapi" - version = "= 1.3.0" - } - } - - backend "azurerm" {} -} - -provider "azurerm" { - features {} -} - -provider "azapi" {} - -data "azurerm_subscription" "current" {} - -data "azurerm_client_config" "current" {} \ No newline at end of file diff --git a/infra/99_variables.tf b/infra/99_variables.tf deleted file mode 100644 index 5adebd2d..00000000 --- a/infra/99_variables.tf +++ /dev/null @@ -1,72 +0,0 @@ -# general - -variable "prefix" { - type = string - validation { - condition = ( - length(var.prefix) <= 6 - ) - error_message = "Max length is 6 chars." - } -} - -variable "env" { - type = string -} - -variable "env_short" { - type = string - validation { - condition = ( - length(var.env_short) == 1 - ) - error_message = "Length must be 1 chars." - } -} - -variable "location_short" { - type = string - validation { - condition = ( - length(var.location_short) == 3 - ) - error_message = "Length must be 3 chars." - } - description = "One of wue, neu" -} - -variable "tags" { - type = map(any) - default = { - CreatedBy = "Terraform" - } -} - -variable "apim_dns_zone_prefix" { - type = string - default = null - description = "The dns subdomain for apim." -} - -variable "external_domain" { - type = string - default = null - description = "Domain for delegation" -} - -variable "hostname" { - type = string - default = null - description = "Hostname for the API" -} - -variable "domain" { - type = string - validation { - condition = ( - length(var.domain) <= 12 - ) - error_message = "Max length is 12 chars." - } - default = "nodo" -} \ No newline at end of file diff --git a/infra/env/weu-dev/backend.ini b/infra/env/weu-dev/backend.ini deleted file mode 100644 index 22e6a996..00000000 --- a/infra/env/weu-dev/backend.ini +++ /dev/null @@ -1 +0,0 @@ -subscription=DEV-pagoPA diff --git a/infra/env/weu-dev/backend.tfvars b/infra/env/weu-dev/backend.tfvars deleted file mode 100644 index d8036235..00000000 --- a/infra/env/weu-dev/backend.tfvars +++ /dev/null @@ -1,4 +0,0 @@ -resource_group_name = "io-infra-rg" -storage_account_name = "pagopainfraterraformdev" -container_name = "azurermstate" -key = "pagopa-wisp-converter.infra.tfstate" diff --git a/infra/env/weu-dev/terraform.tfvars b/infra/env/weu-dev/terraform.tfvars deleted file mode 100644 index 9b50e07e..00000000 --- a/infra/env/weu-dev/terraform.tfvars +++ /dev/null @@ -1,18 +0,0 @@ -prefix = "pagopa" -env = "dev" -env_short = "d" - -domain = "nodo" -location_short = "weu" - -tags = { - CreatedBy = "Terraform" - Environment = "Dev" - Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-wisp-converter" - CostCenter = "TS310 - PAGAMENTI & SERVIZI" -} - -apim_dns_zone_prefix = "dev.platform" -external_domain = "pagopa.it" -hostname = "weudev.nodo.internal.dev.platform.pagopa.it" diff --git a/infra/env/weu-prod/backend.ini b/infra/env/weu-prod/backend.ini deleted file mode 100644 index 63184253..00000000 --- a/infra/env/weu-prod/backend.ini +++ /dev/null @@ -1 +0,0 @@ -subscription=PROD-pagoPA diff --git a/infra/env/weu-prod/backend.tfvars b/infra/env/weu-prod/backend.tfvars deleted file mode 100644 index c48fabc0..00000000 --- a/infra/env/weu-prod/backend.tfvars +++ /dev/null @@ -1,4 +0,0 @@ -resource_group_name = "io-infra-rg" -storage_account_name = "pagopainfraterraformprod" -container_name = "azurermstate" -key = "pagopa-wisp-converter.infra.tfstate" diff --git a/infra/env/weu-prod/terraform.tfvars b/infra/env/weu-prod/terraform.tfvars deleted file mode 100644 index f31e595c..00000000 --- a/infra/env/weu-prod/terraform.tfvars +++ /dev/null @@ -1,15 +0,0 @@ -prefix = "pagopa" -env = "prod" -env_short = "p" - -tags = { - CreatedBy = "Terraform" - Environment = "Prod" - Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-wisp-converter" - CostCenter = "TS310 - PAGAMENTI & SERVIZI" -} - -apim_dns_zone_prefix = "platform" -external_domain = "pagopa.it" -hostname = "weuprod.nodo.internal.platform.pagopa.it" diff --git a/infra/env/weu-uat/backend.ini b/infra/env/weu-uat/backend.ini deleted file mode 100644 index 1a014151..00000000 --- a/infra/env/weu-uat/backend.ini +++ /dev/null @@ -1 +0,0 @@ -subscription=UAT-pagoPA diff --git a/infra/env/weu-uat/backend.tfvars b/infra/env/weu-uat/backend.tfvars deleted file mode 100644 index 069506ed..00000000 --- a/infra/env/weu-uat/backend.tfvars +++ /dev/null @@ -1,4 +0,0 @@ -resource_group_name = "io-infra-rg" -storage_account_name = "pagopainfraterraformuat" -container_name = "azurermstate" -key = "pagopa-wisp-converter.infra.tfstate" diff --git a/infra/env/weu-uat/terraform.tfvars b/infra/env/weu-uat/terraform.tfvars deleted file mode 100644 index 414b1754..00000000 --- a/infra/env/weu-uat/terraform.tfvars +++ /dev/null @@ -1,15 +0,0 @@ -prefix = "pagopa" -env = "uat" -env_short = "u" - -tags = { - CreatedBy = "Terraform" - Environment = "Uat" - Owner = "pagoPA" - Source = "https://github.com/pagopa/pagopa-wisp-converter" - CostCenter = "TS310 - PAGAMENTI & SERVIZI" -} - -apim_dns_zone_prefix = "uat.platform" -external_domain = "pagopa.it" -hostname = "weuuat.nodo.internal.uat.platform.pagopa.it" diff --git a/infra/policy/_base_policy.xml b/infra/policy/_base_policy.xml deleted file mode 100644 index 3ff212ba..00000000 --- a/infra/policy/_base_policy.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/infra/terraform.sh b/infra/terraform.sh deleted file mode 100755 index b4691c81..00000000 --- a/infra/terraform.sh +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/bash -############################################################ -# Terraform script for managing infrastructure on Azure -# Fingerprint: d2hhdHlvdXdhbnQ/Cg== -############################################################ -# Global variables -# Version format x.y accepted -vers="1.1" -script_name=$(basename "$0") -git_repo="https://raw.githubusercontent.com/pagopa/eng-common-scripts/main/azure/${script_name}" -tmp_file="${script_name}.new" - -# Define functions -function clean_environment() { - rm -rf .terraform* - rm tfplan 2>/dev/null - echo "cleaned!" -} - -function help_usage() { - echo "terraform.sh Version ${vers}" - echo - echo "Usage: ./script.sh [ACTION] [ENV] [OTHER OPTIONS]" - echo "es. ACTION: init, apply, plan, etc." - echo "es. ENV: dev, uat, prod, etc." - echo - echo "Available actions:" - echo " clean Remove .terraform* folders and tfplan files" - echo " help This help" - echo " list List every environment available" - echo " summ Generate summary of Terraform plan" - echo " * any terraform option" -} - -function init_terraform() { - if [ -n "$env" ]; then - terraform init -reconfigure -backend-config="./env/$env/backend.tfvars" - else - echo "ERROR: no env configured!" - exit 1 - fi -} - -function list_env() { - # Check if env directory exists - if [ ! -d "./env" ]; then - echo "No environment directory found" - exit 1 - fi - - # List subdirectories under env directory - env_list=$(ls -d ./env/*/ 2>/dev/null) - - # Check if there are any subdirectories - if [ -z "$env_list" ]; then - echo "No environments found" - exit 1 - fi - - # Print the list of environments - echo "Available environments:" - for env in $env_list; do - env_name=$(echo "$env" | sed 's#./env/##;s#/##') - echo "- $env_name" - done -} - -function other_actions() { - if [ -n "$env" ] && [ -n "$action" ]; then - terraform "$action" -var-file="./env/$env/terraform.tfvars" -compact-warnings $other - else - echo "ERROR: no env or action configured!" - exit 1 - fi -} - -function state_output_taint_actions() { - terraform $action $other -} - -function tfsummary() { - action="plan" - other="-out=tfplan" - other_actions - if [ -n "$(command -v tf-summarize)" ]; then - tf-summarize -separate-tree tfplan && rm tfplan 2>/dev/null - else - echo "tf-summarize is not installed" - fi -} - -function update_script() { - # Check if the repository was cloned successfully - if ! curl -sL "$git_repo" -o "$tmp_file"; then - echo "Error cloning the repository" - rm "$tmp_file" 2>/dev/null - return 1 - fi - - # Check if a newer version exists - remote_vers=$(sed -n '8s/vers="\(.*\)"/\1/p' "$tmp_file") - if [ "$(printf '%s\n' "$vers" "$remote_vers" | sort -V | tail -n 1)" == "$vers" ]; then - echo "The local script version is equal to or newer than the remote version." - rm "$tmp_file" 2>/dev/null - return 0 - fi - - # Check the fingerprint - local_fingerprint=$(sed -n '4p' "$0") - remote_fingerprint=$(sed -n '4p' "$tmp_file") - - if [ "$local_fingerprint" != "$remote_fingerprint" ]; then - echo "The local and remote file fingerprints do not match." - rm "$tmp_file" 2>/dev/null - return 0 - fi - - # Show the current and available versions to the user - echo "Current script version: $vers" - echo "Available script version: $remote_vers" - - # Ask the user if they want to update the script - read -rp "Do you want to update the script to version $remote_vers? (y/n): " answer - - if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then - # Replace the local script with the updated version - cp "$tmp_file" "$script_name" - chmod +x "$script_name" - rm "$tmp_file" 2>/dev/null - - echo "Script successfully updated to version $remote_vers" - else - echo "Update canceled by the user" - fi - - rm "$tmp_file" 2>/dev/null -} - -# Check arguments number -if [ "$#" -lt 1 ]; then - help_usage - exit 0 -fi - -# Parse arguments -action=$1 -env=$2 -shift 2 -other=$@ - -if [ -n "$env" ]; then - # shellcheck source=/dev/null - source "./env/$env/backend.ini" - if [ -z "$(command -v az)" ]; then - echo "az not found, cannot proceed" - exit 1 - fi - az account set -s "${subscription}" -fi - -# Call appropriate function based on action -case $action in - clean) - clean_environment - ;; - ?|help) - help_usage - ;; - init) - init_terraform - init_terraform "$other" - ;; - list) - list_env - ;; - output|state|taint) - init_terraform - state_output_taint_actions $other - ;; - summ) - init_terraform - tfsummary "$other" - ;; - update) - update_script - ;; - *) - # [ -z "$TF_INIT" ] && terraform init - other_actions "$other" - ;; -esac From 162e93cab6c6211a24af3831ea8c910da9f9805e Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Tue, 9 Apr 2024 17:04:19 +0200 Subject: [PATCH 06/20] feat: added Helm chart configuration --- helm/values-dev.yaml | 34 ++++++++++++++++++++++++++-------- helm/values-prod.yaml | 32 ++++++++++++++++++++++++++------ helm/values-uat.yaml | 34 ++++++++++++++++++++++++++-------- 3 files changed, 78 insertions(+), 22 deletions(-) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 96aacfad..6893368e 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: {} + annotations: { } name: "" - podAnnotations: {} + podAnnotations: { } podSecurityContext: seccompProfile: type: RuntimeDefault @@ -67,8 +67,6 @@ microservice-chart: APP_LOGGING_LEVEL: 'DEBUG' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - REDIS_HOST: "pagopa-d-redis.redis.cache.windows.net" - REDIS_PORT: "6380" OTEL_SERVICE_NAME: "pagopa-wisp-converter" OTEL_RESOURCE_ATTRIBUTES: "service.environment=dev" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -76,6 +74,21 @@ microservice-chart: OTEL_METRICS_EXPORTER: otlp OTEL_LOGS_EXPORTER: none OTEL_TRACES_SAMPLER: "always_on" + REDIS_HOST: "pagopa-d-redis.redis.cache.windows.net" + REDIS_PORT: "6380" + COSMOS_URI: "https://pagopa-d-weu-nodo-wispconv-cosmos-account.documents.azure.com:443/" + CACHED_REQUESTID_MAPPING_TTL_MINUTES: "1440" + CACHE_REFRESH_CRON: "0 */60 * * * *" + CLIENT_GPD_READ_TIMEOUT: '5000' + CLIENT_IUVGENERATOR_READ_TIMEOUT: '5000' + CLIENT_CHECKOUT_READ_TIMEOUT: '5000' + CLIENT_DECOUPLERCACHING_READ_TIMEOUT: '5000' + CLIENT_CACHE_READ_TIMEOUT: '5000' + CLIENT_GPD_HOST: 'https://api.dev.platform.pagopa.it/gpd/api/v1' + CLIENT_IUVGENERATOR_HOST: 'https://api.dev.platform.pagopa.it/shared/iuv-generator-service/v1' + CLIENT_CHECKOUT_HOST: 'https://api.dev.platform.pagopa.it/checkout/ec/v1/' + CLIENT_DECOUPLERCACHING_HOST: 'https://api.dev.platform.pagopa.it/wisp-converter/caching/api/v1' + CLIENT_CACHE_HOST: 'https://api.dev.platform.pagopa.it/api-config-cache/o/v1' secretProvider: create: true envSecrets: @@ -83,13 +96,18 @@ microservice-chart: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token REDIS_PASSWORD: 'redis-primary-key' + COSMOS_KEY: 'cosmosdb-wisp-converter-account-key' + CLIENT_GPD_SUBKEY: 'gpd-pagopa-v1-subscription-key' + CLIENT_IUVGENERATOR_SUBKEY: 'iuv-generator-subscription-key' + CLIENT_DECOUPLERCACHING_SUBKEY: 'wisp-converter-caching-subscription-key' + CLIENT_CACHE_SUBKEY: 'api-config-cache-subscription-key-string' keyvault: name: "pagopa-d-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -116,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: {} - envSecret: {} + envConfig: { } + envSecret: { } diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index eca68233..d6aacd2b 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: {} + annotations: { } name: "" - podAnnotations: {} + podAnnotations: { } podSecurityContext: seccompProfile: type: RuntimeDefault @@ -76,6 +76,21 @@ microservice-chart: OTEL_METRICS_EXPORTER: otlp OTEL_LOGS_EXPORTER: none OTEL_TRACES_SAMPLER: "always_on" + REDIS_HOST: "pagopa-p-redis.redis.cache.windows.net" + REDIS_PORT: "6380" + COSMOS_URI: "https://pagopa-p-weu-nodo-wispconv-cosmos-account.documents.azure.com:443/" + CACHED_REQUESTID_MAPPING_TTL_MINUTES: "1440" + CACHE_REFRESH_CRON: "0 */60 * * * *" + CLIENT_GPD_READ_TIMEOUT: '5000' + CLIENT_IUVGENERATOR_READ_TIMEOUT: '5000' + CLIENT_CHECKOUT_READ_TIMEOUT: '5000' + CLIENT_DECOUPLERCACHING_READ_TIMEOUT: '5000' + CLIENT_CACHE_READ_TIMEOUT: '5000' + CLIENT_GPD_HOST: 'https://api.platform.pagopa.it/gpd/api/v1' + CLIENT_IUVGENERATOR_HOST: 'https://api.platform.pagopa.it/shared/iuv-generator-service/v1' + CLIENT_CHECKOUT_HOST: 'https://api.platform.pagopa.it/checkout/ec/v1/' + CLIENT_DECOUPLERCACHING_HOST: 'https://api.platform.pagopa.it/wisp-converter/caching/api/v1' + CLIENT_CACHE_HOST: 'https://api.platform.pagopa.it/api-config-cache/o/v1' secretProvider: create: true envSecrets: @@ -83,13 +98,18 @@ microservice-chart: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string' OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token REDIS_PASSWORD: 'redis-primary-key' + COSMOS_KEY: 'cosmosdb-wisp-converter-account-key' + CLIENT_GPD_SUBKEY: 'gpd-pagopa-v1-subscription-key' + CLIENT_IUVGENERATOR_SUBKEY: 'iuv-generator-subscription-key' + CLIENT_DECOUPLERCACHING_SUBKEY: 'wisp-converter-caching-subscription-key' + CLIENT_CACHE_SUBKEY: 'api-config-cache-subscription-key-string' keyvault: name: "pagopa-p-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -116,5 +136,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: {} - envSecret: {} + envConfig: { } + envSecret: { } diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index fa733f02..d822514f 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: {} + annotations: { } name: "" - podAnnotations: {} + podAnnotations: { } podSecurityContext: seccompProfile: type: RuntimeDefault @@ -67,8 +67,6 @@ microservice-chart: APP_LOGGING_LEVEL: 'INFO' DEFAULT_LOGGING_LEVEL: 'INFO' CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}' - REDIS_HOST: "pagopa-u-redis.redis.cache.windows.net" - REDIS_PORT: "6380" OTEL_SERVICE_NAME: "pagopa-wisp-converter" OTEL_RESOURCE_ATTRIBUTES: "service.environment=uat" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317" @@ -76,6 +74,21 @@ microservice-chart: OTEL_METRICS_EXPORTER: otlp OTEL_LOGS_EXPORTER: none OTEL_TRACES_SAMPLER: "always_on" + REDIS_HOST: "pagopa-u-redis.redis.cache.windows.net" + REDIS_PORT: "6380" + COSMOS_URI: "https://pagopa-u-weu-nodo-wispconv-cosmos-account.documents.azure.com:443/" + CACHED_REQUESTID_MAPPING_TTL_MINUTES: "1440" + CACHE_REFRESH_CRON: "0 */60 * * * *" + CLIENT_GPD_READ_TIMEOUT: '5000' + CLIENT_IUVGENERATOR_READ_TIMEOUT: '5000' + CLIENT_CHECKOUT_READ_TIMEOUT: '5000' + CLIENT_DECOUPLERCACHING_READ_TIMEOUT: '5000' + CLIENT_CACHE_READ_TIMEOUT: '5000' + CLIENT_GPD_HOST: 'https://api.uat.platform.pagopa.it/gpd/api/v1' + CLIENT_IUVGENERATOR_HOST: 'https://api.uat.platform.pagopa.it/shared/iuv-generator-service/v1' + CLIENT_CHECKOUT_HOST: 'https://api.uat.platform.pagopa.it/checkout/ec/v1/' + CLIENT_DECOUPLERCACHING_HOST: 'https://api.uat.platform.pagopa.it/wisp-converter/caching/api/v1' + CLIENT_CACHE_HOST: 'https://api.uat.platform.pagopa.it/api-config-cache/o/v1' secretProvider: create: true envSecrets: @@ -83,13 +96,18 @@ microservice-chart: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-u-connection-string' OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token REDIS_PASSWORD: 'redis-primary-key' + COSMOS_KEY: 'cosmosdb-wisp-converter-account-key' + CLIENT_GPD_SUBKEY: 'gpd-pagopa-v1-subscription-key' + CLIENT_IUVGENERATOR_SUBKEY: 'iuv-generator-subscription-key' + CLIENT_DECOUPLERCACHING_SUBKEY: 'wisp-converter-caching-subscription-key' + CLIENT_CACHE_SUBKEY: 'api-config-cache-subscription-key-string' keyvault: name: "pagopa-u-nodo-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -116,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: {} - envSecret: {} + envConfig: { } + envSecret: { } From 049bae7c79778661277040a749b607ae1d69cb67 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 9 Apr 2024 15:05:59 +0000 Subject: [PATCH 07/20] Bump to version 0.0.8-1-fixes-after-integration-test [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 14 +++++++------- helm/values-prod.yaml | 14 +++++++------- helm/values-uat.yaml | 14 +++++++------- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 16555857..f585c9e0 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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.9.0 -appVersion: 0.0.8 +version: 0.10.0 +appVersion: 0.0.8-1-fixes-after-integration-test dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 6893368e..52948783 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8" + tag: "0.0.8-1-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -106,8 +106,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -134,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } + envConfig: {} + envSecret: {} diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index d6aacd2b..18207877 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8" + tag: "0.0.8-1-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -108,8 +108,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -136,5 +136,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } + envConfig: {} + envSecret: {} diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index d822514f..3854ef10 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8" + tag: "0.0.8-1-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -106,8 +106,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -134,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } + envConfig: {} + envSecret: {} diff --git a/openapi/openapi.json b/openapi/openapi.json index 4aeb719f..09592f4c 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -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.8" + "version": "0.0.8-1-fixes-after-integration-test" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 75c516e1..1027d41e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 0.0.8 + 0.0.8-1-fixes-after-integration-test pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From 262dbfdad9be84f89806e348167aa03e8c1fe94f Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Tue, 9 Apr 2024 17:16:09 +0200 Subject: [PATCH 08/20] fix: updated Dockerfile, changind entrypoint reference --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 26e3228e..24d0bde0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,4 +24,4 @@ COPY --chown=spring:spring --from=builder application/ ./ EXPOSE 8080 -ENTRYPOINT ["java","-javaagent:opentelemetry-javaagent.jar","--enable-preview","org.springframework.boot.loader.JarLauncher"] \ No newline at end of file +ENTRYPOINT ["java","-javaagent:opentelemetry-javaagent.jar","--enable-preview","org.springframework.boot.loader.launch.JarLauncher"] \ No newline at end of file From b04713a623d9656ed7ee7c5b7655355715cc9f6a Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 9 Apr 2024 15:18:05 +0000 Subject: [PATCH 09/20] Bump to version 0.0.8-2-fixes-after-integration-test [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f585c9e0..cda270c0 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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.10.0 -appVersion: 0.0.8-1-fixes-after-integration-test +version: 0.11.0 +appVersion: 0.0.8-2-fixes-after-integration-test dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 52948783..03e3e88f 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-1-fixes-after-integration-test" + tag: "0.0.8-2-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 18207877..767c340a 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-1-fixes-after-integration-test" + tag: "0.0.8-2-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 3854ef10..1a4433c5 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-1-fixes-after-integration-test" + tag: "0.0.8-2-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 09592f4c..a86dd4fd 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -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.8-1-fixes-after-integration-test" + "version": "0.0.8-2-fixes-after-integration-test" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 1027d41e..f92c94a9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 0.0.8-1-fixes-after-integration-test + 0.0.8-2-fixes-after-integration-test pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From c93fdd0a83c7b56b670863761f32a546482cdb68 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Wed, 10 Apr 2024 08:44:56 +0200 Subject: [PATCH 10/20] fix: change on cached key for APIM cache, defining it now as institutionId_nav --- .../it/gov/pagopa/wispconverter/service/CacheService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java index 4bae9d2e..236908bf 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java @@ -37,14 +37,14 @@ public class CacheService { public void storeRequestMappingInCache(CommonRPTFieldsDTO commonRPTFieldsDTO, String sessionId) { try { - String creditorInstitutionBrokerId = commonRPTFieldsDTO.getCreditorInstitutionBrokerId(); + String creditorInstitutionId = commonRPTFieldsDTO.getCreditorInstitutionId(); List noticeNumbers = commonRPTFieldsDTO.getPaymentNotices().stream() .map(PaymentNoticeContentDTO::getNoticeNumber) .toList(); // 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, creditorInstitutionBrokerId, noticeNumber))); + noticeNumbers.forEach(noticeNumber -> decouplerCachingKeys.addKeysItem(String.format(COMPOSITE_TWOVALUES_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)); @@ -55,7 +55,6 @@ public void storeRequestMappingInCache(CommonRPTFieldsDTO commonRPTFieldsDTO, St this.cacheRepository.insert(requestIDForRTHandling, sessionId, this.requestIDMappingTTL); } */ - String creditorInstitutionId = commonRPTFieldsDTO.getCreditorInstitutionId(); Set iuvs = commonRPTFieldsDTO.getRpts().stream() .map(RPTContentDTO::getIuv) .collect(Collectors.toSet()); From 1f4d0b4d480e282a51aaa0e32f04e389bc941c27 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Wed, 10 Apr 2024 08:52:27 +0200 Subject: [PATCH 11/20] fix: resolved pending issues on request generation for checkout --- .../it/gov/pagopa/wispconverter/service/CacheService.java | 6 ------ .../gov/pagopa/wispconverter/service/CheckoutService.java | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java index 236908bf..c76610aa 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java @@ -49,12 +49,6 @@ public void storeRequestMappingInCache(CommonRPTFieldsDTO commonRPTFieldsDTO, St apiInstance.saveMapping(decouplerCachingKeys, MDC.get(Constants.MDC_REQUEST_ID)); // save in Redis cache the mapping of the request identifier needed for RT generation in next steps - /* - for (String noticeNumber : noticeNumbers) { - String requestIDForRTHandling = String.format(CACHING_KEY_TEMPLATE, creditorInstitutionBrokerId, noticeNumber); - this.cacheRepository.insert(requestIDForRTHandling, sessionId, this.requestIDMappingTTL); - } - */ Set iuvs = commonRPTFieldsDTO.getRpts().stream() .map(RPTContentDTO::getIuv) .collect(Collectors.toSet()); diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java b/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java index 751cf7ff..8f8b8b9d 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java @@ -34,7 +34,7 @@ public String executeCall(CommonRPTFieldsDTO commonRPTFieldsDTO) { try { // execute mapping for Checkout carts invocation it.gov.pagopa.gen.wispconverter.client.checkout.model.CartRequestDto cart = mapper.toCart(commonRPTFieldsDTO); - String stationRedirectURL = ""; // FIXME on next API version will be added the stationID so -> getRedirectURL(cart.getStationId()); + String stationRedirectURL = getRedirectURL(commonRPTFieldsDTO.getStationId()); it.gov.pagopa.gen.wispconverter.client.checkout.model.CartRequestReturnUrlsDto returnUrls = new it.gov.pagopa.gen.wispconverter.client.checkout.model.CartRequestReturnUrlsDto(); returnUrls.setReturnOkUrl(new URI(stationRedirectURL + "/success.html")); returnUrls.setReturnCancelUrl(new URI(stationRedirectURL + "/cancel.html")); From ac8e3851fc78d701cd179d91ab1a30543d50c2e7 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 10 Apr 2024 06:54:17 +0000 Subject: [PATCH 12/20] Bump to version 0.0.8-3-fixes-after-integration-test [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index cda270c0..9aa9bb7e 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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.11.0 -appVersion: 0.0.8-2-fixes-after-integration-test +version: 0.12.0 +appVersion: 0.0.8-3-fixes-after-integration-test dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 03e3e88f..04a76d71 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-2-fixes-after-integration-test" + tag: "0.0.8-3-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 767c340a..7f5901b1 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-2-fixes-after-integration-test" + tag: "0.0.8-3-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 1a4433c5..0b254b35 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-2-fixes-after-integration-test" + tag: "0.0.8-3-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index a86dd4fd..d0c23606 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -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.8-2-fixes-after-integration-test" + "version": "0.0.8-3-fixes-after-integration-test" }, "servers": [ { diff --git a/pom.xml b/pom.xml index f92c94a9..d7462088 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 0.0.8-2-fixes-after-integration-test + 0.0.8-3-fixes-after-integration-test pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From 60e1d9ff703730dd465a0888932383156c4678dd Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Wed, 10 Apr 2024 10:23:57 +0200 Subject: [PATCH 13/20] fix: replacede IUV Generator host URL --- helm/Chart.lock | 6 + helm/values-dev.yaml | 14 +- scripts/system-test/README.md | 19 ++ scripts/system-test/config/.env.dev | 1 + scripts/system-test/data/c.env | 3 + scripts/system-test/lib/client.js | 58 ++++++ scripts/system-test/lib/util.js | 15 ++ scripts/system-test/package-lock.json | 207 ++++++++++++++++++++ scripts/system-test/package.json | 15 ++ scripts/system-test/requests/complete_ok.js | 106 ++++++++++ scripts/system-test/start.js | 2 + 11 files changed, 439 insertions(+), 7 deletions(-) create mode 100644 helm/Chart.lock create mode 100644 scripts/system-test/README.md create mode 100644 scripts/system-test/config/.env.dev create mode 100644 scripts/system-test/data/c.env create mode 100644 scripts/system-test/lib/client.js create mode 100644 scripts/system-test/lib/util.js create mode 100644 scripts/system-test/package-lock.json create mode 100644 scripts/system-test/package.json create mode 100644 scripts/system-test/requests/complete_ok.js create mode 100644 scripts/system-test/start.js diff --git a/helm/Chart.lock b/helm/Chart.lock new file mode 100644 index 00000000..63942226 --- /dev/null +++ b/helm/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: microservice-chart + repository: https://pagopa.github.io/aks-microservice-chart-blueprint + version: 3.0.0 +digest: sha256:47c6b74ce3ca60c2d4eee8e65c65597e5f62fb420653fcaec310eaa51b472413 +generated: "2024-04-09T17:12:54.285532+02:00" diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 04a76d71..751459b4 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: {} + annotations: { } name: "" - podAnnotations: {} + podAnnotations: { } podSecurityContext: seccompProfile: type: RuntimeDefault @@ -85,7 +85,7 @@ microservice-chart: CLIENT_DECOUPLERCACHING_READ_TIMEOUT: '5000' CLIENT_CACHE_READ_TIMEOUT: '5000' CLIENT_GPD_HOST: 'https://api.dev.platform.pagopa.it/gpd/api/v1' - CLIENT_IUVGENERATOR_HOST: 'https://api.dev.platform.pagopa.it/shared/iuv-generator-service/v1' + CLIENT_IUVGENERATOR_HOST: 'https://api.dev.platform.pagopa.it/shared/pagopa-iuvgenerator/v1' CLIENT_CHECKOUT_HOST: 'https://api.dev.platform.pagopa.it/checkout/ec/v1/' CLIENT_DECOUPLERCACHING_HOST: 'https://api.dev.platform.pagopa.it/wisp-converter/caching/api/v1' CLIENT_CACHE_HOST: 'https://api.dev.platform.pagopa.it/api-config-cache/o/v1' @@ -106,8 +106,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -134,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: {} - envSecret: {} + envConfig: { } + envSecret: { } diff --git a/scripts/system-test/README.md b/scripts/system-test/README.md new file mode 100644 index 00000000..93d8d469 --- /dev/null +++ b/scripts/system-test/README.md @@ -0,0 +1,19 @@ +# System tests for pagoPA WISP Converter + +In order to correctly start the tests, first of all execute the command: + +```shell +npm install +``` + +Then, if the test must be executed in DEV environment, execute the command: + +```shell +npm run test:dev +``` + +Alternatively, if the test must be executed in UAT environment, execute the command: + +```shell +npm run test:uat +``` \ No newline at end of file diff --git a/scripts/system-test/config/.env.dev b/scripts/system-test/config/.env.dev new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/scripts/system-test/config/.env.dev @@ -0,0 +1 @@ + diff --git a/scripts/system-test/data/c.env b/scripts/system-test/data/c.env new file mode 100644 index 00000000..1838f53a --- /dev/null +++ b/scripts/system-test/data/c.env @@ -0,0 +1,3 @@ +creditor_institution_broker=77777777777 +creditor_institution=77777777777 +station=77777777777_01 \ No newline at end of file diff --git a/scripts/system-test/lib/client.js b/scripts/system-test/lib/client.js new file mode 100644 index 00000000..fee4596b --- /dev/null +++ b/scripts/system-test/lib/client.js @@ -0,0 +1,58 @@ +const axios = require("axios"); + +function call(method, url, body) { + if (method === 'GET') { + return get(url) + } + if (method === 'POST') { + return post(url, body) + } + if (method === 'PUT') { + return put(url, body) + } + if (method === 'DELETE') { + return del(url) + } +} + +function get(url) { + return axios.get(url) + .then(res => { + return res; + }) + .catch(error => { + return error.response; + }); +} + +function post(url, body) { + return axios.post(url, body) + .then(res => { + return res; + }) + .catch(error => { + return error.response; + }); +} + +function put(url, body) { + return axios.put(url, body) + .then(res => { + return res; + }) + .catch(error => { + return error.response; + }); +} + +function del(url) { + return axios.delete(url) + .then(res => { + return res; + }) + .catch(error => { + return error.response; + }); +} + +module.exports = {call} \ No newline at end of file diff --git a/scripts/system-test/lib/util.js b/scripts/system-test/lib/util.js new file mode 100644 index 00000000..e85b8493 --- /dev/null +++ b/scripts/system-test/lib/util.js @@ -0,0 +1,15 @@ + +function makeNumericalString(length) { + let result = ''; + const characters = '0123456789'; + const charactersLength = characters.length; + let counter = 0; + while (counter < length) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + counter += 1; + } + return result; +} + + +module.exports = {makeNumericalString} \ No newline at end of file diff --git a/scripts/system-test/package-lock.json b/scripts/system-test/package-lock.json new file mode 100644 index 00000000..80f643bc --- /dev/null +++ b/scripts/system-test/package-lock.json @@ -0,0 +1,207 @@ +{ + "name": "pagopa-wisp-converter-systemtest", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pagopa-wisp-converter-systemtest", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "axios": "^0.27.2", + "dotenv": "^16.0.2", + "dotenv-cli": "^3.2.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dotenv-cli": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-3.2.0.tgz", + "integrity": "sha512-zg/dfXISo7ntL3JKC+oj7eXEMg8LbOsARWTeypfVsmYtazDYOptmKLqA9u3LTee9x/sIPiLqmI6wskRP+89ohQ==", + "dependencies": { + "cross-spawn": "^7.0.1", + "dotenv": "^8.1.0", + "dotenv-expand": "^5.1.0", + "minimist": "^1.1.3" + }, + "bin": { + "dotenv": "cli.js" + } + }, + "node_modules/dotenv-cli/node_modules/dotenv": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", + "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", + "engines": { + "node": ">=10" + } + }, + "node_modules/dotenv-expand": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", + "integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==" + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + } + } +} diff --git a/scripts/system-test/package.json b/scripts/system-test/package.json new file mode 100644 index 00000000..fdaeb62a --- /dev/null +++ b/scripts/system-test/package.json @@ -0,0 +1,15 @@ +{ + "name": "pagopa-wisp-converter-systemtest", + "license": "MIT", + "version": "1.0.0", + "scripts": { + "test:local": "dotenv -e ./config/.env.local node start.js", + "test:dev": "dotenv -e ./config/.env.dev node start.js", + "test:uat": "dotenv -e ./config/.env.uat node start.js" + }, + "dependencies": { + "axios": "^0.27.2", + "dotenv": "^16.0.2", + "dotenv-cli": "^3.2.0" + } +} diff --git a/scripts/system-test/requests/complete_ok.js b/scripts/system-test/requests/complete_ok.js new file mode 100644 index 00000000..90f266e7 --- /dev/null +++ b/scripts/system-test/requests/complete_ok.js @@ -0,0 +1,106 @@ +const {makeNumericalString} = require("util") + +let nodoInviaRPT = ` + + + + ${creditorInstitutionBroker} + ${station} + ${creditorInstitution} + ${makeNumericalString} + CCD01 + + + + + pwdpwdpwd + ${psp} + ${pspBroker} + ${channel} + + ${atob(rpt)} + + + +`; + +let rpt = ` + + 6.0 + + 66666666666 + 66666666666_05 + + idMsgRichiesta + 2016-09-16T11:24:10 + CNS + + + F + RCCGLD09P09H501E + + Gesualdo;Riccitelli + via del gesu + 11 + 00186 + Roma + RM + IT + + + + F + RCCGLD09P09H501E + + Gesualdo;Riccitelli + via del gesu + 11 + 00186 + Roma + RM + IT + + + + G + 11111111117 + + AZIENDA XXX + 123 + XXX + IndirizzoBeneficiario + 123 + 00123 + Roma + RM + IT + + + 2016-09-16 + 10.00 + PO + 141577487701211 + CCD01 + IT45R0760103200000000001016 + ARTIITM1045 + 0 + + 10.00 + 1.00 + ARTIITM1050 + IT45R0760103200000000001016 + ARTIITM1050 + CP1.1 + pagamento fotocopie pratica RPT + 1/abc + + 01 + wHpFSLCGZjIvNSXxqtGbxg7275t446DRTk5ZrsdUQ6E= + MI + + + + +` + +module.exports = {nodoInviaRPT, rpt} \ No newline at end of file diff --git a/scripts/system-test/start.js b/scripts/system-test/start.js new file mode 100644 index 00000000..57784411 --- /dev/null +++ b/scripts/system-test/start.js @@ -0,0 +1,2 @@ + +console.log("pippo"); \ No newline at end of file From 5fa3545b2f1368856148d398bc659910e64af79e Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 10 Apr 2024 08:25:44 +0000 Subject: [PATCH 14/20] Bump to version 0.0.8-4-fixes-after-integration-test [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 14 +++++++------- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 9aa9bb7e..c35f5a1c 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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.12.0 -appVersion: 0.0.8-3-fixes-after-integration-test +version: 0.13.0 +appVersion: 0.0.8-4-fixes-after-integration-test dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 751459b4..f19c2253 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-3-fixes-after-integration-test" + tag: "0.0.8-4-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -106,8 +106,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -134,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } + envConfig: {} + envSecret: {} diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 7f5901b1..da437fe3 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-3-fixes-after-integration-test" + tag: "0.0.8-4-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 0b254b35..23078274 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-3-fixes-after-integration-test" + tag: "0.0.8-4-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index d0c23606..c45f380c 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -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.8-3-fixes-after-integration-test" + "version": "0.0.8-4-fixes-after-integration-test" }, "servers": [ { diff --git a/pom.xml b/pom.xml index d7462088..d1f2bddb 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 0.0.8-3-fixes-after-integration-test + 0.0.8-4-fixes-after-integration-test pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From e6aeea04c3d36983bb6a56379419207194125570 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Wed, 10 Apr 2024 10:52:29 +0200 Subject: [PATCH 15/20] fix: fixed missing ApiKey and wrong API calls flow --- helm/values-prod.yaml | 14 +++++++------- helm/values-uat.yaml | 14 +++++++------- .../config/client/APIConfigCacheClientConfig.java | 2 +- .../config/client/CheckoutClientConfig.java | 1 - .../exception/AppErrorCodeMessageEnum.java | 1 + .../wispconverter/service/CheckoutService.java | 3 +++ 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index da437fe3..81f1a6d9 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: {} + annotations: { } name: "" - podAnnotations: {} + podAnnotations: { } podSecurityContext: seccompProfile: type: RuntimeDefault @@ -87,7 +87,7 @@ microservice-chart: CLIENT_DECOUPLERCACHING_READ_TIMEOUT: '5000' CLIENT_CACHE_READ_TIMEOUT: '5000' CLIENT_GPD_HOST: 'https://api.platform.pagopa.it/gpd/api/v1' - CLIENT_IUVGENERATOR_HOST: 'https://api.platform.pagopa.it/shared/iuv-generator-service/v1' + CLIENT_IUVGENERATOR_HOST: 'https://api.platform.pagopa.it/shared/pagopa-iuvgenerator/v1' CLIENT_CHECKOUT_HOST: 'https://api.platform.pagopa.it/checkout/ec/v1/' CLIENT_DECOUPLERCACHING_HOST: 'https://api.platform.pagopa.it/wisp-converter/caching/api/v1' CLIENT_CACHE_HOST: 'https://api.platform.pagopa.it/api-config-cache/o/v1' @@ -108,8 +108,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -136,5 +136,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: {} - envSecret: {} + envConfig: { } + envSecret: { } diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 23078274..17588297 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: {} + annotations: { } name: "" - podAnnotations: {} + podAnnotations: { } podSecurityContext: seccompProfile: type: RuntimeDefault @@ -85,7 +85,7 @@ microservice-chart: CLIENT_DECOUPLERCACHING_READ_TIMEOUT: '5000' CLIENT_CACHE_READ_TIMEOUT: '5000' CLIENT_GPD_HOST: 'https://api.uat.platform.pagopa.it/gpd/api/v1' - CLIENT_IUVGENERATOR_HOST: 'https://api.uat.platform.pagopa.it/shared/iuv-generator-service/v1' + CLIENT_IUVGENERATOR_HOST: 'https://api.uat.platform.pagopa.it/shared/pagopa-iuvgenerator/v1' CLIENT_CHECKOUT_HOST: 'https://api.uat.platform.pagopa.it/checkout/ec/v1/' CLIENT_DECOUPLERCACHING_HOST: 'https://api.uat.platform.pagopa.it/wisp-converter/caching/api/v1' CLIENT_CACHE_HOST: 'https://api.uat.platform.pagopa.it/api-config-cache/o/v1' @@ -106,8 +106,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: {} - tolerations: [] + nodeSelector: { } + tolerations: [ ] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -134,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: {} - envSecret: {} + envConfig: { } + envSecret: { } diff --git a/src/main/java/it/gov/pagopa/wispconverter/config/client/APIConfigCacheClientConfig.java b/src/main/java/it/gov/pagopa/wispconverter/config/client/APIConfigCacheClientConfig.java index d4f800bb..3a165bde 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/config/client/APIConfigCacheClientConfig.java +++ b/src/main/java/it/gov/pagopa/wispconverter/config/client/APIConfigCacheClientConfig.java @@ -60,7 +60,7 @@ public it.gov.pagopa.gen.wispconverter.client.cache.invoker.ApiClient configCach it.gov.pagopa.gen.wispconverter.client.cache.invoker.ApiClient client = new it.gov.pagopa.gen.wispconverter.client.cache.invoker.ApiClient(restTemplate); client.setBasePath(basePath); -// client.setApiKey(apiKey); + client.setApiKey(apiKey); return client; } diff --git a/src/main/java/it/gov/pagopa/wispconverter/config/client/CheckoutClientConfig.java b/src/main/java/it/gov/pagopa/wispconverter/config/client/CheckoutClientConfig.java index 67fcff06..7d5d8ccd 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/config/client/CheckoutClientConfig.java +++ b/src/main/java/it/gov/pagopa/wispconverter/config/client/CheckoutClientConfig.java @@ -61,7 +61,6 @@ public it.gov.pagopa.gen.wispconverter.client.checkout.invoker.ApiClient checkou it.gov.pagopa.gen.wispconverter.client.checkout.invoker.ApiClient client = new it.gov.pagopa.gen.wispconverter.client.checkout.invoker.ApiClient(restTemplate); client.setBasePath(basePath); -// client.setApiKey(apiKey); return client; } diff --git a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java index a6122ff4..4ceaf22c 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java @@ -21,6 +21,7 @@ public enum AppErrorCodeMessageEnum { VALIDATION_INVALID_CREDITOR_INSTITUTION(1103, "Creditor institution not valid", "Error while generating debt position for GPD service. The creditor institution information is different between the various RPT of the cart.", HttpStatus.BAD_REQUEST), CONFIGURATION_INVALID_STATION(1200, "Station not valid", "Error while generating cart for Checkout service. No valid station found with code [{0}].", HttpStatus.NOT_FOUND), CONFIGURATION_INVALID_STATION_REDIRECT_URL(1201, "Station not valid", "Error while generating cart for Checkout service. The station with code [{0}] contains wrong redirect URL and it is not possible to generate valid URI.", HttpStatus.NOT_FOUND), + CONFIGURATION_INVALID_CACHE(1202, "Cache not valid", "Error while reading configuration cache. No valid cached configuration found.", HttpStatus.NOT_FOUND), // --- DB and storage interaction errors --- PERSISTENCE_RPT_NOT_FOUND(2000, "RPT not found", "Error while retrieving RPT. RPT with sessionId [{0}] not found.", HttpStatus.NOT_FOUND), PERSISTENCE_REQUESTID_CACHING_ERROR(2001, "RequestID caching error", "Error while caching RequestID. {0}", HttpStatus.UNPROCESSABLE_ENTITY), diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java b/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java index 8f8b8b9d..f9b99d97 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/CheckoutService.java @@ -65,6 +65,9 @@ public String executeCall(CommonRPTFieldsDTO commonRPTFieldsDTO) { private String getRedirectURL(String stationId) { it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto cache = configCacheService.getCache(); + if (cache == null) { + throw new AppException(AppErrorCodeMessageEnum.CONFIGURATION_INVALID_CACHE); + } Map stations = cache.getStations(); it.gov.pagopa.gen.wispconverter.client.cache.model.StationDto station = stations.get(stationId); if (station == null) { From 28cb524beb50450792da383a5d70f5234a46fdeb Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 10 Apr 2024 08:54:21 +0000 Subject: [PATCH 16/20] Bump to version 0.0.8-5-fixes-after-integration-test [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 14 +++++++------- helm/values-uat.yaml | 14 +++++++------- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index c35f5a1c..614bfe00 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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.13.0 -appVersion: 0.0.8-4-fixes-after-integration-test +version: 0.14.0 +appVersion: 0.0.8-5-fixes-after-integration-test dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index f19c2253..50da07ea 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-4-fixes-after-integration-test" + tag: "0.0.8-5-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 81f1a6d9..3a33a126 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-4-fixes-after-integration-test" + tag: "0.0.8-5-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -108,8 +108,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -136,5 +136,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } + envConfig: {} + envSecret: {} diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 17588297..a272b86b 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-4-fixes-after-integration-test" + tag: "0.0.8-5-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: @@ -34,9 +34,9 @@ microservice-chart: servicePort: 8080 serviceAccount: create: false - annotations: { } + annotations: {} name: "" - podAnnotations: { } + podAnnotations: {} podSecurityContext: seccompProfile: type: RuntimeDefault @@ -106,8 +106,8 @@ microservice-chart: tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" tmpVolumeMount: create: true - nodeSelector: { } - tolerations: [ ] + nodeSelector: {} + tolerations: [] affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -134,5 +134,5 @@ microservice-chart: repository: ghcr.io/pagopa/pagopa-wisp-converter tag: "0.0.0" pullPolicy: Always - envConfig: { } - envSecret: { } + envConfig: {} + envSecret: {} diff --git a/openapi/openapi.json b/openapi/openapi.json index c45f380c..ea3d8701 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -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.8-4-fixes-after-integration-test" + "version": "0.0.8-5-fixes-after-integration-test" }, "servers": [ { diff --git a/pom.xml b/pom.xml index d1f2bddb..45f908ec 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 0.0.8-4-fixes-after-integration-test + 0.0.8-5-fixes-after-integration-test pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From cf7a0942011f24784d0705aae168c1d04548cfc6 Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Thu, 11 Apr 2024 06:28:37 +0000 Subject: [PATCH 17/20] Bump to version 0.0.8-6-fixes-after-integration-test [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 614bfe00..1be78f85 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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.14.0 -appVersion: 0.0.8-5-fixes-after-integration-test +version: 0.15.0 +appVersion: 0.0.8-6-fixes-after-integration-test dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 50da07ea..49e9c3d2 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-5-fixes-after-integration-test" + tag: "0.0.8-6-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 3a33a126..ace382a0 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-5-fixes-after-integration-test" + tag: "0.0.8-6-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index a272b86b..c62544aa 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "0.0.8-5-fixes-after-integration-test" + tag: "0.0.8-6-fixes-after-integration-test" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index ea3d8701..b56c6b0c 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -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.8-5-fixes-after-integration-test" + "version": "0.0.8-6-fixes-after-integration-test" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 92ebc8f1..193bf575 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 0.0.8-5-fixes-after-integration-test + 0.0.8-6-fixes-after-integration-test pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From 1ab04c8b334874a7a7478f8e487caef96f55dfe5 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Thu, 11 Apr 2024 12:00:06 +0200 Subject: [PATCH 18/20] [NOD-817] feat: first working version of WISP dismantling tests --- scripts/system-test/README.md | 15 +- scripts/system-test/config/.env.dev | 1 - scripts/system-test/data/c.env | 3 - scripts/system-test/lib/util.js | 15 -- scripts/system-test/package-lock.json | 207 ------------------ scripts/system-test/requests/complete_ok.js | 106 --------- scripts/system-test/src/config/.env.dev | 4 + scripts/system-test/{ => src}/lib/client.js | 26 +-- scripts/system-test/src/lib/util.js | 36 +++ scripts/system-test/{ => src}/package.json | 3 +- .../src/requests/rpt/ko_withstamp.js | 139 ++++++++++++ .../src/requests/rpt/ok_nostamp.js | 142 ++++++++++++ scripts/system-test/src/start.js | 77 +++++++ scripts/system-test/start.js | 2 - 14 files changed, 425 insertions(+), 351 deletions(-) delete mode 100644 scripts/system-test/config/.env.dev delete mode 100644 scripts/system-test/data/c.env delete mode 100644 scripts/system-test/lib/util.js delete mode 100644 scripts/system-test/package-lock.json delete mode 100644 scripts/system-test/requests/complete_ok.js create mode 100644 scripts/system-test/src/config/.env.dev rename scripts/system-test/{ => src}/lib/client.js (55%) create mode 100644 scripts/system-test/src/lib/util.js rename scripts/system-test/{ => src}/package.json (87%) create mode 100644 scripts/system-test/src/requests/rpt/ko_withstamp.js create mode 100644 scripts/system-test/src/requests/rpt/ok_nostamp.js create mode 100644 scripts/system-test/src/start.js delete mode 100644 scripts/system-test/start.js diff --git a/scripts/system-test/README.md b/scripts/system-test/README.md index 93d8d469..f7ad1116 100644 --- a/scripts/system-test/README.md +++ b/scripts/system-test/README.md @@ -9,11 +9,20 @@ npm install Then, if the test must be executed in DEV environment, execute the command: ```shell -npm run test:dev +sh run.sh dev TESTCASE SUBKEY ``` Alternatively, if the test must be executed in UAT environment, execute the command: ```shell -npm run test:uat -``` \ No newline at end of file +sh run.sh uat TESTCASE SUBKEY +``` + +## Test cases + +You can choose one of the following test cases: + +| Outcome | Name | Primitive | Command | +|---------|----------------------------|--------------|-----------------------------------------| +| OK | NodoInviaRPT without Stamp | NodoInviaRPT | `sh run.sh ENV rpt_ok_nostamp SUBKEY` | +| KO | NodoInviaRPT with Stamp | NodoInviaRPT | `sh run.sh ENV rpt_ko_withstamp SUBKEY` | diff --git a/scripts/system-test/config/.env.dev b/scripts/system-test/config/.env.dev deleted file mode 100644 index 8b137891..00000000 --- a/scripts/system-test/config/.env.dev +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scripts/system-test/data/c.env b/scripts/system-test/data/c.env deleted file mode 100644 index 1838f53a..00000000 --- a/scripts/system-test/data/c.env +++ /dev/null @@ -1,3 +0,0 @@ -creditor_institution_broker=77777777777 -creditor_institution=77777777777 -station=77777777777_01 \ No newline at end of file diff --git a/scripts/system-test/lib/util.js b/scripts/system-test/lib/util.js deleted file mode 100644 index e85b8493..00000000 --- a/scripts/system-test/lib/util.js +++ /dev/null @@ -1,15 +0,0 @@ - -function makeNumericalString(length) { - let result = ''; - const characters = '0123456789'; - const charactersLength = characters.length; - let counter = 0; - while (counter < length) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - counter += 1; - } - return result; -} - - -module.exports = {makeNumericalString} \ No newline at end of file diff --git a/scripts/system-test/package-lock.json b/scripts/system-test/package-lock.json deleted file mode 100644 index 80f643bc..00000000 --- a/scripts/system-test/package-lock.json +++ /dev/null @@ -1,207 +0,0 @@ -{ - "name": "pagopa-wisp-converter-systemtest", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "pagopa-wisp-converter-systemtest", - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "axios": "^0.27.2", - "dotenv": "^16.0.2", - "dotenv-cli": "^3.2.0" - } - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", - "dependencies": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" - } - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/dotenv": { - "version": "16.4.5", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", - "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/dotenv-cli": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-3.2.0.tgz", - "integrity": "sha512-zg/dfXISo7ntL3JKC+oj7eXEMg8LbOsARWTeypfVsmYtazDYOptmKLqA9u3LTee9x/sIPiLqmI6wskRP+89ohQ==", - "dependencies": { - "cross-spawn": "^7.0.1", - "dotenv": "^8.1.0", - "dotenv-expand": "^5.1.0", - "minimist": "^1.1.3" - }, - "bin": { - "dotenv": "cli.js" - } - }, - "node_modules/dotenv-cli/node_modules/dotenv": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", - "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", - "engines": { - "node": ">=10" - } - }, - "node_modules/dotenv-expand": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", - "integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==" - }, - "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "engines": { - "node": ">=8" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - } - } -} diff --git a/scripts/system-test/requests/complete_ok.js b/scripts/system-test/requests/complete_ok.js deleted file mode 100644 index 90f266e7..00000000 --- a/scripts/system-test/requests/complete_ok.js +++ /dev/null @@ -1,106 +0,0 @@ -const {makeNumericalString} = require("util") - -let nodoInviaRPT = ` - - - - ${creditorInstitutionBroker} - ${station} - ${creditorInstitution} - ${makeNumericalString} - CCD01 - - - - - pwdpwdpwd - ${psp} - ${pspBroker} - ${channel} - - ${atob(rpt)} - - - -`; - -let rpt = ` - - 6.0 - - 66666666666 - 66666666666_05 - - idMsgRichiesta - 2016-09-16T11:24:10 - CNS - - - F - RCCGLD09P09H501E - - Gesualdo;Riccitelli - via del gesu - 11 - 00186 - Roma - RM - IT - - - - F - RCCGLD09P09H501E - - Gesualdo;Riccitelli - via del gesu - 11 - 00186 - Roma - RM - IT - - - - G - 11111111117 - - AZIENDA XXX - 123 - XXX - IndirizzoBeneficiario - 123 - 00123 - Roma - RM - IT - - - 2016-09-16 - 10.00 - PO - 141577487701211 - CCD01 - IT45R0760103200000000001016 - ARTIITM1045 - 0 - - 10.00 - 1.00 - ARTIITM1050 - IT45R0760103200000000001016 - ARTIITM1050 - CP1.1 - pagamento fotocopie pratica RPT - 1/abc - - 01 - wHpFSLCGZjIvNSXxqtGbxg7275t446DRTk5ZrsdUQ6E= - MI - - - - -` - -module.exports = {nodoInviaRPT, rpt} \ No newline at end of file diff --git a/scripts/system-test/src/config/.env.dev b/scripts/system-test/src/config/.env.dev new file mode 100644 index 00000000..9cfe74b4 --- /dev/null +++ b/scripts/system-test/src/config/.env.dev @@ -0,0 +1,4 @@ +wisp_converter_soap_host=https://api.dev.platform.pagopa.it/wisp-soap-converter/soap/v1 + +// temporary +wisp_converter_host=https://dev.wisp2.pagopa.it/wisp-converter/redirect/api/v1/payments?sessionId \ No newline at end of file diff --git a/scripts/system-test/lib/client.js b/scripts/system-test/src/lib/client.js similarity index 55% rename from scripts/system-test/lib/client.js rename to scripts/system-test/src/lib/client.js index fee4596b..6a5184a1 100644 --- a/scripts/system-test/lib/client.js +++ b/scripts/system-test/src/lib/client.js @@ -1,22 +1,22 @@ const axios = require("axios"); -function call(method, url, body) { +async function call(method, url, body, headers) { if (method === 'GET') { - return get(url) + return await get(url, headers) } if (method === 'POST') { - return post(url, body) + return await post(url, body, headers) } if (method === 'PUT') { - return put(url, body) + return await put(url, body, headers) } if (method === 'DELETE') { - return del(url) + return await del(url, headers) } } -function get(url) { - return axios.get(url) +async function get(url, headers) { + return await axios.get(url, headers) .then(res => { return res; }) @@ -25,8 +25,8 @@ function get(url) { }); } -function post(url, body) { - return axios.post(url, body) +async function post(url, body, headers) { + return await axios.post(url, body, headers) .then(res => { return res; }) @@ -35,8 +35,8 @@ function post(url, body) { }); } -function put(url, body) { - return axios.put(url, body) +async function put(url, body, headers) { + return await axios.put(url, body, headers) .then(res => { return res; }) @@ -45,8 +45,8 @@ function put(url, body) { }); } -function del(url) { - return axios.delete(url) +async function del(url, headers) { + return await axios.delete(url, headers) .then(res => { return res; }) diff --git a/scripts/system-test/src/lib/util.js b/scripts/system-test/src/lib/util.js new file mode 100644 index 00000000..63a8e00b --- /dev/null +++ b/scripts/system-test/src/lib/util.js @@ -0,0 +1,36 @@ + +function makeNumericalString(length) { + let result = ''; + const characters = '0123456789'; + const charactersLength = characters.length; + let counter = 0; + while (counter < length) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + counter += 1; + } + return result; +} + +function getCurrentDateTime() { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); + const day = String(now.getDate()).padStart(2, '0'); + const hours = String(now.getHours()).padStart(2, '0'); + const minutes = String(now.getMinutes()).padStart(2, '0'); + const seconds = String(now.getSeconds()).padStart(2, '0'); + + return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`; +} + +function getCurrentDate() { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); + const day = String(now.getDate()).padStart(2, '0'); + + return `${year}-${month}-${day}`; +} + + +module.exports = {makeNumericalString, getCurrentDateTime, getCurrentDate} \ No newline at end of file diff --git a/scripts/system-test/package.json b/scripts/system-test/src/package.json similarity index 87% rename from scripts/system-test/package.json rename to scripts/system-test/src/package.json index fdaeb62a..df9d17e7 100644 --- a/scripts/system-test/package.json +++ b/scripts/system-test/src/package.json @@ -10,6 +10,7 @@ "dependencies": { "axios": "^0.27.2", "dotenv": "^16.0.2", - "dotenv-cli": "^3.2.0" + "dotenv-cli": "^3.2.0", + "xmldom": "^0.6.0" } } diff --git a/scripts/system-test/src/requests/rpt/ko_withstamp.js b/scripts/system-test/src/requests/rpt/ko_withstamp.js new file mode 100644 index 00000000..0f4e3561 --- /dev/null +++ b/scripts/system-test/src/requests/rpt/ko_withstamp.js @@ -0,0 +1,139 @@ +const {getCurrentDate, getCurrentDateTime, makeNumericalString} = require("../../lib/util"); + +let values = { + creditorInstitutionBroker: "66666666666", + creditorInstitution: "66666666666", + station: "66666666666_05", + psp: "AGID_01", + pspBroker: "97735020584", + channel: "97735020584_03", + payerFiscalCode: "RSSMRA70A01H501Z", + payerName: "Mario Rossi", + payeeFiscalCode: "11111111117", + payerName: "Enel", + transfers: [ + { + totalAmount: "16.50", + iuv: makeNumericalString(15), + ccp: "CCD01", + debtorIban: "IT45R0760103200000000001016", + debtorBic: "ARTIITM1045", + singleTransfers: [ + { + amount: "16.00", + fee: "0.50", + payerInfo: "CP1.1", + paymentDescription: "Marca da bollo da 16 euro", + taxonomy: "9/0301109AP" + }, + ] + } + ] + } + +function getNodoInviaRPT() { + let rpt = btoa(getRPT()); + return ` + + + + ${values.creditorInstitutionBroker} + ${values.station} + ${values.creditorInstitution} + ${values.transfers[0].iuv} + CCD01 + + + + + pwdpwdpwd + ${values.psp} + ${values.pspBroker} + ${values.channel} + + ${rpt} + + + + `; +} + +function getRPT() { + return ` + + 6.0 + + ${values.creditorInstitution} + ${values.station} + + systemtest + ${getCurrentDateTime()} + CNS + + + F + ${values.payerFiscalCode} + + ${values.payerName} + via Roma + 1 + 00186 + Roma + RM + IT + + + + F + ${values.payerFiscalCode} + + ${values.payerName} + via Roma + 1 + 00186 + Roma + RM + IT + + + + G + ${values.payeeFiscalCode} + + ${values.payeeName} + 123 + XXX + via Napoleone + 1 + 00123 + Roma + RM + IT + + + ${getCurrentDate()} + ${values.transfers[0].totalAmount} + PO + ${values.transfers[0].iuv} + ${values.transfers[0].ccp} + ${values.transfers[0].debtorIban} + ${values.transfers[0].debtorBic} + 0 + + ${values.transfers[0].singleTransfers[0].amount} + ${values.transfers[0].singleTransfers[0].fee} + ${values.transfers[0].singleTransfers[0].payerInfo} + ${values.transfers[0].singleTransfers[0].paymentDescription} + ${values.transfers[0].singleTransfers[0].taxonomy} + + 01 + wHpFSLCGZjIvNSXxqtGbxg7275t446DRTk5ZrsdUQ6E= + RM + + + + + `; +} + +module.exports = {getNodoInviaRPT} \ No newline at end of file diff --git a/scripts/system-test/src/requests/rpt/ok_nostamp.js b/scripts/system-test/src/requests/rpt/ok_nostamp.js new file mode 100644 index 00000000..ba117a48 --- /dev/null +++ b/scripts/system-test/src/requests/rpt/ok_nostamp.js @@ -0,0 +1,142 @@ +const {getCurrentDate, getCurrentDateTime, makeNumericalString} = require("../../lib/util"); + +let values = { + creditorInstitutionBroker: "66666666666", + creditorInstitution: "66666666666", + station: "66666666666_05", + psp: "AGID_01", + pspBroker: "97735020584", + channel: "97735020584_03", + payerFiscalCode: "RSSMRA70A01H501Z", + payerName: "Mario Rossi", + payeeFiscalCode: "11111111117", + payerName: "Enel", + transfers: [ + { + totalAmount: "100.00", + iuv: makeNumericalString(15), + ccp: "CCD01", + debtorIban: "IT45R0760103200000000001016", + debtorBic: "ARTIITM1045", + singleTransfers: [ + { + amount: "100.00", + fee: "1.00", + creditorBic: "ARTIITM1050", + creditorIban: "IT45R0760103200000000001016", + creditorBic2: "ARTIITM1050", + creditorIban2: "IT45R0760103200000000001016", + payerInfo: "CP1.1", + paymentDescription: "Donazione casa di cura comunale", + taxonomy: "9/0301109AP" + } + ] + } + ] + } + +function getNodoInviaRPT() { + let rpt = btoa(getRPT()); + return ` + + + + ${values.creditorInstitutionBroker} + ${values.station} + ${values.creditorInstitution} + ${values.transfers[0].iuv} + CCD01 + + + + + pwdpwdpwd + ${values.psp} + ${values.pspBroker} + ${values.channel} + + ${rpt} + + + + `; +} + +function getRPT() { + return ` + + 6.0 + + ${values.creditorInstitution} + ${values.station} + + systemtest + ${getCurrentDateTime()} + CNS + + + F + ${values.payerFiscalCode} + + ${values.payerName} + via Roma + 1 + 00186 + Roma + RM + IT + + + + F + ${values.payerFiscalCode} + + ${values.payerName} + via Roma + 1 + 00186 + Roma + RM + IT + + + + G + ${values.payeeFiscalCode} + + ${values.payeeName} + 123 + XXX + via Napoleone + 1 + 00123 + Roma + RM + IT + + + ${getCurrentDate()} + ${values.transfers[0].totalAmount} + PO + ${values.transfers[0].iuv} + ${values.transfers[0].ccp} + ${values.transfers[0].debtorIban} + ${values.transfers[0].debtorBic} + 0 + + ${values.transfers[0].singleTransfers[0].amount} + ${values.transfers[0].singleTransfers[0].fee} + ${values.transfers[0].singleTransfers[0].creditorIban} + ${values.transfers[0].singleTransfers[0].creditorBic} + ${values.transfers[0].singleTransfers[0].creditorIban2} + ${values.transfers[0].singleTransfers[0].creditorBic2} + ${values.transfers[0].singleTransfers[0].payerInfo} + ${values.transfers[0].singleTransfers[0].paymentDescription} + ${values.transfers[0].singleTransfers[0].taxonomy} + + + + `; +} + +module.exports = {getNodoInviaRPT} \ No newline at end of file diff --git a/scripts/system-test/src/start.js b/scripts/system-test/src/start.js new file mode 100644 index 00000000..1f89b35d --- /dev/null +++ b/scripts/system-test/src/start.js @@ -0,0 +1,77 @@ +const {getNodoInviaRPT: get_RPT_OK_nostamp} = require("./requests/rpt/ok_nostamp"); +const {getNodoInviaRPT: get_RPT_KO_withstamp} = require("./requests/rpt/ko_withstamp"); + +const {call} = require("./lib/client"); +const {DOMParser} = require('xmldom'); +const {env} = require("dotenv"); + + +const nodoInviaRPTPrimitive = "NodoInviaRPT"; +const nodoInviaCarrelloRPTPrimitive = "NodoInviaCarrelloRPT"; + +const file = process.argv[2]; +const subkey = process.argv[3]; +main(); + + +async function main() { + + let request = getRequest(); + let responseFromSOAPConverter = await callWispSoapConverter(request); + + 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"); + } + + if (isOK) { + // 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('==Response:==\nStatus: [', responseFromConverter.status, ']\n'); + if (responseFromConverter.status !== 200) { + console.log(responseFromConverter.data); + } + console.log('\n=====================\n'); + } +} + +function getRequest() { + let request; + switch(file) { + case "rpt_ok_nostamp": + request = [nodoInviaRPTPrimitive, get_RPT_OK_nostamp()]; + break; + case "rpt_ko_withstamp": + request = [nodoInviaRPTPrimitive, get_RPT_KO_withstamp()]; + break; + default: + throw "\nTEST CASE NOT FOUND!\n" + break; + } + return request; +} + +async function callWispSoapConverter(request) { + console.log('==Request:==\nContent: ', request[1], "\n=====================\n"); + let headers = { + "SOAPAction": request[0], + "Ocp-Apim-Subscription-Key": subkey + } + return await call("POST", process.env.wisp_converter_soap_host, request[1], headers); +} \ No newline at end of file diff --git a/scripts/system-test/start.js b/scripts/system-test/start.js deleted file mode 100644 index 57784411..00000000 --- a/scripts/system-test/start.js +++ /dev/null @@ -1,2 +0,0 @@ - -console.log("pippo"); \ No newline at end of file From 9cf396e5fceb6bad4cd7f035f9f0138b8ba2841e Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Thu, 11 Apr 2024 12:02:01 +0200 Subject: [PATCH 19/20] [NOD-817] feat: first working version of WISP dismantling tests --- scripts/system-test/run.sh | 6 + scripts/system-test/src/package-lock.json | 216 ++++++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 scripts/system-test/run.sh create mode 100644 scripts/system-test/src/package-lock.json diff --git a/scripts/system-test/run.sh b/scripts/system-test/run.sh new file mode 100644 index 00000000..1eadd9b9 --- /dev/null +++ b/scripts/system-test/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd ./src || exit +npm install +clear +npm run test:"$1" "$2" "$3" \ No newline at end of file diff --git a/scripts/system-test/src/package-lock.json b/scripts/system-test/src/package-lock.json new file mode 100644 index 00000000..a5629d11 --- /dev/null +++ b/scripts/system-test/src/package-lock.json @@ -0,0 +1,216 @@ +{ + "name": "pagopa-wisp-converter-systemtest", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pagopa-wisp-converter-systemtest", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "axios": "^0.27.2", + "dotenv": "^16.0.2", + "dotenv-cli": "^3.2.0", + "xmldom": "^0.6.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dotenv-cli": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-3.2.0.tgz", + "integrity": "sha512-zg/dfXISo7ntL3JKC+oj7eXEMg8LbOsARWTeypfVsmYtazDYOptmKLqA9u3LTee9x/sIPiLqmI6wskRP+89ohQ==", + "dependencies": { + "cross-spawn": "^7.0.1", + "dotenv": "^8.1.0", + "dotenv-expand": "^5.1.0", + "minimist": "^1.1.3" + }, + "bin": { + "dotenv": "cli.js" + } + }, + "node_modules/dotenv-cli/node_modules/dotenv": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", + "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", + "engines": { + "node": ">=10" + } + }, + "node_modules/dotenv-expand": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", + "integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==" + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/xmldom": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.6.0.tgz", + "integrity": "sha512-iAcin401y58LckRZ0TkI4k0VSM1Qg0KGSc3i8rU+xrxe19A/BN1zHyVSJY7uoutVlaTSzYyk/v5AmkewAP7jtg==", + "engines": { + "node": ">=10.0.0" + } + } + } +} From 0a703cce5180cccb556e7db6ffcfc1820f47900c Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Thu, 11 Apr 2024 12:24:09 +0200 Subject: [PATCH 20/20] feat: new method for retrieve cached session id from Redis --- .../exception/AppErrorCodeMessageEnum.java | 2 +- .../wispconverter/repository/CacheRepository.java | 11 +++++++++++ .../pagopa/wispconverter/service/CacheService.java | 13 ++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java index 4ceaf22c..6288c2d6 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java @@ -24,7 +24,7 @@ public enum AppErrorCodeMessageEnum { CONFIGURATION_INVALID_CACHE(1202, "Cache not valid", "Error while reading configuration cache. No valid cached configuration found.", HttpStatus.NOT_FOUND), // --- DB and storage interaction errors --- PERSISTENCE_RPT_NOT_FOUND(2000, "RPT not found", "Error while retrieving RPT. RPT with sessionId [{0}] not found.", HttpStatus.NOT_FOUND), - PERSISTENCE_REQUESTID_CACHING_ERROR(2001, "RequestID caching error", "Error while caching RequestID. {0}", HttpStatus.UNPROCESSABLE_ENTITY), + PERSISTENCE_REQUESTID_CACHING_ERROR(2001, "RequestID caching error", "Error while reading cached RequestID. No valid value found for key [{0}].", HttpStatus.UNPROCESSABLE_ENTITY), // --- Client errors --- CLIENT_APICONFIGCACHE(3000, "APIConfig cache client error", "Error while communicating with APIConfig cache service. {0}", HttpStatus.EXPECTATION_FAILED), CLIENT_GPD(3001, "GPD client error", "Error while communicating with GPD service. {0}", HttpStatus.EXPECTATION_FAILED), diff --git a/src/main/java/it/gov/pagopa/wispconverter/repository/CacheRepository.java b/src/main/java/it/gov/pagopa/wispconverter/repository/CacheRepository.java index 5cdea116..05a733cc 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/repository/CacheRepository.java +++ b/src/main/java/it/gov/pagopa/wispconverter/repository/CacheRepository.java @@ -19,4 +19,15 @@ public class CacheRepository { public void insert(String key, String value, long ttlInMinutes) { this.redisSimpleTemplate.opsForValue().set(key, value, Duration.ofMinutes(ttlInMinutes)); } + + public T read(String key, Class clazz) { + T result = null; + try { + Object value = this.redisSimpleTemplate.opsForValue().get(key); + result = clazz.cast(value); + } catch (ClassCastException e) { + log.error(String.format("Cannot correctly parse the object retrieved with key [%s] in [%s] class", key, clazz.getCanonicalName())); + } + return result; + } } \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java index 86f2a211..320a5cfb 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/CacheService.java @@ -1,6 +1,5 @@ package it.gov.pagopa.wispconverter.service; -import io.lettuce.core.RedisException; import it.gov.pagopa.wispconverter.exception.AppErrorCodeMessageEnum; import it.gov.pagopa.wispconverter.exception.AppException; import it.gov.pagopa.wispconverter.repository.CacheRepository; @@ -57,8 +56,16 @@ public void storeRequestMappingInCache(CommonRPTFieldsDTO commonRPTFieldsDTO, St this.cacheRepository.insert(requestIDForRTHandling, sessionId, this.requestIDMappingTTL); } } catch (RestClientException e) { - throw new AppException(AppErrorCodeMessageEnum.CLIENT_DECOUPLER_CACHING, - String.format("RestClientException ERROR [%s] - %s", e.getCause().getClass().getCanonicalName(), e.getMessage())); + throw new AppException(AppErrorCodeMessageEnum.CLIENT_DECOUPLER_CACHING, String.format("RestClientException ERROR [%s] - %s", e.getCause().getClass().getCanonicalName(), e.getMessage())); } } + + public String getCachedSessionId(String creditorInstitutionId, String iuv) { + String cachedKey = String.format(CACHING_KEY_TEMPLATE, creditorInstitutionId, iuv); + String sessionId = this.cacheRepository.read(cachedKey, String.class); + if (sessionId == null) { + throw new AppException(AppErrorCodeMessageEnum.PERSISTENCE_REQUESTID_CACHING_ERROR, cachedKey); + } + return sessionId; + } }