The purpose of this document is to describe how the application is being tested to assure quality and coverage.
The application testing strategy depends on two main types of testing to achieve the objective:
- Unit testing
- End to end (e2e) testing
This type of testing covers the application business logic (domain models and services) and generates a test result and code coverage report that give an insight on how the application codebase is covered by the defined test cases.
The application is using the Jest Testing Framework
to define the unit-test scenarios in addition to generating a visual view and developer friendly for testing results and code coverage.
To run the application unit tests
# In the terminal window
cd data-reconciliation-app # Navigate to reconciliation sample folder
make unit-test # Build and run unit-test using jest framework
NOTE: To enable the CCF functionality on testing environment, the application is using built-in feature of CCF, the Polyfill implementation which overrides the CCF modules' implementation to support testing and local environments
End to end testing (E2E testing) is a testing method that involves testing an application’s workflow from beginning to end. This method aims to replicate real user scenarios to validate the system for integration and data integrity.
The application uses bash scripts to start up the network environment a typescript application to perform end-to-end testing for the Data Reconciliation endpoints.
There are 3 different types of network this sample can be tested against:
- Sandbox (virtual)
- Docker (virtual - enclave)
- Azure Managed CCF (enclave)
The test script ./test.sh contains the call to the TypeScript application located in e2e-test folder. This code runs the test scenarios and result validation for each endpoint. Additionally, there are assertions at the end of the test to compare report results with expected values. All requests are made simulating MTLS members' signatures via certificates and private keys.
Note: The test script of each sample is called by wrapper scripts that exist in the root scripts folder. These wrapper scripts are used for all samples, and they are responsible for starting the particular network with the correct constitution and setting up governance (users, members, and applications). The wrapper scripts will also close the network after the tests have finished (excluding mCCF).
To run the application e2e tests
# In the terminal window
cd data-reconciliation-app # Navigate to reconciliation sample folder
make test # Run end-to-end(e2e) tests in a sandbox (virtual) environment
Network | Command | Script | Supported environment |
---|---|---|---|
Sandbox | make test |
test_sandbox | virtual |
Docker | make test-docker-virtual |
test_docker | virtual |
Docker | make test-docker-enclave |
test_docker | enclave (TEE) |
Managed CCF | make test-mccf |
test_mccf | enclave (TEE) |
To Run the application's e2e-tests using docker on enclave environment
- First, create a Virtual Machine with TEE hardware. Please follow here
- Clone the samples repository on the created VM
- Run the
cd data-reconciliation-app && make test-docker-enclave
To Run the application's e2e-tests on a Managed CCF
- First, create a Managed CCF instance on your Azure subscription. Please follow here
- Run the e2e-test, please follow here
The application currently supports two JWT token issuers (identity providers):
-
Test Idp: custom implementation to simulate a token issuer to test your application locally.
- Generate test tokens:
/.workspace/proposals/set_jwt_issuer_test_sandbox.json
contains pre-generated tokens you can use to test the application endpoints using JWT authentication. - Run
make start-host
and request/app/swagger
endpoint thenauthorize
- Generate test tokens:
-
Microsoft Azure Active Directory Identity Provider: integration sample with MS-AAD Idp
-
Generate test tokens: before you can complete this step, two applications must be registered at the Azure AD tenant, follow here
- To create the required registered applications run
make deploy-ms-idp
. - Update
src/services/authentication-service.ts
with environment values inaad.env
file created by the previous step:- Replace
MS_APP_ID_URI
byApiIdentifierUri
- Replace
MS_APP_ID
: byClientApplicationId
- Replace
- Run
make generate-access-token
to generate a new token. - Run
make start-host-jwt-host
and request/app/swagger
endpoint then click onauthorize
.
- To create the required registered applications run
-