Skip to content

Commit

Permalink
template engine test
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanueleBonofiglio committed Dec 16, 2024
1 parent 8d3e585 commit be03c41
Show file tree
Hide file tree
Showing 12 changed files with 365 additions and 0 deletions.
122 changes: 122 additions & 0 deletions src/TemplateEngineTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { check, sleep } from 'k6';
import crypto from 'k6/crypto';
import { SharedArray } from 'k6/data';
import encoding from 'k6/encoding';
import exec from 'k6/execution';
import http from 'k6/http';



export let options = JSON.parse(open('./modules/test-types/'+__ENV.TEST_TYPE+'.json'));

let notificationReceivedLegalFact = JSON.parse(open('./model/templateEngine/receivedLegalFact.json'));
let viewedLegalFact = JSON.parse(open('./model/templateEngine/viewedLegalFact.json'));
let malfunctionLegalFact = JSON.parse(open('./model/templateEngine/malfunctionLegalFact.json'));
let cancelledLegalFact = JSON.parse(open('./model/templateEngine/cancelledLegalFact.json'));
let analogWorkflowFailureLegalFact = JSON.parse(open('./model/templateEngine/analogWorkflowFailureLegalFact.json'));
let pecDeliveryWorkflowLegalFact = JSON.parse(open('./model/templateEngine/pecDeliveryWorkflowLegalFact.json'));
let notificationAAR = JSON.parse(open('./model/templateEngine/notificationAAR.json'));
let notificationAarRaddAlt = JSON.parse(open('./model/templateEngine/notificationAarRaddAlt.json'));
let notificationAarForEmail = JSON.parse(open('./model/templateEngine/notificationAarForEmail.json'));
let notificationAarForPec = JSON.parse(open('./model/templateEngine/notificationAarForPec.json'));
let notificationAarForSms = JSON.parse(open('./model/templateEngine/notificationAarForSms.json'));


export function templateEngineTest(request, body) {
let url = `http://localhost:8886/${request}`;

console.log(`Url ${url}`);

let params = {
headers: {
'Content-Type': 'application/json',
'x-language': 'DE'
}
};

let payload = JSON.stringify(body);
let response = http.put(url, payload, params);

check(response, {
'status templateEngine is KO': (response) => response.status > 202,
});

check(response, {
'status templateEngine is 202': (response) => response.status === 202,
});

}

export default function templateLoadTest() {

try{
templateEngineTest('templates-engine-private/v1/templates/notification-received-legal-fact',notificationReceivedLegalFact);
}catch(error){
console.log('notification-received-legal-fact error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/notification-viewed-legal-fact',viewedLegalFact);
}catch(error){
console.log('notification-viewed-legal-fact error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/malfunction-legal-fact',malfunctionLegalFact);
}catch(error){
console.log('malfunction-legal-fact error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/notification-cancelled-legal-fact',cancelledLegalFact);
}catch(error){
console.log('notification-cancelled-legal-fact error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/analog-delivery-workflow-failure-legal-fact',analogWorkflowFailureLegalFact);
}catch(error){
console.log('analog-delivery-workflow-failure-legal-fact error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/pec-delivery-workflow-legal-fact',pecDeliveryWorkflowLegalFact);
}catch(error){
console.log('pec-delivery-workflow-legal-fact error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/notification-aar',notificationAAR);
}catch(error){
console.log('notification-aar error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/notification-aar-radd-alt',notificationAarRaddAlt);
}catch(error){
console.log('notification-aar-radd-alt error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/notification-aar-for-email',notificationAarForEmail);
}catch(error){
console.log('notification-aar-for-email error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/notification-aar-for-pec',notificationAarForPec);
}catch(error){
console.log('notification-aar-for-pec error: ',error)
}

try{
templateEngineTest('templates-engine-private/v1/templates/notification-aar-for-sms',notificationAarForSms);
}catch(error){
console.log('notification-aar-for-sms error: ',error)
}




sleep(2);
}
9 changes: 9 additions & 0 deletions src/model/templateEngine/analogWorkflowFailureLegalFact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"iun": "TEST_iun",
"endWorkflowDate": "TEST_endWorkflowDate",
"endWorkflowTime": "TEST_endWorkflowTime",
"recipient": {
"denomination": "TEST_denomination",
"taxId": "TEST_taxId"
}
}
19 changes: 19 additions & 0 deletions src/model/templateEngine/cancelledLegalFact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"notificationCancelledDate": "TEST_notificationCancelledDate",
"notification": {
"iun": "TEST_iun",
"sender": {
"paDenomination": "TEST_paDenomination"
},
"recipients": [
{
"denomination": "TEST1_denomination",
"taxId": "TEST1_taxId"
},
{
"denomination": "TEST2_denomination",
"taxId": "TEST2_taxId"
}
]
}
}
6 changes: 6 additions & 0 deletions src/model/templateEngine/malfunctionLegalFact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"startDate": "TEST_startDate",
"timeReferenceStartDate": "TEST_timeReferenceStartDate",
"endDate": "TEST_endDate",
"timeReferenceEndDate": "TEST_timeReferenceEndDate"
}
18 changes: 18 additions & 0 deletions src/model/templateEngine/notificationAAR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"notification": {
"iun": "TEST_iun",
"subject": "TEST_subject",
"sender": {
"paDenomination": "TEST_paDenomination"
}
},
"qrCodeQuickAccessLink": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAALQAAAC0AQAAAAAVtjufAAAEd0lEQVR4Xu2XPdLrJhSGUSO2IBrYGjTSFqCRoIEtQANbkxrRpoQG5Xgk35tkjL8uaULh8Twevzq8cH6Ero/rD/RPcq//+b3+Da4HE7GWdJQkeT4Ej9hXnqodSZTDlfeVr7jWK33lnnh1WRLaptctHK6an/gu13ldzpldRbmifuS1jQixXKum7IjkB56qX6eJaaI50yr/Jf7PXA/hb+u3P585KIXLMo9dYc4Fzx6fe7wQBxYgnDzTaFSNy1uny+mgR1ablBPHjXk6fueXiXRShcsllwkNbV7uffW4cefSWKhuV34U2ZPz1unxfFxt5cyB2qKxa1LdOj0eZyRhU5tf+Xaqww+Pzz1uTIiTlGgk7ioL6MzbV57h6NpWy6JVskMFndvnHg/maOvSRmHpZmpos7x1ejzF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E2MKpl8LvU718Nr1LfiOmDgxDAVPnN1j39a//N7/Wf8TwIyrfH4OjBLAAAAAElFTkSuQmCC",
"recipient": {
"recipientType": "PG",
"taxId": "TEST_taxId"
},
"piattaformaNotificheURL": "https://cittadini.test.notifichedigitali.it/auth/login",
"piattaformaNotificheURLLabel": "TEST_piattaformaNotificheURLLabel",
"perfezionamentoURL": "https://www.notifichedigitali.it/it/perfezionamento",
"perfezionamentoURLLabel": "TEST_perfezionamentoURLLabel"
}
12 changes: 12 additions & 0 deletions src/model/templateEngine/notificationAarForEmail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"perfezionamentoURL": "https://www.notifichedigitali.it/it/perfezionamento/",
"quickAccessLink": "TEST_quickAccessLink",
"pnFaqSendURL": "https://www.notifichedigitali.it/it/faq/",
"piattaformaNotificheURL": "https://cittadini.notifichedigitali.it/auth/login",
"notification": {
"iun": "TEST_iun",
"sender": {
"paDenomination": "Comune di Palermo"
}
}
}
17 changes: 17 additions & 0 deletions src/model/templateEngine/notificationAarForPec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"notification": {
"iun": "TEST",
"subject": "Notifica digitale",
"sender": {
"paDenomination": "Comune di Palermo"
}
},
"perfezionamentoURL": "https://www.notifichedigitali.it/it/perfezionamento/",
"quickAccessLink": "TEST",
"pnFaqSendURL": "https://www.notifichedigitali.it/it/faq/",
"piattaformaNotificheURL": "https://cittadini.notifichedigitali.it/auth/login",
"recipientType": "PG",
"recipient": {
"taxId": "897645321"
}
}
8 changes: 8 additions & 0 deletions src/model/templateEngine/notificationAarForSms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"notification": {
"iun": "TEST",
"sender": {
"paDenomination": "Comune di Palermo"
}
}
}
22 changes: 22 additions & 0 deletions src/model/templateEngine/notificationAarRaddAlt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"notification": {
"iun": "TEST_iun",
"subject": "TEST_subject",
"sender": {
"paDenomination": "Comune di Palermo"
}
},
"sendURL": "https://cittadini.notifichedigitali.it/auth/login",
"sendURLLAbel": "SEND",
"raddPhoneNumber": "TEST_raddPhoneNumber",
"perfezionamentoURL": "https://www.notifichedigitali.it/it/perfezionamento",
"perfezionamentoURLLabel": "perfezionamento",
"recipient": {
"recipientType": "PF",
"denomination": "Ada Lovelace",
"taxId": "LVLDAA85T50G702B"
},
"piattaformaNotificheURL": "https://cittadini.notifichedigitali.it/auth/login",
"piattaformaNotificheURLLabel": "SEND",
"qrCodeQuickAccessLink": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAALQAAAC0AQAAAAAVtjufAAAEd0lEQVR4Xu2XPdLrJhSGUSO2IBrYGjTSFqCRoIEtQANbkxrRpoQG5Xgk35tkjL8uaULh8Twevzq8cH6Ero/rD/RPcq//+b3+Da4HE7GWdJQkeT4Ej9hXnqodSZTDlfeVr7jWK33lnnh1WRLaptctHK6an/gu13ldzpldRbmifuS1jQixXKum7IjkB56qX6eJaaI50yr/Jf7PXA/hb+u3P585KIXLMo9dYc4Fzx6fe7wQBxYgnDzTaFSNy1uny+mgR1ablBPHjXk6fueXiXRShcsllwkNbV7uffW4cefSWKhuV34U2ZPz1unxfFxt5cyB2qKxa1LdOj0eZyRhU5tf+Xaqww+Pzz1uTIiTlGgk7ioL6MzbV57h6NpWy6JVskMFndvnHg/maOvSRmHpZmpos7x1ejzFkeNcGzxb5HR51m4fetwOKU6sCCvcUZ1ps7j31ePG5dff4fSVsVv26tHpcS/A6JlZNE1KD+DFo9Pj6Rwlzn4rkrOXz+L4zsHntFN1nMziIlyb1l/+f+QuH0VdZYTaQSw+tMi3zz0eNIHfNIPriIacDo0e/zs8Mi+SZVFylZw5HHz/yi0xroLauECxScnDx3fOTJlW5k7wwYqysvjodLhHJOes0aAhT+GeI/L43+EBSpcdqZzoclmxS/rkdY8bP0S0FfwqGYVFSt7n0uHOmQv2Zcd5M6dooHTr9HgwtbpzAp8RgTzVS37i7PC4nCt7+Uz5YsWRy6PT45ZjTZqEQmZJYQHS6vG5x+GJcn3V+XE7xbm94+xxrwrJJ9uHVA3EGbcnzh4PKRs7TuAzVeCzesfZ42af2T5z7FIDn/26vP3vcBf5Sspix6XmJprSb/87HHwOeacsRL5FDIf52/+P/AQLmMZRsmC8gLLz6PT4Lpcayoxw3E7KjDmeOHs8YpP9vAq/eMQ520W5dXpco0mOKxpq8ghhaFb41unxBilElxQ0hXQVTTJ/6/S4J3Yzlugh7cSznf/u7595ZHqDEu/sElnkkKWPTo9Dnl47R6xCiaE4FPTE2ePnOvKRQwFmJysc+vnjQ4/vA4w2Xs44Yigah8lv/zs8Lvtml33wuHHwOb/Psce1qA1t2dS0QwMqg3OP/x3expFP8zqYBnWGUymfvtbj4DMJ8GBER+Ipn7F+fOvwSMUV1Qkd+ZWwMNxN37nn7NrFlSFL55XUfXnqdo+f7NgpX1WoJ4WeY6fl+sp3dRKnyYlhxGyTCFClvnKopFcUeoM7yAeXcnp863GtCkVLPa6s8T7KIcfbtx6P0JLXmUMRBp8RnSd1x9njUIvIAZtixwnDMjSV/Y6zxxvlmxZRBfD5Cteve9LjKSTo3Wi4jEZU+UHj+7k9/qp868yCqznBkAMTxr2vHtfDSWBahEZoSST7RJ6+2eMJJm8YZKEhQKAvn59z73F4j3hNmMPhIFDwGa7hDxx8FrlwaPxY0xmH9AOHSzIhcZgTpmtEYMr4yhNcVS0xvE2MKpl8LvU718Nr1LfiOmDgxDAVPnN1j39a//N7/Wf8TwIyrfH4OjBLAAAAAElFTkSuQmCC"
}
79 changes: 79 additions & 0 deletions src/model/templateEngine/pecDeliveryWorkflowLegalFact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"iun": "TEST_iun",
"endWorkflowDate": null,
"endWorkflowStatus": "SUCCESS",
"deliveries": [
{
"denomination": "TEST1_denomination",
"taxId": "TEST1_taxId",
"type": "TEST1_NO_SERCQ",
"responseDate": "TEST1_responseDate",
"ok": false,
"address": "TEST1_address_platform",
"addressSource": "PLATFORM"
},
{
"denomination": "TEST1_denomination",
"taxId": "TEST1_taxId",
"type": "TEST1_NO_SERCQ",
"responseDate": "TEST1_responseDate",
"ok": false,
"address": "TEST2_address_platform",
"addressSource": "PLATFORM"
},
{
"denomination": "TEST2_denomination",
"taxId": "TEST2_taxId",
"type": "TEST2_NO_SERCQ",
"responseDate": "TEST2_responseDate",
"ok": false,
"address": "TEST2_address_special",
"addressSource": "SPECIAL"
},
{
"denomination": "TEST3_denomination",
"taxId": "TEST3_taxId",
"type": "TEST2_NO_SERCQ",
"responseDate": "TEST3_responseDate",
"ok": true,
"address": "TEST3_address_general",
"addressSource": "GENERAL"
},
{
"denomination": "TEST1_denomination",
"taxId": "TEST1_taxId",
"type": "TEST1_NO_SERCQ",
"responseDate": "TEST1_responseDate",
"ok": false,
"address": "TEST1_address_platform",
"addressSource": "PLATFORM"
},
{
"denomination": "TEST1_denomination",
"taxId": "TEST1_taxId",
"type": "TEST1_NO_SERCQ",
"responseDate": "TEST1_responseDate",
"ok": false,
"address": "TEST1_address_platform",
"addressSource": "PLATFORM"
},
{
"denomination": "TEST2_denomination",
"taxId": "TEST2_taxId",
"type": "TEST2_NO_SERCQ",
"responseDate": "TEST2_responseDate",
"ok": false,
"address": "TEST2_address_special",
"addressSource": "SPECIAL"
},
{
"denomination": "TEST3_denomination",
"taxId": "TEST3_taxId",
"type": "TEST2_NO_SERCQ",
"responseDate": "TEST3_responseDate",
"ok": true,
"address": "TEST3_address_general",
"addressSource": "GENERAL"
}
]
}
41 changes: 41 additions & 0 deletions src/model/templateEngine/receivedLegalFact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"sendDate": "TEST_sendDate",
"notification": {
"iun": "TEST_iun",
"sender": {
"paDenomination": "TEST_paDenomination",
"paTaxId": "TEST_paTaxId"
},
"recipients": [
{
"denomination": "TEST1_denomination",
"taxId": "TEST1_taxId",
"physicalAddressAndDenomination": null,
"digitalDomicile": {
"address": "TEST1_digitalDomicile"
}
},
{
"denomination": "TEST2_denomination",
"taxId": "TEST2_taxId",
"physicalAddressAndDenomination": "TEST2_physicalAddressAndDenomination",
"digitalDomicile": {
"address": null
}
},
{
"denomination": "TEST3_denomination",
"taxId": "TEST3_taxId",
"physicalAddressAndDenomination": "TEST3_physicalAddressAndDenomination",
"digitalDomicile": {
"address": "TEST3_address"
}
}
]
},
"subject": "TEST_subject",
"digests": [
"TEST1_digests",
"TEST2_digests"
]
}
12 changes: 12 additions & 0 deletions src/model/templateEngine/viewedLegalFact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"iun": "TEST_iun",
"when": "TEST_when",
"recipient": {
"denomination": "TEST_denomination",
"taxId": "TEST_taxId"
},
"delegate": {
"denomination": "TEST_denomination",
"taxId": "TEST_taxId"
}
}

0 comments on commit be03c41

Please sign in to comment.