You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lambdas/tests/e2e/README.md
+61-32Lines changed: 61 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# 🧪 End-to-End Testing Setup
2
2
3
-
These tests focus on the features of the NDR. This will serve as a blended suite of integration and end-to-end (E2E) tests, with the aim to validate API functionality and snapshot comparisons.
3
+
These tests serve as a suite of end-to-end (E2E) teststo validate FHIR API functionality and snapshot comparisons.
4
4
5
5
There are 2 suites which separately test
6
6
@@ -11,15 +11,9 @@ as well as APIM E2E tests `lambdas/tests/e2e/apim/`.
11
11
12
12
## 🔐 AWS Authentication
13
13
14
-
You must be authenticated with AWS to run the api tests. Use the following commands with a configured profile set up in ~/.aws/config to authenticate:
14
+
You must be authenticated with AWS to run the api tests.
15
15
16
-
```bash
17
-
aws sso login --profile <your-aws-profile>
18
-
19
-
export AWS_PROFILE=<your-aws-profile>
20
-
```
21
-
22
-
An example profile:
16
+
Before authenticating, ensure you have a valid AWS profile configured:
23
17
24
18
```bash
25
19
[sso-session PRM]
@@ -34,63 +28,98 @@ region=eu-west-2
34
28
output=json
35
29
```
36
30
37
-
Make sure your AWS profile has access to the required resources.
31
+
Your profile name (e.g. NDR-Dev-RW) must match what you use in the commands below. Make sure your AWS profile has access to the required resources.
38
32
39
-
##Using the dev container
33
+
### Inside the dev container (preferred method): aws-vault
40
34
41
-
All of the below make commands can be used in the dev container. To run the below commands you need to append `CONTAINER=true`.
35
+
Use `aws-vault` to assume the profile with a secure, temporary-session subshell.
36
+
37
+
```bash
38
+
List configured profiles::
39
+
'aws-vault list'
40
+
41
+
Start an authenticated session::
42
+
'aws-vault exec <your-aws-profile>'
43
+
44
+
If the session expires, start a new one:
45
+
'exit'
46
+
'aws-vault exec <your-aws-profile>'
47
+
```
48
+
49
+
### Alternative outside the dev container: AWS SSO CLI
50
+
51
+
Authenticate your profile and set it as the active one:
52
+
53
+
```bash
54
+
aws sso login --profile <your-aws-profile>
55
+
56
+
export AWS_PROFILE=<your-aws-profile>
57
+
```
42
58
43
59
## 🔧 Available Make Commands
44
60
45
-
-`make test-fhir-api-e2e WORKSPACE=<workspace>` — Runs the FHIR API E2E tests with mTLS against a given workspace
61
+
All of the below make commands can be run either inside or outside the dev container. It is preferable to work inside the dev container as a developer tool to ensure code formatting and pre-commits are consistent throughout the team, keeping a high standard.
62
+
63
+
* To run inside the dev container append `CONTAINER=true` to each command
64
+
65
+
* If you need to work outside the dev container you **must** run `make env` first to set up your venv and any required dependencies
66
+
67
+
```bash
68
+
make test-fhir-api-e2e WORKSPACE=<workspace> CONTIANER=true
46
69
47
-
-`make test-api-e2e` — Runs the E2E tests without mTLS
70
+
make test-api-e2e
48
71
49
-
-`make test-apim-e2e` - Runs the APIM E2E tests
72
+
make test-apim-e2e
73
+
```
50
74
51
75
### Snapshots
52
76
53
77
Snapshots reduce the amount of individual assertions by comparing pre and post an object e.g. a JSON returned from an API.
54
78
55
79
Snapshot testing is used in the non mTLS test suite only. To update snapshots you can run the following make command:
This runs pytest with the additional argument `--snapshot-update` which will replace the existing snapshots.
85
+
This runs pytest with the additional argument `--snapshot-update` which will update and replace the existing snapshots.
60
86
61
87
### Certificate inspection
62
88
63
-
You can download the mTLS certificates used in the requests if you need to inspect them by running
89
+
You can download the mTLS certificates used in the FHIR api requests if you need to inspect them
64
90
65
-
-`make download-api-certs WORKSPACE=<workspace>` — Downloads mTLS client cert and client key used in the request
91
+
```bash
92
+
make download-api-certs WORKSPACE=<workspace>
93
+
```
66
94
67
95
❗ Always delete these after use and never commit them.
68
96
69
97
## 🌍 Required Environment Variables
70
98
71
-
In order to execute the E2E tests without mTLS (i.e. `make test-api-e2e`) you will need to ensure the following environment variables are set. You can export them in your shell configuration file (`~/.zshrc` or `~/.bashrc`) or **temporarily** add them to the `conftest.py`:
99
+
In order to execute the Lloyd George API E2E tests (i.e. `make test-api-e2e`) you will need to ensure the following environment variables are set.
100
+
101
+
You can export them inside the subshell started by aws-vault exec - these will be scoped to your session and won’t leak to your host environment. Or equivalently, for working outside the dev container, export them in your shell configuration file (`~/.zshrc` or `~/.bashrc`). Or you can **temporarily** add them to the `conftest.py`, but do not commit these:
-`api-name`: Specifies the name of the API being tested. In this case, it's the National Document Repository FHIR R4 API.
132
-
-`proxy-name`: Indicates the APIM proxy configuration to use during testing. This ensures the tests target the correct APIM instance and environment.
160
+
*`api-name`: Specifies the name of the API being tested. In this case, it's the National Document Repository FHIR R4 API.
161
+
*`proxy-name`: Indicates the APIM proxy configuration to use during testing. This ensures the tests target the correct APIM instance and environment.
133
162
134
163
### Important Notes
135
164
136
-
- Environment Configuration: Make sure your test environment is properly configured with access to APIM and any required secrets or credentials.
165
+
* Environment Configuration: Make sure your test environment is properly configured with access to APIM and any required secrets or credentials.
137
166
138
-
- You can test your proxygen set up via `proxygen instance list` and expect to see `national-document-repository_FHIR_R4` listed.
167
+
* You can test your proxygen set up via `proxygen instance list` and expect to see `national-document-repository_FHIR_R4` listed.
139
168
For more information on proxygen credentials see: <https://nhsd-confluence.digital.nhs.uk/pages/viewpage.action?spaceKey=APM&title=Proxygen+CLI+user+guide>
140
169
141
-
- Dependencies: These tests rely on other services being up and running (e.g. backend API, databases). Ensure all dependencies are available before running the tests.
170
+
* Dependencies: These tests rely on other services being up and running (e.g. backend API, databases). Ensure all dependencies are available before running the tests.
0 commit comments