Test suite that runs a set of end to end tests against the epr-backend service.
Also provides a data generator facility for local development purposes.
Please install Node.js >= v20 and npm >= v9. You will find it
easier to use the Node Version Manager nvm
To use the correct version of Node.js for this application, via nvm:
nvm useInstall application dependencies:
npm installBring up the relevant Docker containers:
docker compose up -dRun the tests:
npm run testIf you run the epr-backend service as a standalone service (not via Docker Compose) and you wish to test without the logs or audit logs, run the following command:
WITHOUT_LOGS=true npm run testThe testing of logs and audit logs also assumes that you have run the Docker compose command above as it relies on the Dockerised epr-backend service.
For example, if you want to run accreditation tests, you can invoke:
npm run test:tagged @accreditationTo run with report, you can invoke:
npm run test:tagged @accreditation && npm run reportBy default, Proxy is disabled. To enable it, you first need a Proxy server running. You can use MITM Proxy via this Docker container command:
docker run --rm -it --name mitm-proxy --network cdp-tenant -p 7777:7777 -p 127.0.0.1:8081:8081 mitmproxy/mitmproxy mitmweb --web-host 0.0.0.0 --listen-port 7777 --set block_global=false
You can now monitor the proxy traffic via http://localhost:8081/ (Use the token on the console output from the Docker command above)
If you wish to use a port number other than 8081 for MITM Proxy (Web), you can pass in the following option at the end of the docker command (e.g. port 8082):
--web-port 8082
Now, you can run the tests with the following command:
WITH_PROXY=true npm run test
Alternatively, you can also use a non Docker based Proxy client such as Postman. For more information, please refer to the Postman Docs.
To run a non Docker based Proxy client, you need to use the following command:
WITH_EXTERNAL_PROXY=true npm run test
The default Proxy port is 7777. You can change it by modifying the value in test/config/config.js under the ProxyAgent configuration.
Tests are run from the CDP-Portal under the Test Suites section. Before any changes can be run, a new docker image must be built, this will happen automatically when a pull request is merged into the main branch.
You can check the progress of the build under the actions section of this repository. Builds typically take around 1-2 minutes.
The results of the test run are made available in the portal.
You can also run the tests against environments locally. This can be achieved by supplying both the ENVIRONMENT and X_API_KEY variables.
First, you will need to generate your X_API_KEY to use. Follow the CDP README for more information.
Ensure ZAP docker container is running and the proxy of your choice is running.
docker compose up -d zap
Then, to run the tests against the dev environment (Where <api_key> = the generated key from the CDP README above):
X_API_KEY=<api_key> ENVIRONMENT=dev npm run test
If you want to run the tests with proxy against the dev environment, you can do so by supplying the following:
WITH_PROXY=true X_API_KEY=<api_key> ENVIRONMENT=dev npm run test
Note that the database checks and logging tests will not run against the dev environment as they rely on the local Docker services.
This only applies to local builds. You can generate 50 organisation details, registrations and accreditations (all linked together) in one go with this command:
npm run generatedata
This will create mock datasets for the 3 collections in the database. Only to be used for local development purposes.
| Test type | Local / PR Checks | Dev environment | Test environment |
|---|---|---|---|
| Endpoint tests | ✓ | ✓ | ✓ |
| Mongo / database checks | ✓ | ☒ | ☒ |
| Logging tests | ✓ | ☒ | ☒ |
| ZAP tests | ✓ | ✓ | ✓ |
| Email / Notify tests | ☒ | ☒ | ✓ |
| Slack non-prod tests | ☒ | ✓ | ✓ |
For more information on the tests, please refer to the Confluence page.
THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3
The following attribution statement MUST be cited in your products and applications when using this information.
Contains public sector information licensed under the Open Government licence v3
The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.