Skip to content

Commit

Permalink
Govstack demo tcs and Co-dev Tcs (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavm117 authored Jul 11, 2024
1 parent 18f9458 commit 28bd097
Show file tree
Hide file tree
Showing 14 changed files with 831 additions and 54 deletions.
49 changes: 48 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,45 @@ jobs:
path: build/test-results/test/TEST-org.mifos.integrationtest.TestRunner.xml
- store_artifacts:
path: build/test-results

test-chart-e2e:
docker:
- image: cimg/openjdk:17.0.0-node
steps:
- checkout
#- run: git clone https://github.com/fynarfin/ph-ee-integration-test
- run:
name: Ngrok setup
command: curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok
- run:
name: Test execution
no_output_timeout: 30m
command: |
ngrok config add-authtoken $AUTH_TOKEN
echo "web_addr: $LOCAL_PORT" >> /home/circleci/.config/ngrok/ngrok.yml
ngrok http 53013 > /dev/null &
echo -n "Extracting ngrok public url ."
NGROK_PUBLIC_URL=""
while [ -z "$NGROK_PUBLIC_URL" ]; do
# Run 'curl' against ngrok API and extract public (using 'sed' command)
export NGROK_PUBLIC_URL=$(curl --silent --max-time 10 --connect-timeout 5 \
--show-error http://127.0.0.1:$LOCAL_PORT/api/tunnels | \
sed -nE 's/.*public_url":"https:..([^"]*).*/\1/p')
sleep 1
echo -n "."
done
export CALLBACK_URL="https://$NGROK_PUBLIC_URL"
echo -n "Public url ."
echo $CALLBACK_URL
./gradlew test -Dcucumber.filter.tags="@e2e"
echo -n "Test execution is completed, kill ngrok"
pkill ngrok
- store_test_results:
path: build/test-results/test/TEST-org.fynarfin.integrationtest.TestRunner.xml
- store_artifacts:
path: build/test-results

test-chart-ams:
docker:
- image: cimg/openjdk:17.0.0
Expand Down Expand Up @@ -318,14 +357,22 @@ workflows:
- AWS
- Helm
- slack
- test-chart-ams:
- test-chart-e2e:
requires:
- deploying-bpmns
context:
- AWS
- Helm
- slack
- Ngrok
- test-chart-ams:
requires:
- test-chart-e2e
context:
- AWS
- Helm
- slack
- Ngrok
- test-chart-gov:
requires:
- test-chart-ams
Expand Down
1 change: 1 addition & 0 deletions .jit/jit-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ public void callBatchTransactionsEndpoint(int expectedStatus) {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant, scenarioScopeState.clientCorrelationId);
requestSpec.header(HEADER_PURPOSE, "Integartion test");
requestSpec.header(HEADER_FILENAME, scenarioScopeState.filename);
requestSpec.header(HEADER_REGISTERING_INSTITUTE_ID, "SocialWelfare");
requestSpec.queryParam(QUERY_PARAM_TYPE, "CSV");
requestSpec.header(QUERY_PARAM_TYPE, "CSV");
if (scenarioScopeState.signature != null && !scenarioScopeState.signature.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.mifos.connector.common.identityaccountmapper.dto.BeneficiaryDTO;
import org.mifos.integrationtest.common.Utils;
import org.mifos.integrationtest.config.GsmaConfig;
import org.mifos.integrationtest.util.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -431,10 +432,10 @@ public void iCallTheBalanceApiForPayerBalance() throws JsonProcessingException {
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}",
scenarioScopeState.debitParty.isEmpty() ? scenarioScopeState.payerIdentifier : scenarioScopeState.debitParty);
logger.info("Endpoint: " + finalEndpoint);
logger.info("Endpoint: {}", finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(interopAccountDTO.getAvailableBalance().intValue() <= scenarioScopeState.initialBalForPayer).isTrue();
scenarioScopeState.gsmaP2PAmtDebit = 0;
Expand All @@ -448,10 +449,10 @@ public void iCallTheBalanceApiForPayeeBalance() throws JsonProcessingException {
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}",
scenarioScopeState.creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : scenarioScopeState.creditParty);
logger.info("Endpoint: " + finalEndpoint);
logger.info("Endpoint: {}", finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayee).isTrue();

Expand All @@ -468,7 +469,7 @@ public void iCallTheBalanceApiForPayerBalanceAfterDebit() throws JsonProcessingE
logger.info("Endpoint: " + finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(interopAccountDTO.getAvailableBalance().intValue() == scenarioScopeState.initialBalForPayer
- scenarioScopeState.gsmaP2PAmtDebit).isTrue();
Expand All @@ -484,10 +485,10 @@ public void iCallTheBalanceApiForPayeeBalanceAfterCredit() throws JsonProcessing
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}",
scenarioScopeState.creditParty.isEmpty() ? scenarioScopeState.payeeIdentifier : scenarioScopeState.creditParty);
logger.info("Endpoint: " + finalEndpoint);
logger.info("Endpoint: {}", finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(interopAccountDTO.getAvailableBalance().intValue() == scenarioScopeState.initialBalForPayee
+ scenarioScopeState.gsmaP2PAmtDebit).isTrue();
Expand Down Expand Up @@ -690,7 +691,7 @@ public void iCallTheBalanceApiForPayeeBalance(String id) throws JsonProcessingEx
logger.info("Endpoint: " + finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)])
Expand All @@ -712,7 +713,71 @@ public void iCallTheBalanceApiForPayeeBalanceForCombinedTestsCases(String id) th
logger.info("Endpoint: " + finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)])
.isTrue();

}

@Then("I call the balance api for payer {string} balance for all combine test cases")
public void iCallTheBalanceApiForAllPayerBalanceForCombinedTestCases(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
String finalEndpoint = amsBalanceEndpoint;
// Check whether a new batch been initialized
initializeIfNotInitialized(id);
scenarioScopeState.payerIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payerIdentifier;
String accountId = (scenarioScopeState.debitParty == null) ? scenarioScopeState.payerIdentifier : scenarioScopeState.debitParty;
String identifierType = "MSISDN";
finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierType}", identifierType);
finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierId}", accountId);
logger.info("Endpoint: {} ", finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)])
.isTrue();
}

public void initializeIfNotInitialized(String id) {
if (shouldInitializeArray(id)) {
scenarioScopeState.payerIdentifierforBatch = new String[15];
}
}

private boolean shouldInitializeArray(String id) {
return scenarioScopeState.payerIdentifierforBatch == null || id.equals("1");
}

public void initializeIfNotInitializedForPayee(String id) {
if (shouldInitializeArrayForPayee(id)) {
scenarioScopeState.payeeIdentifierforBatch = new String[15];
}
}

private boolean shouldInitializeArrayForPayee(String id) {
return scenarioScopeState.payeeIdentifierforBatch == null || id.equals("1");
}

@Then("I call the balance api for payee {string} balance for all combine test cases")
public void iCallTheBalanceApiForPayeeBalanceForAllCombinedTestsCases(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
String finalEndpoint = amsBalanceEndpoint;

initializeIfNotInitializedForPayee(id);
scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)] = scenarioScopeState.payeeIdentifier;
String identifierId = (scenarioScopeState.creditParty == null) ? scenarioScopeState.payeeIdentifier
: scenarioScopeState.creditParty;
String identifierType = "MSISDN";
finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierType}", identifierType);
finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierId}", identifierId);
logger.info("Endpoint: {}", finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)])
Expand All @@ -724,16 +789,18 @@ public void iCallTheBalanceApiForPayeeBalanceForCombinedTestsCases(String id) th
public void iCallTheBalanceApiForPayeeBalanceAfterCredit(String id) throws JsonProcessingException {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
String finalEndpoint = amsBalanceEndpoint;
finalEndpoint = finalEndpoint.replace("{IdentifierType}", "MSISDN");
finalEndpoint = finalEndpoint.replace("{IdentifierId}", scenarioScopeState.payeeIdentifierforBatch[Integer.parseInt(id)]);
logger.info("Endpoint: " + finalEndpoint);
String identifierId = (scenarioScopeState.creditParty == null) ? scenarioScopeState.payeeIdentifier
: scenarioScopeState.creditParty;
String identifierType = "MSISDN";
finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierType}", identifierType);
finalEndpoint = Util.getFormattedEndpoint(finalEndpoint, "{IdentifierId}", identifierId);
logger.info("Endpoint: {}", finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(interopAccountDTO.getAvailableBalance().intValue() == scenarioScopeState.initialBalForPayeeForBatch[Integer.parseInt(id)]
+ scenarioScopeState.gsmaP2PAmtDebitForBatch[Integer.parseInt(id)]).isTrue();

}

@Then("I call the balance api for payer {string} balance")
Expand All @@ -749,7 +816,7 @@ public void iCallTheBalanceApiForPayerBalance(String id) throws JsonProcessingEx
logger.info("Endpoint: " + finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)])
Expand All @@ -771,7 +838,7 @@ public void iCallTheBalanceApiForPayerBalanceForCombinedTestCases(String id) thr
logger.info("Endpoint: " + finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
assertThat(
interopAccountDTO.getAvailableBalance().intValue() >= scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)])
Expand All @@ -788,7 +855,7 @@ public void iCallTheBalanceApiForPayerBalanceAfterDebit(String id) throws JsonPr
logger.info("Endpoint: " + finalEndpoint);
scenarioScopeState.response = RestAssured.given(requestSpec).baseUri(amsBaseUrl).body("").expect()
.spec(new ResponseSpecBuilder().expectStatusCode(200).build()).when().get(finalEndpoint).andReturn().asString();
logger.info("Balance Response: " + scenarioScopeState.response);
logger.info("Balance Response: {}", scenarioScopeState.response);
InteropAccountDTO interopAccountDTO = objectMapper.readValue(scenarioScopeState.response, InteropAccountDTO.class);
int originBal = scenarioScopeState.initialBalForPayerForBatch[Integer.parseInt(id)];
int debitAmt = scenarioScopeState.gsmaP2PAmtDebitForBatch[Integer.parseInt(id)];
Expand Down
Loading

0 comments on commit 28bd097

Please sign in to comment.