8. Testing - nhsconnect/nrls-reference-implementation GitHub Wiki
In this section:
8.1 Front end
There is a basic set of Javascript unit tests set up. These can be run from the \\[repo-root]\Demonstrator\Demonstrator.WebApp folder using NPM.
8.2 Back end
Along with C# unit tests found in the Test folder of the Solution there are a number of postman scripts created to test the APIs end to end. Details of the postman tests are below.
8.3 NRL Stub
Along with C# unit tests found in the Test folder of the Solution there are a number of postman scripts created to test the APIs end to end. Details of the postman tests are below.
8.4 Supporting Stubs
There are a number of postman scripts created to allow you to test the functionality of the SSP, ODS, and PDS. Details of the postman tests are below.
8.5 Postman Scripts
A number of test scripts have been created to run in postman. These help to confirm that the NRL Reference Implementation and the Demonstrator are running as expected.
The scripts are designed to run as a collection within the postman runner but can also be ran individually, substituting variables (e.g. {{I_AM_A_POSTMAN_VARIABLE}}) with actual values where required.
To start with you can download postman as a desktop app from https://www.getpostman.com/.
8.5.1 Tests
Within each postman request there are a number of tests defined which check the response back from the services to ensure the service handle the request as expected.
Pre-request Scripts
Within some of the postman requests there will be some pre-request scripts defined which most create default values and set up validation functions
Data sets
Some Tests and pre-request scripts are set up to run a number of sub-requests and sub-tests. This is done to allow for when a larger number of similar requests and tests need to be run, JWT validation for example.
8.5.2 Environments
There are a number of environments set up to allow you to run these scripts in the following places:
- Local
- Local via Docker
- Staging Developer Network
- Live Developer Network
These will need to be installed into your postman applications.
See the download section for details on the supporting postman files.
8.5.3 Globals
There are a number of global variables set up, some are static and some are generated as part of the test runs. These help to prevent duplication.
These will need to be installed into your postman applications.
See the download section for details on the supporting postman files.
8.5.4 Request Collections
Demo App collection scripts
There are two folders within this section:
- Interactions - A set of scripts to be run in sequence, including all of the API endpoints that support the demo apps and also the Provider Record Retrieval endpoint
- Redirects - These test that the redirects to the corporate website are working correctly
See the download section for details on the supporting postman files.
Reference Implementation collection scripts
There are two folders within this section:
- Positive Tests - A set of scripts to be run in sequence that test all of the different combinations of interactions
- Negative Tests - A set of scripts to be run in sequence that test all of the logic that checks for errors is working
See the download section for details on the supporting postman files.
Supporting API collection scripts
There are three folders within this section:
- PDS - A set of scripts to test the supporting PDS stub API interactions are working
- ODS - A set of scripts to test the supporting ODS stub API interactions are working
- Record Retrieval (SSP) - A set of scripts to test the supporting SSP stub API interactions are working. There is an additional test that allows you to fetch a record direct from the Provider endpoint.
See the download section for details on the supporting postman files.
Record Retrieval via the SSP Stub
In order to use this stub you will need to provide the following in your request:
- The NRLS-API
BASE_URLfor your working environment e.g. Local Docker - The Demo Apps base url for your working environment e.g. Local Docker
- A valid Provider ODS Code (see the default SDS data)
- A valid 'document type' e.g. mhcp (see the 'Demonstrator/Demonstrator.WebApp/Controllers/CCBinaryController.cs' for more details)
- A valid record ID - this is a MongoDB Object ID but can be any value that matches the following regex
/^[A-Fa-f0-9-]{1,1024}$/ - A valid
Authorizationheader - this is a JWT that conforms to the SSP requirements (for more detail, see the NRL specification) - A valid Consumer ASID (see the default SDS data)
- A valid Provider ASID that is associated to the above mentioned ODS code (see the default SDS data)
- The correct Record Retrieval Interaction ID (for more detail, see the NRL specification)
This will return a dynamically generated test PDF that will include the record id used above. The PDF will be formatted as per the format defined for the 'document type' used e.g. mhcp.
Example request to the stub SSP
GET https://data.developer.nhs.uk/nrls-ri/SSP/http%3A%2F%2Fnrlsdemoapp:5000%2Fprovider%2FMHT01%2Ffhir%2FSTU3%2Fcareconnect%2Fbinary%2Fmhcp%2F5d5e7c6b29c311aaa8c51b95 HTTP/1.1
Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJpc3MiOiJodHRwczovL2RlbW9uc3RyYXRvci5jb20iLCJzdWIiOiJodHRwczovL2ZoaXIubmhzLnVrL0lkL3Nkcy1yb2xlLXByb2ZpbGUtaWR8ZmFrZVByb2ZpbGVJZCIsImF1ZCI6Imh0dHBzOi8vbnJscy5jb20vZmhpci9kb2N1bWVudHJlZmVyZW5jZSIsImV4cCI6MTU2NTk1MjIxMiwiaWF0IjoxNTY1OTUxOTEyLCJyZWFzb25fZm9yX3JlcXVlc3QiOiJkaXJlY3RjYXJlIiwic2NvcGUiOiJwYXRpZW50LyoucmVhZCIsInJlcXVlc3Rpbmdfc3lzdGVtIjoiaHR0cHM6Ly9maGlyLm5ocy51ay9JZC9hY2NyZWRpdGVkLXN5c3RlbXwyMDAwMDAwMDAxMTciLCJyZXF1ZXN0aW5nX29yZ2FuaXphdGlvbiI6Imh0dHBzOi8vZmhpci5uaHMudWsvSWQvb2RzLW9yZ2FuaXphdGlvbi1jb2RlfEFNUzAxIiwicmVxdWVzdGluZ191c2VyIjoiaHR0cHM6Ly9maGlyLm5ocy51ay9JZC9zZHMtcm9sZS1wcm9maWxlLWlkfGZha2VQcm9maWxlSWQifQ.
Ssp-TraceID: 3cf432b653fd4ca3883e2c4225bd711c
Ssp-From: 200000000117
Ssp-To: 200000000118
Ssp-InteractionID: urn:nhs:names:services:nrl:DocumentReference.content.read
8.5.5 Automation
The Postman scripts detailed above can be run the Postman application. They can also be integrated into existing build/test/deploy pipelines using Postman's sister command line interface application, Newman.
Newman example
newman run nrl.ref-imp.postman_collection.json --global-var "BASE_URL=http://localhost:8101" --global-var "TC100_Patient_Number=2686033207" --global-var "TC200_Patient_Number=2686033207" --global-var "TC300_Patient_Number=5456049767" --global-var "TC600_Patient_Number=3656987882" --verbose
8.5.6 Downloads
| Name | Last updated | Download |
|---|---|---|
| Environments | 15/08/2019 12:59 | NRL-Postman-Environments.zip |
| Globals | 15/08/2019 12:59 | NRL-Postman-Globals.zip |
| Collections | 15/08/2019 12:59 | NRL-Postman-Collections.zip |