Skip to content

Commit

Permalink
Merge branch 'PPANTT-196-feat-introducing-int-tests' into PPANTT-193-…
Browse files Browse the repository at this point in the history
…feat-add-performance-test-scripts
  • Loading branch information
alessio-cialini committed Dec 24, 2024
2 parents 0e0c99c + 9a766be commit 032f3f3
Show file tree
Hide file tree
Showing 87 changed files with 5,428 additions and 4,219 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-mbd-service
description: Microservice that handles services for eBollo
type: application
version: 0.97.0
appVersion: 1.0.1-4-fix-dati-servizio
version: 0.104.0
appVersion: 1.2.3-2-PPANTT-196-feat-introducing-int-tests
dependencies:
- name: microservice-chart
version: 7.1.1
Expand Down
4 changes: 2 additions & 2 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: "pagopa-mbd-service"
image:
repository: ghcr.io/pagopa/pagopa-mbd-service
tag: "1.0.1-4-fix-dati-servizio"
tag: "1.2.3-2-PPANTT-196-feat-introducing-int-tests"
pullPolicy: Always
livenessProbe:
handlerType: httpGet
Expand Down Expand Up @@ -79,7 +79,7 @@ microservice-chart:
MBD_BASE_URL: 'https://api.dev.platform.pagopa.it/pagopa-mbd-service/v1'
MBD_ID_PSP: 'ABI50004'
MBD_ID_BROKER_PSP: '99999000011'
MBD_CHANNEL_ID: '99999000011_03'
MBD_CHANNEL_ID: '99999000011_02'
ENV: 'azure-dev'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
OTEL_SERVICE_NAME: "pagopa-mbd-service"
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: "pagopa-mbd-service"
image:
repository: ghcr.io/pagopa/pagopa-mbd-service
tag: "1.0.1-4-fix-dati-servizio"
tag: "1.2.3-2-PPANTT-196-feat-introducing-int-tests"
pullPolicy: Always
livenessProbe:
handlerType: httpGet
Expand Down
6 changes: 3 additions & 3 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: "pagopa-mbd-service"
image:
repository: ghcr.io/pagopa/pagopa-mbd-service
tag: "1.0.1-4-fix-dati-servizio"
tag: "1.2.3-2-PPANTT-196-feat-introducing-int-tests"
pullPolicy: Always
livenessProbe:
handlerType: httpGet
Expand Down Expand Up @@ -76,10 +76,10 @@ microservice-chart:
DEMAND_PAYMENT_ENDPOINT: 'https://api.uat.platform.pagopa.it/nodo-auth/node-for-psp/v1'
CART_ENDPOINT: 'https://api.uat.platform.pagopa.it/checkout/carts-auth/v1/carts'
PAYMENT_RECEIPT_ENDPOINT: 'https://api.uat.platform.pagopa.it/gpd/payments-receipts-service/v1'
MBD_BASE_URL: 'https://api.dev.platform.pagopa.it/pagopa-mbd-service/v1'
MBD_BASE_URL: 'https://api.uat.platform.pagopa.it/pagopa-mbd-service/v1'
MBD_ID_PSP: 'ABI50004'
MBD_ID_BROKER_PSP: '99999000011'
MBD_CHANNEL_ID: '99999000011_03'
MBD_CHANNEL_ID: '99999000011_02'
ENV: 'azure-uat'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'
OTEL_SERVICE_NAME: "pagopa-mbd-service"
Expand Down
5 changes: 3 additions & 2 deletions integration-test/src/config/.env.dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SERVICE_URI=https://api.dev.platform.pagopa.it/pagopa-gps-mbd-service/v1
SUBKEY=<SUBKEY>

GPD_SERVICE_URI=https://api.dev.platform.pagopa.it/gpd/debt-positions-service/v1/
GPD_SERVICE_URI=https://api.dev.platform.pagopa.it/gpd/api/v1/
GPD_SUBKEY=<SUBKEY>

FISCAL_CODE_EC=777777777
FISCAL_CODE_EC=99999000013
CORRECT_NAV=348173447377455101
9 changes: 8 additions & 1 deletion integration-test/src/config/.env.local
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
ENVIRONMENT=local

SERVICE_URI=http://localhost:8080/messages
SERVICE_URI=https://api.dev.platform.pagopa.it/pagopa-mbd-service/v1
SUBKEY=<SUBKEY>

GPD_SERVICE_URI=https://api.dev.platform.pagopa.it/gpd/api/v1
GPD_SUBKEY=<GPD_SUBKEY>

FISCAL_CODE_EC=99999000013
CORRECT_NAV=348173447377455101
3 changes: 2 additions & 1 deletion integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ SUBKEY=<SUBKEY>
GPD_SERVICE_URI=https://api.uat.platform.pagopa.it/gpd/debt-positions-service/v1/
GPD_SUBKEY=<SUBKEY>

FISCAL_CODE_EC=777777777
FISCAL_CODE_EC=99999000013
CORRECT_NAV=348173447377455101
10 changes: 5 additions & 5 deletions integration-test/src/features/mbd_service.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Feature: Get MBD

Scenario: Execute a request to getMDB Receipt service with valid content
Given a receipt of the former MDB payment being payed
When an Http GET request is sent to the mdb-service getMDBReceipt with fiscalCode "77777777777" and "correct" NAV
When an Http GET request is sent to the mdb-service getMDBReceipt with "correct"
Then response has a 200 Http status

Scenario: Execute a request to getMDBReceipt service with wrong data
When an Http GET request is sent to the mdb-service getMDBReceipt with fiscalCode "AAAAAAAAAA" and "correct" NAV
Then response has a 404 Http status
When an Http GET request is sent to the mdb-service getMDBReceipt with "wrong_ec"
Then response has a 500 Http status

Scenario: Execute a request to getMDBReceipt service with wrong data
When an Http GET request is sent to the mdb-service getMDBReceipt with fiscalCode "77777777777" and "wrong" NAV
Then response has a 404 Http status
When an Http GET request is sent to the mdb-service getMDBReceipt with "wrong_nav"
Then response has a 500 Http status
36 changes: 19 additions & 17 deletions integration-test/src/step_definitions/support/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const axios = require("axios");
const uri = process.env.SERVICE_URI;
const gpd_payment_uri = process.env.GPD_SERVICE_URI;
const environment = process.env.ENVIRONMENT;
const idCIService = process.env.CI_SERVICE || '00005';

axios.defaults.headers.common['Ocp-Apim-Subscription-Key'] = process.env.SUBKEY || ""; // for all requests
if (process.env.canary) {
Expand All @@ -17,14 +18,14 @@ function getBody() {
{
"firstName": "Mario",
"lastName": "Rossi",
"fiscalCodeEC": "77777777777",
"fiscalCode": "77777777777",
"amount": 16,
"email": "test@pagopa.it",
"province": "RM",
"documentHash": "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVpBQkNERQ=="
"documentHash": "PHJvb3Q+PC9yb290Pg=========================="
}
],
"idCIService": "01000",
"idCIService": idCIService,
"returnUrls": {
"successUrl": "https://url1.it",
"cancelUrl": "https://url2.it",
Expand All @@ -37,58 +38,59 @@ function getBody() {
async function getDebtPositions(fiscalCodeEC, dueDate) {

let headers = {
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY;
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY
};


return await axios.get(gpd_payment_uri+"/organizations/"+fiscalCodeEC+"/debtpositions?due_date_from="+dueDate, { headers })
.then(res => {
return res.data;
})
.catch(error => {
return error.response;
});

}

async function deleteDebtPositions(fiscalCodeEC, iupd) {

let headers = {
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY;
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY
};


return await axios.delete(gpd_payment_uri+"/organizations/"+fiscalCodeEC+"/debtpositions/"+iupd, { headers })
.then(res => {
return res.data;
return res;
})
.catch(error => {
return error.response;
});

}


async function getPayPosition(fiscalCodeEC, nav) {

let headers = {
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY;
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY
};

return await axios.post(gpd_payment_uri+"/organizations/{organizationfiscalcode}/paymentoptions/{nav}", { headers })
return await axios.get(gpd_payment_uri+"/organizations/"+fiscalCodeEC+"/paymentoptions/"+nav, { headers })
.then(res => {
return res.data;
return res;
})
.catch(error => {
return error.response;
});

}

async function payReceipt(fiscalCodeEC, nav, body) {

let headers = {
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY;
"Ocp-Apim-Subscription-Key": process.env.GPD_SUBKEY
};

return await axios.post(gpd_payment_uri+"/organizations/{organizationfiscalcode}/paymentoptions/{nav}/pay", body, { headers })
return await axios.post(gpd_payment_uri+"/organizations/"+fiscalCodeEC+"/paymentoptions/"+nav+"/pay", body, { headers })
.then(res => {
return res.data;
})
Expand All @@ -102,9 +104,9 @@ async function getMDB(fiscalCodeEC, body) {

let headers = {};

return await axios.post(uri+"organizations"+fiscalCodeEC+"/mbd", body, { headers })
return await axios.post(uri+"/organizations/"+fiscalCodeEC+"/mbd", body, { headers })
.then(res => {
return res.data;
return res;
})
.catch(error => {
return error.response;
Expand All @@ -118,7 +120,7 @@ async function getMdbReceipt(organizationalFiscalCode, nav) {

return await axios.get(uri+"/organizations/"+organizationalFiscalCode+"/receipt/"+nav, { headers })
.then(res => {
return res.data;
return res;
})
.catch(error => {
return error.response;
Expand All @@ -127,5 +129,5 @@ async function getMdbReceipt(organizationalFiscalCode, nav) {
}

module.exports = {
getMDB, getMdbReceipt, getBody, getPayPosition, payReceipt, getDebtPositions, deleteDebtPosition
getMDB, getMdbReceipt, getBody, getPayPosition, payReceipt, getDebtPositions, deleteDebtPositions
}
49 changes: 24 additions & 25 deletions integration-test/src/step_definitions/support/mdb_service_step.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const assert = require('assert');
const { Given, When, Then, After } = require('@cucumber/cucumber');
const {getMDB, getMdbReceipt, getBody, getPayPosition, payReceipt, getDebtPositions, deleteDebtPosition} = require("./common.js");

const fiscalCodeEC = process.env.FISCAL_CODE_EC;
var fiscalCodeEC = process.env.FISCAL_CODE_EC;
var receiptNav = process.env.CORRECT_NAV;

// After each Scenario
After(async function () {
Expand Down Expand Up @@ -45,58 +46,56 @@ When('an Http GET request is sent to the mdb-service getMDB with {string}', asyn
}

this.response = await getMDB(fiscalCodeEC, body);

});

Then('response body contains checkoutUrl', function () {
assert.notNull(this.response?.data?.checkoutUrl);
assert.notEqual(this.response?.data?.checkoutRedirectUrl, null);
});

Then('response contains mdb link', function () {
assert.notNull(this.response?.data?.navDownloadLink);
assert.notEqual(this.response?.data?.navDownloadLink, null);
});

Then('response contains mdb nav', function () {
assert.notNull(this.response?.data?.mbdNav);
assert.notEqual(this.response?.data?.mbdNav, null);
this.correctNav = this.response?.data?.mbdNav;
});

Given('a receipt of the former MDB payment being payed', async function () {

this.payResponse = await getPayPosition(fiscalCodeEC, correctNav);
assert.assertNotNull(this.response?.data);
this.dueDate = this.response?.data?.dueDate;
var payBody = {
"paymentDate": this.response?.data?.insertedDate,
"paymentMethod": this.response?.data?.paymentMethod,
"pspCompany": this.response?.data?.pspCompany
"idReceipt": this.response?.data?.idReceipt,
"fee": this.response?.data?.fee
}
await payReceipt();
assert.notEqual(this.payResponse, null);
this.dueDate = this.payResponse?.data?.dueDate;
// var payBody = {
// "paymentDate": this.response?.data?.insertedDate,
// "paymentMethod": this.response?.data?.paymentMethod,
// "pspCompany": this.response?.data?.pspCompany
// "idReceipt": this.response?.data?.idReceipt,
// "fee": this.response?.data?.fee
// }
// await payReceipt();

});

When('an Http GET request is sent to the mdb-service getMDBReceipt with fiscalCode {string} and {string} NAV', async function (fiscalCodeEC, navType) {

var nav;
switch(inputType) {
When('an Http GET request is sent to the mdb-service getMDBReceipt with {string}', async function (dataType) {

switch(dataType) {
case "correct":
nav = this.response?.data?.mbdNav;
this.response = await getMdbReceipt(fiscalCodeEC, receiptNav);
break;
case "wrong":
nav = "AAAAAAAA";
case "wrong_ec":
this.response = await getMdbReceipt("AAAAAAA", receiptNav);
break;
case "wrong_nav":
this.response = await getMdbReceipt(fiscalCodeEC, "AAAAAAAA");
break;

}

this.response = await getMdbReceipt(fiscalCodeEC, nav);

});

Then('response body contains content data', function () {
assert.notNull(this.response?.data?.content);
assert.notEqual(this.response?.data?.content, null);
});

//COMMON
Expand Down
Loading

0 comments on commit 032f3f3

Please sign in to comment.