From 61d83ff5eb5e1a58f8b2f646ca474f094198c8e4 Mon Sep 17 00:00:00 2001 From: somanath21 <104554892+somanath21@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:26:43 +0530 Subject: [PATCH 01/12] Add .circleci/config.yml --- .circleci/config.yml | 102 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7db2980..dfb7096 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,16 +3,100 @@ setup: true orbs: test-harness: govstack-working-group/testutils@1.0.1 +jobs: + build: + docker: + - image: cimg/python:3.10 + working_directory: ~/repo + environment: + TERM: dumb + steps: + - checkout + - run: rm -f helm/govstack-chart/Chart.lock helm/govstack-chart/requirements.lock helm/govstack-chart/charts/* + - helm/install-helm-client: + version: "v3.8.2" + # - run: "sed -i '12s/.*/version: 0.0.0/' helm/g2p-sandbox-fynarfin-SIT/Chart.yaml" + - run: cat helm/govstack-chart/Chart.yaml + - run: helm dep up helm/govstack-chart + - run: helm package helm/govstack-chart + - run: helm repo index . + - run: echo "$CERT_FILE" | base64 --decode > b64encoded.pem + - run: chmod 400 b64encoded.pem + - run: scp -o StrictHostKeyChecking=No -i b64encoded.pem index.yaml govstack-chart-1.0.0.tgz ec2-user@13.233.68.128:~/ + - run: ssh -i b64encoded.pem -o StrictHostKeyChecking=No ec2-user@13.233.68.128 sudo mv -t /apps/apache-tomcat-7.0.82/webapps/ROOT/images/govstack-chart index.yaml govstack-chart-1.0.0.tgz + upgrade-g2psandbox-helm-chart: + docker: + - image: cimg/python:3.10 + parameters: + cluster-name: + description: "sit" + type: string + steps: + - aws-eks/update-kubeconfig-with-authenticator: + cluster-name: "sit" + aws-region: "us-east-2" + - helm/install-helm-client: + version: "v3.8.2" + - run: helm ls --namespace=paymenthub + - helm/upgrade-helm-chart: + chart: "https://fynarfin.io/images/ph-ee-g2psandbox-fynarfin/govstack-chart-1.0.0.tgz" + release-name: "g2p-sandbox" + namespace: paymenthub + recreate-pods: true + add-repo: "https://fynarfin.io/images/govstack-chart" + wait: true + timeout: "300s" + # - run: helm test g2p-sandbox --namespace=paymenthub + # reset-values: true + # dry-run: true + # - helm/install-helm-chart: + # add-repo: "https://fynarfin.io/images/" + # chart: "https://fynarfin.io/images/ph-ee-g2psandbox-0.2.0.tgz" + # release-name: g2p-sandbox + # namespace: ph-test + + # kubectl delete secrets elastic-certificates elastic-certificate-pem elastic-certificate-crt|| true + workflows: - test_everything: + deploy: jobs: - - test-harness/create-config: - post-steps: # Persist to workspace has to be defined in main workflow - - persist_to_workspace: - root: workspace - paths: - - generated.yml - - test-harness/execute-tests: + - build: + context: + - AWS + - Helm + - slack + - upgrade-g2psandbox-helm-chart: + cluster-name: sit requires: - - test-harness/create-config + - build + context: + - AWS + - Helm + - slack + - Secrets + # test_everything: + # jobs: + # - test-harness/create-config: + # post-steps: # Persist to workspace has to be defined in main workflow + # - persist_to_workspace: + # root: workspace + # paths: + # - generated.yml + # - test-harness/execute-tests: + # requires: + # - test-harness/create-config + + +# workflows: +# test_everything: +# jobs: +# - test-harness/create-config: +# post-steps: # Persist to workspace has to be defined in main workflow +# - persist_to_workspace: +# root: workspace +# paths: +# - generated.yml +# - test-harness/execute-tests: +# requires: +# - test-harness/create-config From a0f71b4989516d1afa4bb1e70e30bfa7c38c631b Mon Sep 17 00:00:00 2001 From: somanath21 <104554892+somanath21@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:28:13 +0530 Subject: [PATCH 02/12] Updated config.yml --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index dfb7096..3670571 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,6 +3,10 @@ setup: true orbs: test-harness: govstack-working-group/testutils@1.0.1 + slack: circleci/slack@4.12.5 + helm: circleci/helm@2.0.1 + aws-eks: circleci/aws-eks@2.2.0 + kubernetes: circleci/kubernetes@1.3 jobs: build: docker: From 56bb1442e8f6b6f19fdb6bed8f9372e32acec095 Mon Sep 17 00:00:00 2001 From: somanath21 <104554892+somanath21@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:38:22 +0530 Subject: [PATCH 03/12] Updated config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3670571..b1d8305 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ jobs: - helm/install-helm-client: version: "v3.8.2" # - run: "sed -i '12s/.*/version: 0.0.0/' helm/g2p-sandbox-fynarfin-SIT/Chart.yaml" - - run: cat helm/govstack-chart/Chart.yaml + # - run: cat helm/govstack-chart/Chart.yaml - run: helm dep up helm/govstack-chart - run: helm package helm/govstack-chart - run: helm repo index . From 63b4571ad29ad2ac9bcbd1352aab1b6e3eee9e8d Mon Sep 17 00:00:00 2001 From: mgrochalskisoldevelo Date: Mon, 26 Jun 2023 13:37:56 +0200 Subject: [PATCH 04/12] TECH-494 updated cucumber tests, mocks and gherkin scenarios for voucher activation --- .../mockoon-paymentsbbvoucher.json | 59 ++---- .../features/support/helpers/helpers.js | 10 ++ .../features/support/voucher_activation.js | 170 +++++++++++------- .../features/voucher_activation.feature | 91 ++++++++-- 4 files changed, 205 insertions(+), 125 deletions(-) diff --git a/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json b/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json index d8cb37a..b4897ab 100644 --- a/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json +++ b/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json @@ -928,7 +928,7 @@ "uuid": "539da980-8549-47a2-91d2-6b80599f27f3", "documentation": "Request for voucher activation by sending the voucher serial number", "method": "patch", - "endpoint": "vouchers/voucher_activation/", + "endpoint": "vouchers/voucher_activation", "responses": [ { "uuid": "81855a8c-7115-4f66-b0c9-d241c2a75876", @@ -950,21 +950,7 @@ { "target": "body", "modifier": "voucher_serial_number", - "value": "", - "invert": true, - "operator": "null" - }, - { - "target": "body", - "modifier": "voucher_serial_number", - "value": "", - "invert": true, - "operator": "equals" - }, - { - "target": "body", - "modifier": "voucher_serial_number", - "value": "^((?!(0))[0-9]{0,19})$", + "value": "^[1-9]\\d{0,18}$", "invert": false, "operator": "regex" }, @@ -978,7 +964,7 @@ { "target": "body", "modifier": "Gov_Stack_BB", - "value": "", + "value": "not_exist", "invert": true, "operator": "equals" } @@ -1002,7 +988,14 @@ "rules": [ { "target": "body", - "modifier": "", + "modifier": "voucher_serial_number", + "value": "", + "invert": false, + "operator": "null" + }, + { + "target": "body", + "modifier": "Gov_Stack_BB", "value": "", "invert": false, "operator": "null" @@ -1028,26 +1021,19 @@ { "target": "body", "modifier": "voucher_serial_number", - "value": "", - "invert": false, - "operator": "null" - }, - { - "target": "body", - "modifier": "voucher_serial_number", - "value": "", - "invert": false, - "operator": "equals" + "value": "^[1-9]\\d{0,18}$", + "invert": true, + "operator": "regex" }, { "target": "body", - "modifier": "voucher_serial_number", - "value": "^((?!(0))[0-9]{0,19})$", + "modifier": "Gov_Stack_BB", + "value": "not_exist", "invert": true, - "operator": "regex" + "operator": "equals" } ], - "rulesOperator": "OR", + "rulesOperator": "AND", "disableTemplating": false, "fallbackTo404": false, "default": false @@ -1067,14 +1053,7 @@ { "target": "body", "modifier": "Gov_Stack_BB", - "value": "", - "invert": false, - "operator": "null" - }, - { - "target": "body", - "modifier": "Gov_Stack_BB", - "value": "", + "value": "not_exist", "invert": false, "operator": "equals" } diff --git a/test/openAPI/features/support/helpers/helpers.js b/test/openAPI/features/support/helpers/helpers.js index 28ac5e3..901713d 100644 --- a/test/openAPI/features/support/helpers/helpers.js +++ b/test/openAPI/features/support/helpers/helpers.js @@ -84,4 +84,14 @@ module.exports = { properties: { message: { type: 'string' } }, required: ['message'], }, + voucherActivationEndpoint: 'vouchers/voucher_activation', + voucherActivationResponseSchema: { + properties: { result_status: { type: 'string' } }, + required: ['result_status'], + }, + voucherResponseErrorSchema: { + type: 'object', + properties: { message: { type: 'string' } }, + required: ['message'], + }, }; diff --git a/test/openAPI/features/support/voucher_activation.js b/test/openAPI/features/support/voucher_activation.js index e6c567e..c1b9e1c 100644 --- a/test/openAPI/features/support/voucher_activation.js +++ b/test/openAPI/features/support/voucher_activation.js @@ -1,101 +1,133 @@ -const pactum = require('pactum'); +const chai = require('chai'); +const { spec } = require('pactum'); const { Given, When, Then, Before, After } = require('@cucumber/cucumber'); -const { localhost } = require('./helpers/helpers'); +const { + localhost, + defaultExpectedResponseTime, + voucherActivationEndpoint, + voucherActivationResponseSchema, + voucherResponseErrorSchema, +} = require('./helpers/helpers'); + +chai.use(require('chai-json-schema')); let specVoucherActivation; -const baseUrl = `${localhost}vouchers/voucher_activation`; +const baseUrl = localhost + voucherActivationEndpoint; +const endpointTag = { tags: `@endpoint=/${voucherActivationEndpoint}` }; -Before(() => { - specVoucherActivation = pactum.spec(); +Before(endpointTag, () => { + specVoucherActivation = spec(); }); -// Background: The user wants to activate pre-activated voucher -Given('The user wants to activate pre-activated voucher', () => { - return 'The user wants to activate pre-activated voucher'; -}); +// Scenario: Successfully activates a pre-activated voucher smoke type test +Given( + 'Non Payment Building Block wants to activate a pre-activated voucher', + () => 'Non Payment Building Block wants to activate a pre-activated voucher' +); -// Scenario: The user successfully activates a pre-activated voucher When( - 'The user triggers an action with a valid payload to activate a pre-activated voucher', - () => { - specVoucherActivation.patch(baseUrl).withBody({ - voucher_serial_number: 5432, - Gov_Stack_BB: 'example Gov_Stack_BB', - }); - } + /^Sends PATCH \/vouchers\/voucher_activation request with valid payload where voucher_serial_number = (\d+)$/, + voucher_serial_number => + specVoucherActivation.patch(baseUrl).withJson({ + voucher_serial_number: voucher_serial_number, + Gov_Stack_BB: 'bb-digital-registries', + }) ); -Then('The user successfully activates a pre-activated voucher', async () => { - await specVoucherActivation.toss(); - specVoucherActivation.response().should.have.status(200); - specVoucherActivation - .response() - .should.have.jsonLike({ result_status: 'Successfully activated voucher' }); -}); - -// Scenario: The user is not able to activate a pre-activated voucher because of an empty payload -When( - 'The user triggers an action with an empty payload to activate a pre-activated voucher', - () => { - specVoucherActivation.patch(baseUrl).withBody(); - } +Then( + /^Receives a response from the \/vouchers\/voucher_activation endpoint$/, + async () => await specVoucherActivation.toss() ); Then( - 'The result of the operation returns an error because of empty payload', - async () => { - await specVoucherActivation.toss(); - specVoucherActivation.response().should.have.status(400); + /^The \/vouchers\/voucher_activation endpoint response should be returned in a timely manner 15000ms$/, + () => specVoucherActivation .response() - .should.have.body({ message: 'Invalid request' }); - } + .to.have.responseTimeLessThan(defaultExpectedResponseTime) ); -// Scenario: The user is not able to activate a pre-activated voucher because of an invalid voucher serial number -When( - 'The user triggers an action with an invalid serial number to activate a pre-activated voucher', - () => { - specVoucherActivation.patch(baseUrl).withBody({ - voucher_serial_number: 0, - Gov_Stack_BB: 'example Gov_Stack_BB', - }); - } +Then( + /^The \/vouchers\/voucher_activation endpoint response should have status (\d+)$/, + status => specVoucherActivation.response().to.have.status(status) ); Then( - 'The result of the operation returns an error because of an invalid serial number', - async () => { - await specVoucherActivation.toss(); - specVoucherActivation.response().should.have.status(456); - specVoucherActivation - .response() - .should.have.body({ message: 'Invalid voucher serial number' }); - } + /^The \/vouchers\/voucher_activation endpoint response should match json schema$/, + () => + chai + .expect(specVoucherActivation._response.json) + .to.be.jsonSchema(voucherActivationResponseSchema) ); // Scenario: The user is not able to activate a pre-activated voucher because of Gov Stack Building Block does not exist +// Others Given, When, Then are written in the aforementioned example +When(/^Provides optional X-Callback-URL header$/, () => { + specVoucherActivation.withHeaders( + 'X-Callback-URL', + 'https://myserver.com/send/callback/here' + ); +}); + +// Scenario: Successfully activates a pre-activated voucher with the optional X-Channel header +// Others Given, When, Then are written in the aforementioned example +When(/^Provides optional X-Channel header$/, () => { + specVoucherActivation.withHeaders('X-Channel', 'Web'); +}); + +// Scenario: Successfully activates a pre-activated voucher with the optional X-Date header +// Others Given, When, Then are written in the aforementioned example +When(/^Provides optional X-Date header$/, () => { + specVoucherActivation.withHeaders('X-Date', `${new Date().toISOString()}`); +}); + +// Scenario: Successfully activates a pre-activated voucher with the optional X-CorrelationID header +// Others Given, When, Then are written in the aforementioned example +When(/^Provides optional X-CorrelationID header$/, () => { + specVoucherActivation.withHeaders( + 'X-CorrelationID', + '40e9da5c-10fd-11ee-be56-0242ac120002' + ); +}); + +// Scenario: Unable to activate a pre-activated voucher because of an empty payload +// Others Given, Then are written in the aforementioned example When( - 'The user triggers an action with an invalid Gov Stack Building Block to activate a pre-activated voucher', - () => { - specVoucherActivation - .patch(baseUrl) - .withBody({ voucher_serial_number: 4321 }); - } + /^Sends PATCH \/vouchers\/voucher_activation request without payload$/, + () => specVoucherActivation.patch(baseUrl).withJson({}) ); Then( - 'The result of the operation returns an error because of Gov Stack Building Block does not exist', - async () => { - await specVoucherActivation.toss(); - specVoucherActivation.response().should.have.status(460); - specVoucherActivation - .response() - .should.have.body({ message: 'Gov Stack Building Block does not exist' }); - } + /^The \/vouchers\/voucher_activation endpoint response should match json error schema$/, + () => + chai + .expect(specVoucherActivation._response.json) + .to.be.jsonSchema(voucherResponseErrorSchema) +); + +// Scenario: Unable to activate a pre-activated voucher because of an invalid voucher_serial_number +// Others Given, Then are written in the aforementioned example +When( + /^Sends PATCH \/vouchers\/voucher_activation request with an invalid voucher_serial_number$/, + () => + specVoucherActivation.patch(baseUrl).withJson({ + voucher_serial_number: 'invalid_voucher_serial_number', + Gov_Stack_BB: 'bb-digital-registries', + }) +); + +// Scenario: Unable to activate a pre-activated voucher because given Gov_Stack_BB does not exist +// Others Given, Then are written in the aforementioned example +When( + /^Sends PATCH \/vouchers\/voucher_activation request with an invalid Gov_Stack_BB and valid voucher_serial_number = (\d+)$/, + voucher_serial_number => + specVoucherActivation.patch(baseUrl).withJson({ + voucher_serial_number: voucher_serial_number, + Gov_Stack_BB: 'not_exist', + }) ); -After(() => { +After(endpointTag, () => { specVoucherActivation.end(); }); diff --git a/test/openAPI/features/voucher_activation.feature b/test/openAPI/features/voucher_activation.feature index 4a23c8e..c793151 100644 --- a/test/openAPI/features/voucher_activation.feature +++ b/test/openAPI/features/voucher_activation.feature @@ -1,23 +1,82 @@ +@method=PATCH @endpoint=/vouchers/voucher_activation Feature: The VoucherActivation API is used to activate a pre-activated voucher - This API requests for voucher activation by sending the voucher serial number and Gov Stack BB + The VoucherActivation API is used by a non Payment Building Blocks in the GovStack Framework to activate a pre-activated voucher. + This is second function call is intended to ensure that the voucher is only activated when it is disbursed. + This API requests for the activation of a voucher when the caller sends the voucher number to be activated. + If the API call is successful, the activation is confirmed and the voucher can now be used by the beneficiary. - Request endpoint: PATCH /vouchers/voucher_activation + @smoke @positive + Scenario: Successfully activates a pre-activated voucher smoke type test + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5555 + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 200 + And The /vouchers/voucher_activation endpoint response should match json schema - Background: The user wants to activate pre-activated voucher - Given The user wants to activate pre-activated voucher + @positive + Scenario: Successfully activates a pre-activated voucher with the optional X-Callback-URL header + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5556 + And Provides optional X-Callback-URL header + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 200 + And The /vouchers/voucher_activation endpoint response should match json schema - Scenario: The user successfully activates a pre-activated voucher - When The user triggers an action with a valid payload to activate a pre-activated voucher - Then The user successfully activates a pre-activated voucher + @positive + Scenario: Successfully activates a pre-activated voucher with the optional X-Channel header + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5557 + And Provides optional X-Channel header + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 200 + And The /vouchers/voucher_activation endpoint response should match json schema - Scenario: The user is not able to activate a pre-activated voucher because of an empty payload - When The user triggers an action with an empty payload to activate a pre-activated voucher - Then The result of the operation returns an error because of empty payload + @positive + Scenario: Successfully activates a pre-activated voucher with the optional X-Date header + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5558 + And Provides optional X-Date header + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 200 + And The /vouchers/voucher_activation endpoint response should match json schema - Scenario: The user is not able to activate a pre-activated voucher because of an invalid voucher serial number - When The user triggers an action with an invalid serial number to activate a pre-activated voucher - Then The result of the operation returns an error because of an invalid serial number + @positive + Scenario: Successfully activates a pre-activated voucher with the optional X-CorrelationID header + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5559 + And Provides optional X-CorrelationID header + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 200 + And The /vouchers/voucher_activation endpoint response should match json schema - Scenario: The user is not able to activate a pre-activated voucher because of Gov Stack Building Block does not exist - When The user triggers an action with an invalid Gov Stack Building Block to activate a pre-activated voucher - Then The result of the operation returns an error because of Gov Stack Building Block does not exist + @negative + Scenario: Unable to activate a pre-activated voucher because of an empty payload + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request without payload + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 400 + And The /vouchers/voucher_activation endpoint response should match json error schema + + @negative + Scenario: Unable to activate a pre-activated voucher because of an invalid voucher_serial_number + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request with an invalid voucher_serial_number + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 456 + And The /vouchers/voucher_activation endpoint response should match json error schema + + @negative + Scenario: Unable to activate a pre-activated voucher because given Gov_Stack_BB does not exist + Given Non Payment Building Block wants to activate a pre-activated voucher + When Sends PATCH /vouchers/voucher_activation request with an invalid Gov_Stack_BB and valid voucher_serial_number = 5560 + Then Receives a response from the /vouchers/voucher_activation endpoint + And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms + And The /vouchers/voucher_activation endpoint response should have status 460 + And The /vouchers/voucher_activation endpoint response should match json error schema From 570920f24e4a11e9a45740b105280afd3d753c6e Mon Sep 17 00:00:00 2001 From: mgrochalskisoldevelo Date: Tue, 4 Jul 2023 13:52:50 +0200 Subject: [PATCH 05/12] TECH-494: Filled test-data.json file with data for voucher activation tests --- .../features/voucher_activation.feature | 10 ++--- test/openAPI/test-data.json | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/test/openAPI/features/voucher_activation.feature b/test/openAPI/features/voucher_activation.feature index c793151..943b006 100644 --- a/test/openAPI/features/voucher_activation.feature +++ b/test/openAPI/features/voucher_activation.feature @@ -8,7 +8,7 @@ Feature: The VoucherActivation API is used to activate a pre-activated voucher @smoke @positive Scenario: Successfully activates a pre-activated voucher smoke type test Given Non Payment Building Block wants to activate a pre-activated voucher - When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5555 + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5550 Then Receives a response from the /vouchers/voucher_activation endpoint And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms And The /vouchers/voucher_activation endpoint response should have status 200 @@ -17,7 +17,7 @@ Feature: The VoucherActivation API is used to activate a pre-activated voucher @positive Scenario: Successfully activates a pre-activated voucher with the optional X-Callback-URL header Given Non Payment Building Block wants to activate a pre-activated voucher - When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5556 + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5551 And Provides optional X-Callback-URL header Then Receives a response from the /vouchers/voucher_activation endpoint And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms @@ -27,7 +27,7 @@ Feature: The VoucherActivation API is used to activate a pre-activated voucher @positive Scenario: Successfully activates a pre-activated voucher with the optional X-Channel header Given Non Payment Building Block wants to activate a pre-activated voucher - When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5557 + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5552 And Provides optional X-Channel header Then Receives a response from the /vouchers/voucher_activation endpoint And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms @@ -37,7 +37,7 @@ Feature: The VoucherActivation API is used to activate a pre-activated voucher @positive Scenario: Successfully activates a pre-activated voucher with the optional X-Date header Given Non Payment Building Block wants to activate a pre-activated voucher - When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5558 + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5553 And Provides optional X-Date header Then Receives a response from the /vouchers/voucher_activation endpoint And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms @@ -47,7 +47,7 @@ Feature: The VoucherActivation API is used to activate a pre-activated voucher @positive Scenario: Successfully activates a pre-activated voucher with the optional X-CorrelationID header Given Non Payment Building Block wants to activate a pre-activated voucher - When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5559 + When Sends PATCH /vouchers/voucher_activation request with valid payload where voucher_serial_number = 5554 And Provides optional X-CorrelationID header Then Receives a response from the /vouchers/voucher_activation endpoint And The /vouchers/voucher_activation endpoint response should be returned in a timely manner 15000ms diff --git a/test/openAPI/test-data.json b/test/openAPI/test-data.json index a6486d4..e037335 100644 --- a/test/openAPI/test-data.json +++ b/test/openAPI/test-data.json @@ -147,6 +147,48 @@ "voucher_status": "Pre-Activated", "voucher_amount": "1000" }, + { + "voucher_number": "55501", + "voucher_serial_number": 5550, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Pre-Activated", + "voucher_amount": "1000" + }, + { + "voucher_number": "55511", + "voucher_serial_number": 5551, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Pre-Activated", + "voucher_amount": "1000" + }, + { + "voucher_number": "55521", + "voucher_serial_number": 5552, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Pre-Activated", + "voucher_amount": "1000" + }, + { + "voucher_number": "55531", + "voucher_serial_number": 5553, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Pre-Activated", + "voucher_amount": "1000" + }, + { + "voucher_number": "55541", + "voucher_serial_number": 5554, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Pre-Activated", + "voucher_amount": "1000" + }, + { + "voucher_number": "55601", + "voucher_serial_number": 5560, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Pre-Activated", + "voucher_amount": "1000" + }, "// Activated", { "voucher_number": "170282", From fc1e1ee35a10f5104160cf32533b9c2f138d8291 Mon Sep 17 00:00:00 2001 From: mgrochalskisoldevelo Date: Mon, 3 Jul 2023 13:30:33 +0200 Subject: [PATCH 06/12] TECH-495: Updated cucumber tests, gherkin scenarios, test-data file and mocks for voucher redemption --- .../mockoon-paymentsbbvoucher.json | 281 +++++------------- .../features/support/helpers/helpers.js | 7 + .../features/support/voucher_redemption.js | 225 ++++++-------- .../features/voucher_redemption.feature | 72 +++-- test/openAPI/test-data.json | 14 + 5 files changed, 237 insertions(+), 362 deletions(-) diff --git a/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json b/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json index b4897ab..f462f3a 100644 --- a/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json +++ b/examples/mock-bb-payments/mockoon-paymentsbbvoucher.json @@ -518,11 +518,11 @@ "endpoint": "vouchers/voucher_redemption", "responses": [ { - "uuid": "525fc27b-5ec1-41b2-b2ad-163b5352228e", - "body": "{\n \"result_status\": \"Voucher is successfully redeemed\"\n}", + "uuid": "1fcd9573-2753-4b2b-a6df-fd54740888fe", + "body": "{\n \"message\": \"string\"\n}", "latency": 0, - "statusCode": 200, - "label": "Voucher is successfully redeemed", + "statusCode": 400, + "label": "Invalid request", "headers": [], "bodyType": "INLINE", "filePath": "", @@ -531,140 +531,91 @@ "rules": [ { "target": "body", - "modifier": "voucher_number", - "value": "^((?!(0))[0-9]{0,19})$", + "modifier": "", + "value": "", "invert": false, - "operator": "regex" + "operator": "null" }, { "target": "body", "modifier": "voucher_number", "value": "", - "invert": true, + "invert": false, "operator": "null" }, { "target": "body", "modifier": "Gov_Stack_BB", - "value": "Gov_Stack_BB", + "value": "", "invert": false, - "operator": "equals" + "operator": "null" }, { "target": "body", "modifier": "merchant_name", - "value": "Leonard Snow", + "value": "", "invert": false, - "operator": "equals" + "operator": "null" }, { "target": "body", "modifier": "merchant_bank_details", "value": "", - "invert": true, + "invert": false, "operator": "null" }, { "target": "body", "modifier": "merchant_voucher_group", - "value": "Payment Voucher", - "invert": false, - "operator": "equals" - }, - { - "target": "body", - "modifier": "override", "value": "", - "invert": true, + "invert": false, "operator": "null" }, { "target": "body", - "modifier": "", + "modifier": "override", "value": "", - "invert": true, + "invert": false, "operator": "null" } ], - "rulesOperator": "AND", + "rulesOperator": "OR", "disableTemplating": false, "fallbackTo404": false, - "default": false + "default": true }, { - "uuid": "79e9d60b-88c5-4342-87b0-e3b14a4005db", - "body": "{\n \"message\": \"GovStack Building Block does not exist\"\n}", + "uuid": "420d96ff-13ef-4a60-a8b6-298131896b40", + "body": "{\n \"message\": \"Cannot credit merchant\"\n}", "latency": 0, - "statusCode": 460, - "label": "Error - GovStack Building Block does not exist", + "statusCode": 463, + "label": "Cannot credit merchant", "headers": [], "bodyType": "INLINE", "filePath": "", "databucketID": "", "sendFileAsBody": false, "rules": [ - { - "target": "body", - "modifier": "voucher_number", - "value": "^((?!(0))[0-9]{0,19})$", - "invert": false, - "operator": "regex" - }, - { - "target": "body", - "modifier": "voucher_number", - "value": "", - "invert": true, - "operator": "null" - }, - { - "target": "body", - "modifier": "Gov_Stack_BB", - "value": "Gov_Stack_BB", - "invert": true, - "operator": "equals" - }, { "target": "body", "modifier": "merchant_name", - "value": "Leonard Snow", + "value": "Annie Krueger", "invert": false, "operator": "equals" }, { "target": "body", "modifier": "merchant_bank_details", - "value": "", - "invert": true, - "operator": "null" - }, - { - "target": "body", - "modifier": "merchant_voucher_group", - "value": "", - "invert": true, - "operator": "null" + "value": "Omega Holding Company", + "invert": false, + "operator": "equals" }, { "target": "body", "modifier": "merchant_voucher_group", - "value": "Payment Voucher", + "value": "insufficient funds", "invert": false, "operator": "equals" - }, - { - "target": "body", - "modifier": "override", - "value": "", - "invert": true, - "operator": "null" - }, - { - "target": "body", - "modifier": "", - "value": "", - "invert": true, - "operator": "null" } ], "rulesOperator": "AND", @@ -673,69 +624,66 @@ "default": false }, { - "uuid": "93ce5d98-5969-45e7-b8eb-d0faabec96ab", - "body": "{\n \"message\": \"Invalid voucher number\"\n}", + "uuid": "98abe02e-d027-4df5-b41e-899e3f6a69ad", + "body": "{\n \"message\": \"Insufficient funds in funding a/c\"\n}", "latency": 0, - "statusCode": 461, - "label": "Invalid request - Invalid voucher number", + "statusCode": 462, + "label": "Insufficient funds in funding a/c", "headers": [], "bodyType": "INLINE", "filePath": "", "databucketID": "", "sendFileAsBody": false, "rules": [ - { - "target": "body", - "modifier": "voucher_number", - "value": "", - "invert": false, - "operator": "null" - }, - { - "target": "body", - "modifier": "Gov_Stack_BB", - "value": "Gov_Stack_BB", - "invert": false, - "operator": "equals" - }, { "target": "body", "modifier": "merchant_name", - "value": "Leonard Snow", + "value": "Ronan Oliver", "invert": false, "operator": "equals" }, { "target": "body", "modifier": "merchant_bank_details", - "value": "", - "invert": true, - "operator": "null" - }, - { - "target": "body", - "modifier": "merchant_voucher_group", - "value": "", - "invert": true, - "operator": "null" + "value": "Vigor Bank Group", + "invert": false, + "operator": "equals" }, { "target": "body", "modifier": "merchant_voucher_group", - "value": "Payment Voucher", + "value": "insufficient funds", "invert": false, "operator": "equals" - }, + } + ], + "rulesOperator": "AND", + "disableTemplating": false, + "fallbackTo404": false, + "default": false + }, + { + "uuid": "93ce5d98-5969-45e7-b8eb-d0faabec96ab", + "body": "{\n \"message\": \"Invalid voucher number\"\n}", + "latency": 0, + "statusCode": 461, + "label": "Invalid voucher number", + "headers": [], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [ { "target": "body", - "modifier": "override", - "value": "", + "modifier": "voucher_number", + "value": "^[1-9]\\d{0,18}$", "invert": true, - "operator": "null" + "operator": "regex" }, { "target": "body", - "modifier": "", + "modifier": "voucher_number", "value": "", "invert": true, "operator": "null" @@ -747,11 +695,11 @@ "default": false }, { - "uuid": "98abe02e-d027-4df5-b41e-899e3f6a69ad", - "body": "{\n \"message\": \"Insufficient funds in funding a/c\"\n}", + "uuid": "79e9d60b-88c5-4342-87b0-e3b14a4005db", + "body": "{\n \"message\": \"GovStack Building Block does not exist\"\n}", "latency": 0, - "statusCode": 462, - "label": "Error - Insufficient funds in funding a/c", + "statusCode": 460, + "label": "GovStack Building Block does not exist", "headers": [], "bodyType": "INLINE", "filePath": "", @@ -761,58 +709,16 @@ { "target": "body", "modifier": "voucher_number", - "value": "^((?!(0))[0-9]{0,19})$", + "value": "^[1-9]\\d{0,18}$", "invert": false, "operator": "regex" }, - { - "target": "body", - "modifier": "voucher_number", - "value": "", - "invert": true, - "operator": "null" - }, { "target": "body", "modifier": "Gov_Stack_BB", - "value": "Gov_Stack_BB", - "invert": false, - "operator": "equals" - }, - { - "target": "body", - "modifier": "merchant_name", - "value": "Ronan Oliver", - "invert": false, - "operator": "equals" - }, - { - "target": "body", - "modifier": "merchant_bank_details", - "value": "", - "invert": true, - "operator": "null" - }, - { - "target": "body", - "modifier": "merchant_voucher_group", - "value": "insufficient funds", + "value": "invalid_bb", "invert": false, "operator": "equals" - }, - { - "target": "body", - "modifier": "override", - "value": "", - "invert": true, - "operator": "null" - }, - { - "target": "body", - "modifier": "", - "value": "", - "invert": true, - "operator": "null" } ], "rulesOperator": "AND", @@ -821,11 +727,11 @@ "default": false }, { - "uuid": "420d96ff-13ef-4a60-a8b6-298131896b40", - "body": "{\n \"message\": \"Cannot credit merchant\"\n}", + "uuid": "525fc27b-5ec1-41b2-b2ad-163b5352228e", + "body": "{\n \"result_status\": \"string\"\n}", "latency": 0, - "statusCode": 463, - "label": "Error - Cannot credit merchant", + "statusCode": 200, + "label": "Voucher successfully redeemed", "headers": [], "bodyType": "INLINE", "filePath": "", @@ -835,7 +741,7 @@ { "target": "body", "modifier": "voucher_number", - "value": "^((?!(0))[0-9]{0,19})$", + "value": "^[1-9]\\d{0,18}$", "invert": false, "operator": "regex" }, @@ -846,19 +752,12 @@ "invert": true, "operator": "null" }, - { - "target": "body", - "modifier": "Gov_Stack_BB", - "value": "Gov_Stack_BB", - "invert": false, - "operator": "equals" - }, { "target": "body", "modifier": "merchant_name", - "value": "Annie Krueger", - "invert": false, - "operator": "equals" + "value": "", + "invert": true, + "operator": "null" }, { "target": "body", @@ -870,20 +769,13 @@ { "target": "body", "modifier": "merchant_voucher_group", - "value": "insufficient funds", - "invert": false, - "operator": "equals" - }, - { - "target": "body", - "modifier": "override", "value": "", "invert": true, "operator": "null" }, { "target": "body", - "modifier": "", + "modifier": "override", "value": "", "invert": true, "operator": "null" @@ -893,31 +785,6 @@ "disableTemplating": false, "fallbackTo404": false, "default": false - }, - { - "uuid": "1fcd9573-2753-4b2b-a6df-fd54740888fe", - "body": "{\n \"message\": \"Invalid request\"\n}", - "latency": 0, - "statusCode": 400, - "label": "Invalid request", - "headers": [], - "bodyType": "INLINE", - "filePath": "", - "databucketID": "", - "sendFileAsBody": false, - "rules": [ - { - "target": "body", - "modifier": "", - "value": "", - "invert": false, - "operator": "null" - } - ], - "rulesOperator": "OR", - "disableTemplating": false, - "fallbackTo404": false, - "default": true } ], "enabled": true, diff --git a/test/openAPI/features/support/helpers/helpers.js b/test/openAPI/features/support/helpers/helpers.js index 901713d..bdb3253 100644 --- a/test/openAPI/features/support/helpers/helpers.js +++ b/test/openAPI/features/support/helpers/helpers.js @@ -14,6 +14,7 @@ module.exports = { prepaymentValidationResponseEndpoint: 'prepayment-validation-response', registerBeneficiaryEndpoint: 'register-beneficiary', updateBeneficiaryDetailsEndpoint: 'update-beneficiary-details', + voucherRedemptionEndpoint: 'vouchers/voucher_redemption', g2pResponseSchema: { type: 'object', properties: { @@ -86,6 +87,12 @@ module.exports = { }, voucherActivationEndpoint: 'vouchers/voucher_activation', voucherActivationResponseSchema: { + type: 'object', + properties: { result_status: { type: 'string' } }, + required: ['result_status'], + }, + voucherRedemptionResponseSchema: { + type: 'object', properties: { result_status: { type: 'string' } }, required: ['result_status'], }, diff --git a/test/openAPI/features/support/voucher_redemption.js b/test/openAPI/features/support/voucher_redemption.js index a6cce2a..7e9e9e9 100644 --- a/test/openAPI/features/support/voucher_redemption.js +++ b/test/openAPI/features/support/voucher_redemption.js @@ -1,182 +1,143 @@ -const pactum = require('pactum'); +const chai = require('chai'); +const { spec } = require('pactum'); const { Given, When, Then, Before, After } = require('@cucumber/cucumber'); -const { localhost } = require('./helpers/helpers'); +const { + localhost, + voucherRedemptionEndpoint, + voucherRedemptionResponseSchema, + voucherResponseErrorSchema, +} = require('./helpers/helpers'); -let specVoucherRedemption; -let validVoucherNumber; -let validGovstackBB; -let validMerchantName; -let validMerchantBankDetails; -let validMerchantVoucherGroup; -let override; +chai.use(require('chai-json-schema')); -const baseUrl = `${localhost}vouchers/voucher_redemption`; +const baseUrl = localhost + voucherRedemptionEndpoint; +const endpointTag = { tags: `@endpoint=/${voucherRedemptionEndpoint}` }; -Before(() => { - specVoucherRedemption = pactum.spec(); +Before(endpointTag, () => { + specVoucherRedemption = spec(); }); -// Background -Given('The user wants to redeem the voucher', () => { - validVoucherNumber = 96767543; - validGovstackBB = 'Gov_Stack_BB'; - validMerchantName = 'Leonard Snow'; - validMerchantBankDetails = 'Spotlight Corporation'; - validMerchantVoucherGroup = 'Payment Voucher'; - override = true; - return ( - validVoucherNumber, - validGovstackBB, - validMerchantName, - validMerchantBankDetails, - validMerchantVoucherGroup, - override - ); -}); - -// Scenario: The user successfully redeems the voucher -When('The user triggers an action to redeem the voucher', () => { - specVoucherRedemption.post(baseUrl).withBody({ - voucher_number: validVoucherNumber, - Gov_Stack_BB: validGovstackBB, - merchant_name: validMerchantName, - merchant_bank_details: validMerchantBankDetails, - merchant_voucher_group: validMerchantVoucherGroup, - override: override, - }); -}); +// Scenario: A non-Payment Building Block successfully redeems a voucher smoke type test +Given( + /^A non-Payment Building Block wants to redeem a voucher$/, + () => 'A non-Payment Building Block wants to redeem a voucher' +); -Then('The user successfully redeems the voucher', async () => { - await specVoucherRedemption.toss(); - specVoucherRedemption.response().should.have.status(200); - specVoucherRedemption.response().should.have.jsonLike({ - result_status: 'Voucher is successfully redeemed', +When(/^Sends POST request with valid payload to redeem a voucher$/, () => { + specVoucherRedemption.post(baseUrl).withJson({ + voucher_number: '6003', + Gov_Stack_BB: 'bb-digital-registries', + merchant_name: 'Melissa Stephenson', + merchant_bank_details: 'Citizen Service Banks', + merchant_voucher_group: 'Payment Voucher', + override: true, }); }); -// Scenario: The user is not able to redeem the voucher, because of the GovStack Building Block does not exist -When( - 'The user triggers an action to redeem the voucher without an existing GovStack Building Block variable', - () => { - specVoucherRedemption.post(baseUrl).withBody({ - voucher_number: validVoucherNumber, - Gov_Stack_BB: 'Some', - merchant_name: validMerchantName, - merchant_bank_details: validMerchantBankDetails, - merchant_voucher_group: validMerchantVoucherGroup, - override: override, - }); - } -); - Then( - 'The result of an operation returns an error because the GovStack Building Block does not exist', + /^Receives a response from the \/vouchers\/voucher_redemption endpoint$/, async () => { await specVoucherRedemption.toss(); - specVoucherRedemption.response().should.have.status(460); - specVoucherRedemption.response().should.have.jsonLike({ - message: 'GovStack Building Block does not exist', - }); } ); -// Scenario: The user is not able to redeem the voucher, because of an invalid voucher number -When( - 'The user triggers an action to redeem the voucher with an invalid voucher number', - () => { - specVoucherRedemption.post(baseUrl).withBody({ - voucher_number: null, - Gov_Stack_BB: validGovstackBB, - merchant_name: validMerchantName, - merchant_bank_details: validMerchantBankDetails, - merchant_voucher_group: validMerchantVoucherGroup, - override: override, - }); - } +Then( + /^The \/vouchers\/voucher_redemption endpoint response should be returned in a timely manner (\d+) ms$/, + responseTime => + specVoucherRedemption.response().to.have.responseTimeLessThan(responseTime) ); Then( - 'The result of an operation returns an error because of an invalid voucher number', - async () => { - await specVoucherRedemption.toss(); - specVoucherRedemption.response().should.have.status(461); - specVoucherRedemption.response().should.have.jsonLike({ - message: 'Invalid voucher number', - }); - } + /^The \/vouchers\/voucher_redemption endpoint response should have status (\d+)$/, + status => specVoucherRedemption.response().to.have.status(status) +); + +Then( + /^The \/vouchers\/voucher_redemption endpoint response should match json schema$/, + () => + chai + .expect(specVoucherRedemption._response.json) + .to.be.jsonSchema(voucherRedemptionResponseSchema) ); -// Scenario: The user is not able to redeem the voucher because of an invalid request +// Scenario: A non-Payment Building Block is unable to redeem a voucher because of the invalid request +// Others Given and Then are written in the aforementioned example +When(/^Sends POST request without payload to redeem a voucher$/, () => { + specVoucherRedemption.post(baseUrl); +}); + +Then( + /^The \/vouchers\/voucher_redemption endpoint response should match json error schema$/, + () => + chai + .expect(specVoucherRedemption._response.json) + .to.be.jsonSchema(voucherResponseErrorSchema) +); + +// Scenario: A non-Payment Building Block is unable to redeem a voucher because the GovStack Building Block does not exist +// Others Given and Then are written in the aforementioned example When( - 'The user triggers an action to redeem the voucher with an invalid request', + /^Sends POST request with invalid Gov_Stack_BB in the payload to redeem a voucher$/, () => { - specVoucherRedemption.post(baseUrl).withBody(); + specVoucherRedemption.post(baseUrl).withJson({ + voucher_number: '6004', + Gov_Stack_BB: 'invalid_bb', + merchant_name: 'Melissa Stephenson', + merchant_bank_details: 'Citizen Service Banks', + merchant_voucher_group: 'Payment Voucher', + override: true, + }); } ); -Then( - 'The result of an operation returns an error because of an invalid request', - async () => { - await specVoucherRedemption.toss(); - specVoucherRedemption.response().should.have.status(400); - specVoucherRedemption.response().should.have.jsonLike({ - message: 'Invalid request', +// Scenario: A non-Payment Building Block is unable to redeem a voucher because of the invalid voucher number +// Others Given and Then are written in the aforementioned example +When( + /^Sends POST request with invalid voucher_number in the payload to redeem a voucher$/, + () => { + specVoucherRedemption.post(baseUrl).withJson({ + voucher_number: 'notAnumber', + Gov_Stack_BB: 'bb-digital-registries', + merchant_name: 'Melissa Stephenson', + merchant_bank_details: 'Citizen Service Banks', + merchant_voucher_group: 'Payment Voucher', + override: true, }); } ); -// Scenario: The user is not able to redeem the voucher because of insufficient funds in funding a/c +// Scenario: A non-Payment Building Block is unable to redeem a voucher because of insufficient funds in funding a/c +// Others Given and Then are written in the aforementioned example When( - 'The user triggers an action to redeem the voucher with insufficient funds in funding a\\/c', + /^Sends POST request to redeem a voucher with insufficient funds in funding a\/c$/, () => { - specVoucherRedemption.post(baseUrl).withBody({ - voucher_number: validVoucherNumber, - Gov_Stack_BB: validGovstackBB, + specVoucherRedemption.post(baseUrl).withJson({ + voucher_number: '6004', + Gov_Stack_BB: 'bb-digital-registries', merchant_name: 'Ronan Oliver', merchant_bank_details: 'Vigor Bank Group', merchant_voucher_group: 'insufficient funds', - override: override, - }); - } -); - -Then( - 'The result of an operation returns an error, because of insufficient funds in funding a\\/c', - async () => { - await specVoucherRedemption.toss(); - specVoucherRedemption.response().should.have.status(462); - specVoucherRedemption.response().should.have.jsonLike({ - message: 'Insufficient funds in funding a/c', + override: true, }); } ); -// Scenario: The user is not able to redeem the voucher because the merchant cannot be credited +// Scenario: A non-Payment Building Block is unable to redeem a voucher because the merchant cannot be credited +// Others Given and Then are written in the aforementioned example When( - 'The user triggers an action to redeem the voucher with the merchant that cannot be credited', + /^Sends POST request to redeem a voucher with merchant that cannot be credited$/, () => { - specVoucherRedemption.post(baseUrl).withBody({ - voucher_number: validVoucherNumber, - Gov_Stack_BB: validGovstackBB, + specVoucherRedemption.post(baseUrl).withJson({ + voucher_number: '6004', + Gov_Stack_BB: 'bb-digital-registries', merchant_name: 'Annie Krueger', merchant_bank_details: 'Omega Holding Company', merchant_voucher_group: 'insufficient funds', - override: override, - }); - } -); - -Then( - 'The result of an operation returns an error because the merchant cannot be credited', - async () => { - await specVoucherRedemption.toss(); - specVoucherRedemption.response().should.have.status(463); - specVoucherRedemption.response().should.have.jsonLike({ - message: 'Cannot credit merchant', + override: true, }); } ); -After(() => { +After(endpointTag, () => { specVoucherRedemption.end(); }); diff --git a/test/openAPI/features/voucher_redemption.feature b/test/openAPI/features/voucher_redemption.feature index 7b47232..85130e1 100644 --- a/test/openAPI/features/voucher_redemption.feature +++ b/test/openAPI/features/voucher_redemption.feature @@ -1,31 +1,57 @@ +@method=POST @endpoint=/vouchers/voucher_redemption Feature: The VoucherRedemption API is used by a non Payment Building Blocks in the GovStack Framework to redeem a voucher. Request for voucher redemption by sending the voucher number, the merchant name and merchant payment details. - - Request endpoint: POST /vouchers/voucher_redemption - Background: - Given The user wants to redeem the voucher + @smoke @postitive + Scenario: A non-Payment Building Block successfully redeems a voucher smoke type test + Given A non-Payment Building Block wants to redeem a voucher + When Sends POST request with valid payload to redeem a voucher + Then Receives a response from the /vouchers/voucher_redemption endpoint + And The /vouchers/voucher_redemption endpoint response should be returned in a timely manner 15000 ms + And The /vouchers/voucher_redemption endpoint response should have status 200 + And The /vouchers/voucher_redemption endpoint response should match json schema - Scenario: The user successfully redeems the voucher - When The user triggers an action to redeem the voucher - Then The user successfully redeems the voucher + @negative + Scenario: A non-Payment Building Block is unable to redeem a voucher because of the invalid request + Given A non-Payment Building Block wants to redeem a voucher + When Sends POST request without payload to redeem a voucher + Then Receives a response from the /vouchers/voucher_redemption endpoint + And The /vouchers/voucher_redemption endpoint response should be returned in a timely manner 15000 ms + And The /vouchers/voucher_redemption endpoint response should have status 400 + And The /vouchers/voucher_redemption endpoint response should match json error schema - Scenario: The user is not able to redeem the voucher, because the GovStack Building Block does not exist - When The user triggers an action to redeem the voucher without an existing GovStack Building Block variable - Then The result of an operation returns an error because the GovStack Building Block does not exist + @negative + Scenario: A non-Payment Building Block is unable to redeem a voucher because the GovStack Building Block does not exist + Given A non-Payment Building Block wants to redeem a voucher + When Sends POST request with invalid Gov_Stack_BB in the payload to redeem a voucher + Then Receives a response from the /vouchers/voucher_redemption endpoint + And The /vouchers/voucher_redemption endpoint response should be returned in a timely manner 15000 ms + And The /vouchers/voucher_redemption endpoint response should have status 460 + And The /vouchers/voucher_redemption endpoint response should match json error schema - Scenario: The user is not able to redeem the voucher, because of an invalid voucher number - When The user triggers an action to redeem the voucher with an invalid voucher number - Then The result of an operation returns an error because of an invalid voucher number - - Scenario: The user is not able to redeem the voucher because of an invalid request - When The user triggers an action to redeem the voucher with an invalid request - Then The result of an operation returns an error because of an invalid request + @negative + Scenario: A non-Payment Building Block is unable to redeem a voucher because of the invalid voucher number + Given A non-Payment Building Block wants to redeem a voucher + When Sends POST request with invalid voucher_number in the payload to redeem a voucher + Then Receives a response from the /vouchers/voucher_redemption endpoint + And The /vouchers/voucher_redemption endpoint response should be returned in a timely manner 15000 ms + And The /vouchers/voucher_redemption endpoint response should have status 461 + And The /vouchers/voucher_redemption endpoint response should match json error schema - Scenario: The user is not able to redeem the voucher because of insufficient funds in funding a/c - When The user triggers an action to redeem the voucher with insufficient funds in funding a/c - Then The result of an operation returns an error, because of insufficient funds in funding a/c + @negative + Scenario: A non-Payment Building Block is unable to redeem a voucher because of insufficient funds in funding a/c + Given A non-Payment Building Block wants to redeem a voucher + When Sends POST request to redeem a voucher with insufficient funds in funding a/c + Then Receives a response from the /vouchers/voucher_redemption endpoint + And The /vouchers/voucher_redemption endpoint response should be returned in a timely manner 15000 ms + And The /vouchers/voucher_redemption endpoint response should have status 462 + And The /vouchers/voucher_redemption endpoint response should match json error schema - Scenario: The user is not able to redeem the voucher because the merchant cannot be credited - When The user triggers an action to redeem the voucher with the merchant that cannot be credited - Then The result of an operation returns an error because the merchant cannot be credited + @negative + Scenario: A non-Payment Building Block is unable to redeem a voucher because the merchant cannot be credited + Given A non-Payment Building Block wants to redeem a voucher + When Sends POST request to redeem a voucher with merchant that cannot be credited + Then Receives a response from the /vouchers/voucher_redemption endpoint + And The /vouchers/voucher_redemption endpoint response should be returned in a timely manner 15000 ms + And The /vouchers/voucher_redemption endpoint response should have status 463 + And The /vouchers/voucher_redemption endpoint response should match json error schema diff --git a/test/openAPI/test-data.json b/test/openAPI/test-data.json index e037335..30e6cee 100644 --- a/test/openAPI/test-data.json +++ b/test/openAPI/test-data.json @@ -225,6 +225,13 @@ "voucher_status": "Activated", "voucher_amount": "1000" }, + { + "voucher_number": "6003", + "voucher_serial_number": 60031111, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Activated", + "voucher_amount": "1000" + }, { "voucher_number": "600011", "voucher_serial_number": 60001, @@ -260,6 +267,13 @@ "voucher_status": "Activated", "voucher_amount": "1000" }, + { + "voucher_number": "6004", + "voucher_serial_number": 60041111, + "Gov_Stack_BB": "bb-digital-registries", + "voucher_status": "Activated", + "voucher_amount": "1000" + }, "// Purged", { "voucher_number": "725743", From 66eae8f4ebcbd0dc0ccf6e6514938eb3f749f172 Mon Sep 17 00:00:00 2001 From: Somanath Hugar Date: Mon, 24 Jul 2023 13:31:03 +0530 Subject: [PATCH 07/12] Create GovStack specific chart rebase --- .DS_Store | Bin 0 -> 6148 bytes .circleci/config.yml | 21 +++ helm/govstack-chart/Chart.yaml | 12 ++ helm/govstack-chart/README.md | 19 +++ .../config/application-bb.properties | 9 ++ .../config/application-fin12.properties | 2 + .../config/application-tenants.properties | 6 + helm/govstack-chart/templates/config.yaml | 6 + helm/govstack-chart/values.yaml | 143 ++++++++++++++++++ 9 files changed, 218 insertions(+) create mode 100644 .DS_Store create mode 100644 helm/govstack-chart/Chart.yaml create mode 100644 helm/govstack-chart/README.md create mode 100644 helm/govstack-chart/config/application-bb.properties create mode 100644 helm/govstack-chart/config/application-fin12.properties create mode 100644 helm/govstack-chart/config/application-tenants.properties create mode 100644 helm/govstack-chart/templates/config.yaml create mode 100644 helm/govstack-chart/values.yaml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..290bebb3625f7c2411543ca7cfb53527faaacedc GIT binary patch literal 6148 zcmeHKyH3ME5ZnV7mS|E^-VacuqCFz>1^EFKf=FS@p-AtJmhYkGw-B=rqD00>G?9X4 zrM>a(?)dB}yj~GWi`{xIG82&+t|+g%j7{_EBfE%51x$L6_IbX1?7Qu#ayp>gN;dK& zt#m)|_qncbnpNAcP+xz(y}aMte%u{$yMFy^e!KbevrRuWGgN>IPys4H1~zGll}jp)T&VyRI9A}&w=?bk_wb4N|Cq!b6`%tDN`X{0 z%VvRBirzYUIqkI>{s8|r)LJ>>>>>> 0887533 (Create GovStack specific chart) - run: helm dep up helm/govstack-chart - run: helm package helm/govstack-chart - run: helm repo index . @@ -63,6 +67,20 @@ jobs: workflows: +<<<<<<< HEAD +======= + # test_everything: + # jobs: + # - test-harness/create-config: + # post-steps: # Persist to workspace has to be defined in main workflow + # - persist_to_workspace: + # root: workspace + # paths: + # - generated.yml + # - test-harness/execute-tests: + # requires: + # - test-harness/create-config +>>>>>>> 0887533 (Create GovStack specific chart) deploy: jobs: - build: @@ -79,6 +97,7 @@ workflows: - Helm - slack - Secrets +<<<<<<< HEAD # test_everything: # jobs: # - test-harness/create-config: @@ -104,3 +123,5 @@ workflows: # - test-harness/execute-tests: # requires: # - test-harness/create-config +======= +>>>>>>> 0887533 (Create GovStack specific chart) diff --git a/helm/govstack-chart/Chart.yaml b/helm/govstack-chart/Chart.yaml new file mode 100644 index 0000000..c91f619 --- /dev/null +++ b/helm/govstack-chart/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: ph-ee-govstack +description: PaymentHub GovStack Edition + +type: application +version: 1.0.0 +appVersion: 1.0.0 + +dependencies: +- name: ph-ee-g2psandbox + repository: https://fynarfin.io/images/ph-ee-g2psandbox-0.0.0 + version: 0.0.0 diff --git a/helm/govstack-chart/README.md b/helm/govstack-chart/README.md new file mode 100644 index 0000000..30193dd --- /dev/null +++ b/helm/govstack-chart/README.md @@ -0,0 +1,19 @@ +Helm Upgrade command ----> +helm upgrade -f helm/govstack-chart/values.yaml g2p-sandbox helm/govstack-chart --install --create-namespace --namespace paymenthub + +Known Issue +Migration script race condition Operation app startup issue work around +1. port forward ops-mysql -3307 +2. connect the mysql with root passwrod +3. delete tenants +4. Run the SQL scripts which didn’t run successfully + +CREATE DATABASE `tenants`; +GRANT ALL PRIVILEGES ON `tenants`.* TO 'mifos'; +CREATE DATABASE `rhino`; +CREATE DATABASE `gorilla`; +GRANT ALL PRIVILEGES ON `rhino`.* TO 'mifos'; +GRANT ALL PRIVILEGES ON `gorilla`.* TO 'mifos'; +GRANT ALL ON *.* TO 'root'@'%'; + +5. restart ops-app pod \ No newline at end of file diff --git a/helm/govstack-chart/config/application-bb.properties b/helm/govstack-chart/config/application-bb.properties new file mode 100644 index 0000000..247d502 --- /dev/null +++ b/helm/govstack-chart/config/application-bb.properties @@ -0,0 +1,9 @@ +store.local.interop.host=https://rhino.mifos.g2pconnect.io +store.local.customer.host=https://rhino.mifos.g2pconnect.io +zeebe.broker.contactpoint=g2p-sandbox-zeebe-gateway:26500 + +security.oauth2.resource.jwt.key-uri=http://ops-bk.mifos.g2pconnect.io/oauth/token_key +rest.authorization.enabled=false +rest.authorization.host=http://ops-bk.mifos.g2pconnect.io + +dfspids=rhino, gorilla diff --git a/helm/govstack-chart/config/application-fin12.properties b/helm/govstack-chart/config/application-fin12.properties new file mode 100644 index 0000000..bdd5117 --- /dev/null +++ b/helm/govstack-chart/config/application-fin12.properties @@ -0,0 +1,2 @@ +ams.localenabled=true +zeebe.broker.contactpoint=g2p-sandbox-zeebe-gateway:26500 \ No newline at end of file diff --git a/helm/govstack-chart/config/application-tenants.properties b/helm/govstack-chart/config/application-tenants.properties new file mode 100644 index 0000000..dc9bc2e --- /dev/null +++ b/helm/govstack-chart/config/application-tenants.properties @@ -0,0 +1,6 @@ +bpmns.tenants[0].id= "lion" +bpmns.tenants[0].flows.payment-transfer= "mock_payment_transfer-{dfspid}" +bpmns.tenants[1].id= "rhino" +bpmns.tenants[1].flows.payment-transfer= "MockPayerFundTransfer-{dfspid}" +bpmns.tenants[2].id= "gorilla" +bpmns.tenants[2].flows.payment-transfer= "PayerFundTransfer-{dfspid}" \ No newline at end of file diff --git a/helm/govstack-chart/templates/config.yaml b/helm/govstack-chart/templates/config.yaml new file mode 100644 index 0000000..98f65ae --- /dev/null +++ b/helm/govstack-chart/templates/config.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: ph-ee-config +data: +{{ (.Files.Glob "config/**.properties").AsConfig | nindent 2 }} diff --git a/helm/govstack-chart/values.yaml b/helm/govstack-chart/values.yaml new file mode 100644 index 0000000..fc6919f --- /dev/null +++ b/helm/govstack-chart/values.yaml @@ -0,0 +1,143 @@ +ph-ee-g2psandbox: + ph-ee-engine: + + zeebe-cluster-helm: + enabled: true + + elasticsearch: + enabled: false + kibana: + enabled: true + + zeebe-operate-helm: + ingress: + enabled: false + + kibana: + ingress: + enabled: false + + operations: + + ph_ee_connector_ams_mifos: + enabled: true + imageTag: v1.3.0 + ingress: + enabled: false + + ph_ee_connector_mojaloop: + enabled: true + imageTag: v1.2.0 + ingress: + enabled: false + + # kafka: + + channel: + enabled: true + imageTag: v1.6.0 + operations: + url: "http://ops-bk.sandbox.fynarfin.io/api/v1" + server: + ssl: + keyPassword: "password" + keyStorePassword: "password" + ingress: + enabled: false + + operations_app: + enabled: true + imageTag: v1.5.0 + tenants: "rhino,gorilla" + ingress: + enabled: false + + operations_web: + enabled: true + imageTag: v1.3.2 + ingress: + enabled: false + + ph_ee_connector_gsma: + enabled: true + imageTag: v1.0.2 + ingress: + enabled: false + + ph_ee_connector_slcb: + enabled: false + + mpesa: + enabled: false + + roster_connector: + enabled: false + + paygops_connector: + enabled: false + + notifications: + enabled: true + imageTag: v1.2.0 + NOTIFICATION_FAILURE_ENABLED: "false" + ingress: + enabled: false + + connector_bulk: + enabled: true + imageTag: v1.6.0 + tenants: "rhino,gorilla" + aws: + region: "us-east-2" + access_key: "AKIAX32JM37TZOJ5AKFB" + secret_key: "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" + operations_app: + contactpoint: "https://ops-bk.sandbox.fynarfin.io/" + endpoints: + batch_transaction: "/api/v1/batch/transactions" + ingress: + enabled: false + + zeebe_ops: + enabled: true + imageTag: v1.1.0 + tenants: "rhino,gorilla" + ingress: + enabled: false + + messagegateway: + enabled: true + imageTag: v1.0.0 + secret: + value: + api_key: "eKiC1_JWdKy7eaTGQFHxXXjXjacr60W9Zntl" + project_id: "PJ5ff552ce01d2978c" + ingress: + enabled: false + + importer_es: + enabled: true + imageTag: v1.5.0 + + importer_rdbms: + enabled: true + imageTag: v1.4.0 + + wildcardhostname: "" + tls: "" + + keycloak: + enabled: false + ingress: + enabled: false + + kong: + enabled: false + ingress: + enabled: false + + redis: + enabled: true + replica: + replicaCount: 0 + \ No newline at end of file From 070c70d28e082661788b1313c917c0effe42593a Mon Sep 17 00:00:00 2001 From: Somanath Hugar Date: Mon, 24 Jul 2023 15:29:55 +0530 Subject: [PATCH 08/12] test deployment rebase: --- .circleci/config.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d9b039c..9169b25 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,11 +20,7 @@ jobs: - helm/install-helm-client: version: "v3.8.2" # - run: "sed -i '12s/.*/version: 0.0.0/' helm/g2p-sandbox-fynarfin-SIT/Chart.yaml" -<<<<<<< HEAD - # - run: cat helm/govstack-chart/Chart.yaml -======= - run: cat helm/govstack-chart/Chart.yaml ->>>>>>> 0887533 (Create GovStack specific chart) - run: helm dep up helm/govstack-chart - run: helm package helm/govstack-chart - run: helm repo index . @@ -67,8 +63,7 @@ jobs: workflows: -<<<<<<< HEAD -======= + # test_everything: # jobs: # - test-harness/create-config: @@ -80,7 +75,6 @@ workflows: # - test-harness/execute-tests: # requires: # - test-harness/create-config ->>>>>>> 0887533 (Create GovStack specific chart) deploy: jobs: - build: @@ -97,7 +91,6 @@ workflows: - Helm - slack - Secrets -<<<<<<< HEAD # test_everything: # jobs: # - test-harness/create-config: @@ -110,7 +103,6 @@ workflows: # requires: # - test-harness/create-config - # workflows: # test_everything: # jobs: @@ -123,5 +115,3 @@ workflows: # - test-harness/execute-tests: # requires: # - test-harness/create-config -======= ->>>>>>> 0887533 (Create GovStack specific chart) From 44b5782242311720362a4e33d0b772f9c85a227e Mon Sep 17 00:00:00 2001 From: somanath21 <104554892+somanath21@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:13:09 +0530 Subject: [PATCH 09/12] Updated config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9169b25..ceb3b49 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,8 +26,8 @@ jobs: - run: helm repo index . - run: echo "$CERT_FILE" | base64 --decode > b64encoded.pem - run: chmod 400 b64encoded.pem - - run: scp -o StrictHostKeyChecking=No -i b64encoded.pem index.yaml govstack-chart-1.0.0.tgz ec2-user@13.233.68.128:~/ - - run: ssh -i b64encoded.pem -o StrictHostKeyChecking=No ec2-user@13.233.68.128 sudo mv -t /apps/apache-tomcat-7.0.82/webapps/ROOT/images/govstack-chart index.yaml govstack-chart-1.0.0.tgz + # - run: scp -o StrictHostKeyChecking=No -i b64encoded.pem index.yaml govstack-chart-1.0.0.tgz ec2-user@13.233.68.128:~/ + # - run: ssh -i b64encoded.pem -o StrictHostKeyChecking=No ec2-user@13.233.68.128 sudo mv -t /apps/apache-tomcat-7.0.82/webapps/ROOT/images/govstack-chart index.yaml govstack-chart-1.0.0.tgz upgrade-g2psandbox-helm-chart: docker: - image: cimg/python:3.10 From 6a3300433b349c1bc6d97a22c8d05c9ece811537 Mon Sep 17 00:00:00 2001 From: somanath21 <104554892+somanath21@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:14:34 +0530 Subject: [PATCH 10/12] Updated config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ceb3b49..8c4581f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,8 +24,8 @@ jobs: - run: helm dep up helm/govstack-chart - run: helm package helm/govstack-chart - run: helm repo index . - - run: echo "$CERT_FILE" | base64 --decode > b64encoded.pem - - run: chmod 400 b64encoded.pem + # - run: echo "$CERT_FILE" | base64 --decode > b64encoded.pem + # - run: chmod 400 b64encoded.pem # - run: scp -o StrictHostKeyChecking=No -i b64encoded.pem index.yaml govstack-chart-1.0.0.tgz ec2-user@13.233.68.128:~/ # - run: ssh -i b64encoded.pem -o StrictHostKeyChecking=No ec2-user@13.233.68.128 sudo mv -t /apps/apache-tomcat-7.0.82/webapps/ROOT/images/govstack-chart index.yaml govstack-chart-1.0.0.tgz upgrade-g2psandbox-helm-chart: From c25391d29afb5209e07ab2a644f97a721c397b69 Mon Sep 17 00:00:00 2001 From: somanath21 <104554892+somanath21@users.noreply.github.com> Date: Mon, 24 Jul 2023 19:37:42 +0530 Subject: [PATCH 11/12] Updated config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c4581f..988a6b9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -79,7 +79,7 @@ workflows: jobs: - build: context: - - AWS + - aws - Helm - slack - upgrade-g2psandbox-helm-chart: @@ -87,7 +87,7 @@ workflows: requires: - build context: - - AWS + - aws - Helm - slack - Secrets From fb43d341cd07bc8b67031f3c31da69f67b28281c Mon Sep 17 00:00:00 2001 From: somanath21 <104554892+somanath21@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:12:43 +0530 Subject: [PATCH 12/12] Update Chart.yaml --- helm/govstack-chart/Chart.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helm/govstack-chart/Chart.yaml b/helm/govstack-chart/Chart.yaml index c91f619..2e5dc22 100644 --- a/helm/govstack-chart/Chart.yaml +++ b/helm/govstack-chart/Chart.yaml @@ -3,10 +3,10 @@ name: ph-ee-govstack description: PaymentHub GovStack Edition type: application -version: 1.0.0 -appVersion: 1.0.0 +version: 1.1.0 +appVersion: 1.1.0 dependencies: - name: ph-ee-g2psandbox - repository: https://fynarfin.io/images/ph-ee-g2psandbox-0.0.0 - version: 0.0.0 + repository: https://fynarfin.io/images/ph-ee-g2psandbox-1.2.0 + version: 1.2.0