From ee9c2e93c9d8a79e5d7b2caa47944a753c111fea Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 13 Mar 2024 08:25:10 +0000 Subject: [PATCH 1/2] [PAGOPA-1497] int test: first impl --- helm/Chart.yaml | 4 +-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- .../gpd_payments.activate_phase.feature | 16 ++++----- .../support/clients/api_config_client.js | 23 ++++++++++-- .../support/logic/gpd_logic.js | 30 +++++++++++++--- .../support/utility/request_builders.js | 35 ++++++++++++++++++- openapi/openapi.json | 2 +- pom.xml | 2 +- 10 files changed, 95 insertions(+), 23 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 34c5b840..a9327f79 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-payments description: Microservice that exposes API for payment receipts retrieving and other operations type: application -version: 0.75.0 -appVersion: 0.12.11 +version: 0.76.0 +appVersion: 0.12.12 dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 2dcfc3fc..9423b7d8 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-payments - tag: "0.12.11" + tag: "0.12.12" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index e6058d87..4a1be3f4 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-payments - tag: "0.12.11" + tag: "0.12.12" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 355ca5f8..557e9fc8 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-payments - tag: "0.12.11" + tag: "0.12.12" pullPolicy: Always livenessProbe: httpGet: diff --git a/integration-test/src/features/gpd_payments.activate_phase.feature b/integration-test/src/features/gpd_payments.activate_phase.feature index a4772067..63c33dff 100644 --- a/integration-test/src/features/gpd_payments.activate_phase.feature +++ b/integration-test/src/features/gpd_payments.activate_phase.feature @@ -4,7 +4,7 @@ Feature: All about Activate Phase on Debt Position Payments workflow Given Payments running And GPD running And ApiConfig running - And the creditor institution "77777777777" + And the creditor institution "83463829129" And the creditor institution broker "15376371009" And the station "15376371009_01" And a valid debt position @@ -17,10 +17,10 @@ Feature: All about Activate Phase on Debt Position Payments workflow Then the client receives status code 200 And the client receives a KO with the "PPT_DOMINIO_SCONOSCIUTO" fault code error - @GPDScenario - Scenario: Activate phase - Success - Given a valid fiscal code - When the client sends the ActivatePaymentNoticeRequest to Nodo - Then the client receives status code 200 - And the client receives an OK in the response - And the payment token is extracted +# @GPDScenario +# Scenario: Activate phase - Success +# Given a valid fiscal code +# When the client sends the ActivatePaymentNoticeRequest to Nodo +# Then the client receives status code 200 +# And the client receives an OK in the response +# And the payment token is extracted diff --git a/integration-test/src/step_definitions/support/clients/api_config_client.js b/integration-test/src/step_definitions/support/clients/api_config_client.js index c6b19d29..7a6c807b 100644 --- a/integration-test/src/step_definitions/support/clients/api_config_client.js +++ b/integration-test/src/step_definitions/support/clients/api_config_client.js @@ -19,8 +19,25 @@ function readCreditorInstitution(orgId) { }) } +function createCreditorInstitution(body) { + return post(api_config_host + `/creditorinstitutions`, body, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + + function readCreditorInstitutionIbans(orgId) { - return get(api_config_host + `/creditorinstitutions/${orgId}/ibans`, { + return get(api_config_host + `/creditorinstitutions/${orgId}/ibans/enhanced`, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + +function createCreditorInstitutionIbans(orgId, body) { + return post(api_config_host + `/creditorinstitutions/${orgId}/ibans`, body, { headers: { "Ocp-Apim-Subscription-Key": process.env.SUBKEY } @@ -57,5 +74,7 @@ module.exports = { readCreditorInstitutionBroker, readCreditorInstitutionIbans, readECStationAssociation, - readStation + readStation, + createCreditorInstitution, + createCreditorInstitutionIbans } diff --git a/integration-test/src/step_definitions/support/logic/gpd_logic.js b/integration-test/src/step_definitions/support/logic/gpd_logic.js index 8a97c045..272aa373 100644 --- a/integration-test/src/step_definitions/support/logic/gpd_logic.js +++ b/integration-test/src/step_definitions/support/logic/gpd_logic.js @@ -5,6 +5,8 @@ const { readCreditorInstitutionIbans, readECStationAssociation, readStation, + createCreditorInstitution, + createCreditorInstitutionIbans } = require("../clients/api_config_client"); const { createDebtPosition, @@ -27,7 +29,9 @@ const { buildSendPaymentOutcomeRequest, buildSendRTRequest, buildGetPaymentReq, - buildGetPaymentV2Req + buildGetPaymentV2Req, + buildApiConfigServiceCreationCIRequest, + buildApiConfigServiceCreationIbansRequest } = require("../utility/request_builders"); @@ -68,12 +72,21 @@ async function readCreditorInstitutionBrokerInfo(bundle, brokerId) { } async function readCreditorInstitutionInfo(bundle, creditorInstitutionId) { - readAndValidateCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); + await readAndValidateCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); bundle.organizationCode = creditorInstitutionId; - readValidCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); + await readValidCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); response = await readCreditorInstitutionIbans(bundle.organizationCode); - assert.ok(response.data.ibans[0] !== undefined); - bundle.debtPosition.iban = response.data.ibans[0].iban; + // if there is no iban connected to the CI, it is created + if (response.data.ibans_enhanced.length == 0) { + let body = buildApiConfigServiceCreationIbansRequest(new Date(new Date().setDate(new Date().getDate() + 7)).toISOString(), + new Date(new Date().setDate(new Date().getDate() + 1)).toISOString()); + response = await createCreditorInstitutionIbans(bundle.organizationCode, body); + assert.strictEqual(response.status, 201); + bundle.debtPosition.iban = response.data.iban; + } else { + assert.ok(response.data.ibans_enhanced[0] !== undefined); + bundle.debtPosition.iban = response.data.ibans_enhanced[0].iban; + } } async function readStationInfo(bundle, stationId) { @@ -96,6 +109,13 @@ async function readValidCreditorInstitutionInfo(bundle) { async function readAndValidateCreditorInstitutionInfo(bundle, organizationCode, status) { bundle.debtPosition.fiscalCode = organizationCode; let response = await readCreditorInstitution(bundle.debtPosition.fiscalCode); + // if the test Creditor Institution does not exist, it is created + if (response.status == 404){ + // new expected state check + status = 201; + let body = buildApiConfigServiceCreationCIRequest(organizationCode); + let response = await createCreditorInstitution(body); + } assert.strictEqual(response.status, status); } diff --git a/integration-test/src/step_definitions/support/utility/request_builders.js b/integration-test/src/step_definitions/support/utility/request_builders.js index 38fbe108..1225684e 100644 --- a/integration-test/src/step_definitions/support/utility/request_builders.js +++ b/integration-test/src/step_definitions/support/utility/request_builders.js @@ -39,6 +39,7 @@ function buildGPSOrganizationCreationRequest(serviceId) { }; } + function buildDemandPaymentNoticeRequest(gpsSessionBundle) { const organizationCode = gpsSessionBundle.organizationCode; const brokerCode = gpsSessionBundle.brokerCode; @@ -400,6 +401,36 @@ function buildGetPaymentV2Req(gpdSessionBundle, fiscalCode) { `; } + + function buildApiConfigServiceCreationCIRequest(creditorInstitutionCode){ + return { + "address": { + "city": "Lorem", + "country_code": "RM", + "location": "Via delle vie 3", + "tax_domicile": "string", + "zip_code": "00187" + }, + "business_name": "Comune di Lorem Ipsum", + "cbill_code": "1234567890100", + "creditor_institution_code": creditorInstitutionCode, + "enabled": true, + "psp_payment": true, + "reporting_ftp": false, + "reporting_zip": false + }; + } + + function buildApiConfigServiceCreationIbansRequest(dueDate, validityDate){ + return { + "description": "Riscossione Tributi", + "due_date": dueDate, + "iban": "IT99C0222211111000000000000", + "is_active": true, + "labels": [], + "validity_date": validityDate + }; + } module.exports = { @@ -413,5 +444,7 @@ module.exports = { buildSendRTRequest, buildVerifyPaymentNoticeRequest, buildGetPaymentReq, - buildGetPaymentV2Req + buildGetPaymentV2Req, + buildApiConfigServiceCreationCIRequest, + buildApiConfigServiceCreationIbansRequest } \ No newline at end of file diff --git a/openapi/openapi.json b/openapi/openapi.json index adc4589a..554d3bbe 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "PagoPA API Payments", "description": "Payments", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.12.11" + "version": "0.12.12" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 211136b5..6201802c 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa payments - 0.12.11 + 0.12.12 Payments Payments From 19189949f612ae375106282cc51c2319b0b9c60b Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 13 Mar 2024 08:25:10 +0000 Subject: [PATCH 2/2] [PAGOPA-1497] int test: work impl --- helm/Chart.yaml | 4 +- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- integration-test/src/config/.env.dev | 3 +- integration-test/src/config/.env.local | 1 + integration-test/src/config/.env.uat | 3 +- .../gpd_payments.activate_phase.feature | 3 +- .../gpd_payments.get_payment_phase.feature | 3 +- .../gpd_payments.send_receipt_phase.feature | 3 +- .../gpd_payments.verify_phase.feature | 3 +- .../support/clients/api_config_client.js | 59 +++++++++- .../support/logic/gpd_logic.js | 99 ++++++++++++++--- .../src/step_definitions/support/steps.js | 8 +- .../support/utility/request_builders.js | 101 +++++++++++++++++- openapi/openapi.json | 2 +- pom.xml | 2 +- 17 files changed, 268 insertions(+), 32 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 34c5b840..a9327f79 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-gpd-payments description: Microservice that exposes API for payment receipts retrieving and other operations type: application -version: 0.75.0 -appVersion: 0.12.11 +version: 0.76.0 +appVersion: 0.12.12 dependencies: - name: microservice-chart version: 2.4.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 2dcfc3fc..9423b7d8 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-payments - tag: "0.12.11" + tag: "0.12.12" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index e6058d87..4a1be3f4 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-payments - tag: "0.12.11" + tag: "0.12.12" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 355ca5f8..557e9fc8 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-gpd-payments - tag: "0.12.11" + tag: "0.12.12" pullPolicy: Always livenessProbe: httpGet: diff --git a/integration-test/src/config/.env.dev b/integration-test/src/config/.env.dev index c3960722..e89f20f2 100644 --- a/integration-test/src/config/.env.dev +++ b/integration-test/src/config/.env.dev @@ -7,10 +7,11 @@ api_config_host=https://api.dev.platform.pagopa.it/apiconfig/auth/api/v1 gpd_host=https://api.dev.platform.pagopa.it/gpd/api/v1 nodo_host=https://api.dev.platform.pagopa.it/nodo -invalid_creditor_institution=00112233445 +invalid_creditor_institution=00112233555 pspId=AGID_01 pspBrokerId=97735020584 pspChannelId=97735020584_03 pspName=AgID pspFiscalCode=CFAGID_01 pspPassword=pwdpwdpwd +ip=api.dev.platform.pagopa.it diff --git a/integration-test/src/config/.env.local b/integration-test/src/config/.env.local index 7d1b0434..767cdc88 100644 --- a/integration-test/src/config/.env.local +++ b/integration-test/src/config/.env.local @@ -14,3 +14,4 @@ pspChannelId=97735020584_03 pspName=AgID pspFiscalCode=CFAGID_01 pspPassword=pwdpwdpwd +ip=api.dev.platform.pagopa.it diff --git a/integration-test/src/config/.env.uat b/integration-test/src/config/.env.uat index 9d853c45..0cf892bd 100644 --- a/integration-test/src/config/.env.uat +++ b/integration-test/src/config/.env.uat @@ -12,4 +12,5 @@ pspId=AGID_02 pspBrokerId=97735020584 pspChannelId=97735020584_05 pspName=PSP_Agid -pspPassword=pwd_AgID \ No newline at end of file +pspPassword=pwd_AgID +ip=api.uat.platform.pagopa.it \ No newline at end of file diff --git a/integration-test/src/features/gpd_payments.activate_phase.feature b/integration-test/src/features/gpd_payments.activate_phase.feature index a4772067..b5feb0ad 100644 --- a/integration-test/src/features/gpd_payments.activate_phase.feature +++ b/integration-test/src/features/gpd_payments.activate_phase.feature @@ -6,7 +6,8 @@ Feature: All about Activate Phase on Debt Position Payments workflow And ApiConfig running And the creditor institution "77777777777" And the creditor institution broker "15376371009" - And the station "15376371009_01" + And the station "15376371009_01" for the broker "15376371009" + And if necessary, refresh the configuration and wait 30 seconds And a valid debt position And a proper verification of debt position diff --git a/integration-test/src/features/gpd_payments.get_payment_phase.feature b/integration-test/src/features/gpd_payments.get_payment_phase.feature index a6a33045..5cf5ba50 100644 --- a/integration-test/src/features/gpd_payments.get_payment_phase.feature +++ b/integration-test/src/features/gpd_payments.get_payment_phase.feature @@ -6,7 +6,8 @@ Feature: All about Activate Phase on Debt Position Payments workflow And ApiConfig running And the creditor institution "77777777777" And the creditor institution broker "15376371009" - And the station "15376371009_01" + And the station "15376371009_01" for the broker "15376371009" + And if necessary, refresh the configuration and wait 30 seconds And a valid debt position @GPDScenario diff --git a/integration-test/src/features/gpd_payments.send_receipt_phase.feature b/integration-test/src/features/gpd_payments.send_receipt_phase.feature index 84bbb668..5d2150f3 100644 --- a/integration-test/src/features/gpd_payments.send_receipt_phase.feature +++ b/integration-test/src/features/gpd_payments.send_receipt_phase.feature @@ -6,7 +6,8 @@ Feature: All about Send Receipt Phase on Debt Position Payments workflow And ApiConfig running And the creditor institution "77777777777" And the creditor institution broker "15376371009" - And the station "15376371009_01" + And the station "15376371009_01" for the broker "15376371009" + And if necessary, refresh the configuration and wait 30 seconds And a valid debt position And a proper verification of debt position And a proper activation of debt position diff --git a/integration-test/src/features/gpd_payments.verify_phase.feature b/integration-test/src/features/gpd_payments.verify_phase.feature index 28f20aef..b9cac009 100644 --- a/integration-test/src/features/gpd_payments.verify_phase.feature +++ b/integration-test/src/features/gpd_payments.verify_phase.feature @@ -6,7 +6,8 @@ Feature: All about Verify Phase on Debt Position Payments workflow And ApiConfig running And the creditor institution "77777777777" And the creditor institution broker "15376371009" - And the station "15376371009_01" + And the station "15376371009_01" for the broker "15376371009" + And if necessary, refresh the configuration and wait 30 seconds And a valid debt position @GPDScenario diff --git a/integration-test/src/step_definitions/support/clients/api_config_client.js b/integration-test/src/step_definitions/support/clients/api_config_client.js index c6b19d29..bceb3249 100644 --- a/integration-test/src/step_definitions/support/clients/api_config_client.js +++ b/integration-test/src/step_definitions/support/clients/api_config_client.js @@ -19,8 +19,25 @@ function readCreditorInstitution(orgId) { }) } +function createCreditorInstitution(body) { + return post(api_config_host + `/creditorinstitutions`, body, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + + function readCreditorInstitutionIbans(orgId) { - return get(api_config_host + `/creditorinstitutions/${orgId}/ibans`, { + return get(api_config_host + `/creditorinstitutions/${orgId}/ibans/enhanced`, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + +function createCreditorInstitutionIbans(orgId, body) { + return post(api_config_host + `/creditorinstitutions/${orgId}/ibans`, body, { headers: { "Ocp-Apim-Subscription-Key": process.env.SUBKEY } @@ -35,6 +52,14 @@ function readCreditorInstitutionBroker(brokerId) { }) } +function createCreditorInstitutionBroker(body) { + return post(api_config_host + `/brokers`, body, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + function readStation(stationId) { return get(api_config_host + `/stations/${stationId}`, { headers: { @@ -43,6 +68,14 @@ function readStation(stationId) { }) } +function createStation(body) { + return post(api_config_host + `/stations`, body, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + function readECStationAssociation(stationId, orgId) { return get(api_config_host + `/stations/${stationId}/creditorinstitutions/${orgId}`, { headers: { @@ -51,11 +84,33 @@ function readECStationAssociation(stationId, orgId) { }) } +function createECStationAssociation(orgId, body) { + return post(api_config_host + `/creditorinstitutions/${orgId}/stations`, body, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + +function refreshConfig() { + return get(api_config_host + `/refresh/config`, { + headers: { + "Ocp-Apim-Subscription-Key": process.env.SUBKEY + } + }) +} + module.exports = { apiConfigHealthCheck, readCreditorInstitution, readCreditorInstitutionBroker, readCreditorInstitutionIbans, readECStationAssociation, - readStation + readStation, + createCreditorInstitution, + createCreditorInstitutionIbans, + createCreditorInstitutionBroker, + createStation, + createECStationAssociation, + refreshConfig } diff --git a/integration-test/src/step_definitions/support/logic/gpd_logic.js b/integration-test/src/step_definitions/support/logic/gpd_logic.js index 8a97c045..5bb86364 100644 --- a/integration-test/src/step_definitions/support/logic/gpd_logic.js +++ b/integration-test/src/step_definitions/support/logic/gpd_logic.js @@ -5,6 +5,12 @@ const { readCreditorInstitutionIbans, readECStationAssociation, readStation, + createCreditorInstitution, + createCreditorInstitutionIbans, + createCreditorInstitutionBroker, + createStation, + createECStationAssociation, + refreshConfig } = require("../clients/api_config_client"); const { createDebtPosition, @@ -27,10 +33,17 @@ const { buildSendPaymentOutcomeRequest, buildSendRTRequest, buildGetPaymentReq, - buildGetPaymentV2Req + buildGetPaymentV2Req, + buildApiConfigServiceCreationCIRequest, + buildApiConfigServiceCreationIbansRequest, + buildApiConfigServiceCreationBrokerRequest, + buildApiConfigServiceCreationStationRequest, + buildApiConfigServiceCreationECStationAssociation } = require("../utility/request_builders"); +let toRefresh = false; + async function assertPaymentTokenExistence(bundle) { let paymentTokenRegExp = /([a-z0-9]+)<\/paymentToken>/ @@ -62,26 +75,59 @@ async function executeDebtPositionVerificationAndActivation(bundle) { } async function readCreditorInstitutionBrokerInfo(bundle, brokerId) { + let status = 200; let response = await readCreditorInstitutionBroker(brokerId); - assert.strictEqual(response.status, 200); + // if the test broker does not exist, it is created + if (response.status == 404){ + toRefresh = true; + // new expected state check + status = 201; + let body = buildApiConfigServiceCreationBrokerRequest(brokerId); + response = await createCreditorInstitutionBroker(body); + } + assert.strictEqual(response.status, status); bundle.brokerCode = brokerId; } async function readCreditorInstitutionInfo(bundle, creditorInstitutionId) { - readAndValidateCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); + await readAndCreateCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); bundle.organizationCode = creditorInstitutionId; - readValidCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); + await readValidCreditorInstitutionInfo(bundle, creditorInstitutionId, 200); response = await readCreditorInstitutionIbans(bundle.organizationCode); - assert.ok(response.data.ibans[0] !== undefined); - bundle.debtPosition.iban = response.data.ibans[0].iban; -} - -async function readStationInfo(bundle, stationId) { + // if there is no iban connected to the CI, it is created + if (response.data.ibans_enhanced.length == 0) { + toRefresh = true; + let body = buildApiConfigServiceCreationIbansRequest(new Date(new Date().setDate(new Date().getDate() + 7)).toISOString(), + new Date(new Date().setDate(new Date().getDate() + 1)).toISOString()); + response = await createCreditorInstitutionIbans(bundle.organizationCode, body); + assert.strictEqual(response.status, 201); + bundle.debtPosition.iban = response.data.iban; + } else { + assert.ok(response.data.ibans_enhanced[0] !== undefined); + bundle.debtPosition.iban = response.data.ibans_enhanced[0].iban; + } +} + +async function readStationInfo(bundle, stationId, brokerId) { + let status = 200; let response = await readStation(stationId); - assert.strictEqual(response.status, 200); + // if the station does not exist, it is created + if (response.status == 404){ + toRefresh = true; + status = 201; + const ip = process.env.ip; + let body = buildApiConfigServiceCreationStationRequest(stationId, brokerId, ip); + response = await createStation(body); + } + assert.strictEqual(response.status, status); bundle.stationCode = stationId; response = await readECStationAssociation(stationId, bundle.organizationCode); - assert.strictEqual(response.status, 200); + if (response.status == 404){ + toRefresh = true; + body = buildApiConfigServiceCreationECStationAssociation(stationId); + response = await createECStationAssociation(bundle.organizationCode, body); + } + assert.ok(response.status == 201 || response.status == 200); bundle.debtPosition.iuvPrefix = response.data.segregation_code < 10 ? `0${response.data.segregation_code}` : `${response.data.segregation_code}`; } @@ -90,7 +136,7 @@ async function readInvalidCreditorInstitutionInfo(bundle) { } async function readValidCreditorInstitutionInfo(bundle) { - readAndValidateCreditorInstitutionInfo(bundle, bundle.organizationCode, 200); + readAndCreateCreditorInstitutionInfo(bundle, bundle.organizationCode, 200); } async function readAndValidateCreditorInstitutionInfo(bundle, organizationCode, status) { @@ -99,6 +145,20 @@ async function readAndValidateCreditorInstitutionInfo(bundle, organizationCode, assert.strictEqual(response.status, status); } +async function readAndCreateCreditorInstitutionInfo(bundle, organizationCode, status) { + bundle.debtPosition.fiscalCode = organizationCode; + let response = await readCreditorInstitution(bundle.debtPosition.fiscalCode); + // if the Creditor Institution does not exist, it is created + if (response.status == 404){ + toRefresh = true; + // new expected state check + status = 201; + let body = buildApiConfigServiceCreationCIRequest(organizationCode); + response = await createCreditorInstitution(body); + } + assert.strictEqual(response.status, status); +} + async function sendActivatePaymentNoticeRequest(bundle) { bundle.responseToCheck = await activatePaymentNotice(buildActivatePaymentNoticeRequest(bundle, bundle.debtPosition.fiscalCode)); } @@ -126,6 +186,18 @@ async function sendGetPaymentV2Request(bundle) { bundle.responseToCheck = await getPaymentV2(buildGetPaymentV2Req(bundle, bundle.debtPosition.fiscalCode)); } +// N.B.: even by launching the configuration refresh, if it was necessary to create a new IBAN, this will not be visible until the validity date is reached +async function refreshNodeConfig(timeout) { + if (toRefresh){ + let response = await refreshConfig(); + assert.strictEqual(response.status, 200); + toRefresh = false; + console.log("--> execution test is stopped for ["+timeout+"] seconds to update the cache. Please wait.."); + await new Promise(resolve => setTimeout(resolve, timeout * 1000)); + console.log("--> end of the wait, test execution resumes."); + } +} + module.exports = { assertPaymentTokenExistence, @@ -143,5 +215,6 @@ module.exports = { sendSendPaymentOutcomeRequest, sendVerifyPaymentNoticeRequest, sendGetPaymentRequest, - sendGetPaymentV2Request + sendGetPaymentV2Request, + refreshNodeConfig } diff --git a/integration-test/src/step_definitions/support/steps.js b/integration-test/src/step_definitions/support/steps.js index 689fed96..daf33f71 100644 --- a/integration-test/src/step_definitions/support/steps.js +++ b/integration-test/src/step_definitions/support/steps.js @@ -23,7 +23,8 @@ const { sendSendRTV2Request, sendVerifyPaymentNoticeRequest, sendGetPaymentRequest, - sendGetPaymentV2Request + sendGetPaymentV2Request, + refreshNodeConfig } = require('./logic/gpd_logic'); const { assertAmount, assertFaultCode, assertOutcome, assertStatusCode, executeAfterAllStep, assertPaymentAmount, assertIbanInTransferList } = require('./logic/common_logic'); const { createOrganizationInfo, createServiceInfo, sendInvalidDemandPaymentNoticeRequest, sendValidDemandPaymentNoticeRequest } = require('./logic/gps_logic'); @@ -31,7 +32,7 @@ const { gpdSessionBundle, gpsSessionBundle } = require('./utility/data'); const { getValidBundle } = require('./utility/helpers'); // increase cucumber promise timeout -setDefaultTimeout(15000); +setDefaultTimeout(45000); /* @@ -51,7 +52,8 @@ Given('ApiConfig running', () => executeHealthCheckForAPIConfig()); */ Given('the creditor institution {string}', (orgId) => readCreditorInstitutionInfo(gpdSessionBundle, orgId)); Given('the creditor institution broker {string}', (brokerId) => readCreditorInstitutionBrokerInfo(gpdSessionBundle, brokerId)); -Given('the station {string}', (stationId) => readStationInfo(gpdSessionBundle, stationId)); +Given('the station {string} for the broker {string}', (stationId, brokerId) => readStationInfo(gpdSessionBundle, stationId, brokerId)); +Given('if necessary, refresh the configuration and wait {int} seconds', async (timeout) => {await refreshNodeConfig(timeout)}); /* diff --git a/integration-test/src/step_definitions/support/utility/request_builders.js b/integration-test/src/step_definitions/support/utility/request_builders.js index 38fbe108..a7718794 100644 --- a/integration-test/src/step_definitions/support/utility/request_builders.js +++ b/integration-test/src/step_definitions/support/utility/request_builders.js @@ -39,6 +39,7 @@ function buildGPSOrganizationCreationRequest(serviceId) { }; } + function buildDemandPaymentNoticeRequest(gpsSessionBundle) { const organizationCode = gpsSessionBundle.organizationCode; const brokerCode = gpsSessionBundle.brokerCode; @@ -400,6 +401,99 @@ function buildGetPaymentV2Req(gpdSessionBundle, fiscalCode) { `; } + + function buildApiConfigServiceCreationCIRequest(creditorInstitutionCode){ + return { + "address": { + "city": "Lorem", + "country_code": "RM", + "location": "Via delle vie 3", + "tax_domicile": "string", + "zip_code": "00187" + }, + "business_name": "Comune di Lorem Ipsum", + "cbill_code": "1234567890100", + "creditor_institution_code": creditorInstitutionCode, + "enabled": true, + "psp_payment": true, + "reporting_ftp": false, + "reporting_zip": false + }; + } + + function buildApiConfigServiceCreationIbansRequest(dueDate, validityDate){ + return { + "description": "Riscossione Tributi", + "due_date": dueDate, + "iban": "IT99C0222211111000000000000", + "is_active": true, + "labels": [], + "validity_date": validityDate + }; + } + + function buildApiConfigServiceCreationBrokerRequest(brokerCode){ + return { + "broker_code": brokerCode, + "description": "Lorem ipsum dolor sit amet", + "enabled": true, + "extended_fault_bean": true + }; + } + + function buildApiConfigServiceCreationStationRequest(stationCode, brokerCode, ip){ + return { + "broker_code": brokerCode, + "broker_description": "Lorem ipsum dolor sit amet", + "enabled": true, + "flag_online": true, + "invio_rt_istantaneo": false, + "ip": ip, + "ip_4mod": "", + "password": "pagopa_test", + "pof_service": "gpd-payments/api/v1", + "port": 65535, + "port_4mod": 65535, + "primitive_version": 1, + "protocol": "HTTPS", + "protocol_4mod": "HTTP", + "proxy_enabled": true, + "proxy_host": "10.79.20.33", + "proxy_password": "", + "proxy_port": 80, + "proxy_username": "", + "redirect_ip": "", + "redirect_path": "", + "redirect_port": 80, + "redirect_protocol": "HTTP", + "redirect_query_string": "", + "service": "gpd-payments/api/v1", + "service_4mod": "", + "station_code": stationCode, + "target_host": "", + "target_host_pof": "", + "target_path": "", + "target_path_pof": "", + "target_port": 0, + "target_port_pof": 0, + "thread_number": 1, + "timeout_a": 15, + "timeout_b": 30, + "timeout_c": 120, + "version": 2 + }; + } + + function buildApiConfigServiceCreationECStationAssociation(stationCode){ + return { + "application_code": 3, + "aux_digit": 3, + "broadcast": true, + "mod4": true, + "segregation_code": 47, + "station_code": stationCode + }; + } module.exports = { @@ -413,5 +507,10 @@ module.exports = { buildSendRTRequest, buildVerifyPaymentNoticeRequest, buildGetPaymentReq, - buildGetPaymentV2Req + buildGetPaymentV2Req, + buildApiConfigServiceCreationCIRequest, + buildApiConfigServiceCreationIbansRequest, + buildApiConfigServiceCreationBrokerRequest, + buildApiConfigServiceCreationStationRequest, + buildApiConfigServiceCreationECStationAssociation } \ No newline at end of file diff --git a/openapi/openapi.json b/openapi/openapi.json index adc4589a..554d3bbe 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "title": "PagoPA API Payments", "description": "Payments", "termsOfService": "https://www.pagopa.gov.it/", - "version": "0.12.11" + "version": "0.12.12" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 211136b5..6201802c 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa payments - 0.12.11 + 0.12.12 Payments Payments