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
NPA-5244: Composite token and end to end testing (#46)
# Pull Request
## 🧾 Ticket Link
https://nhsd-jira.digital.nhs.uk/browse/NPA-5244
---
## 📄 Description/Summary of Changes
<!-- Describe the changes made in this PR. Include the
purpose/scope/impact/context of the changes -->
- Added support for mock composite token
- Added happy and unhappy path end to end tests
- Enabled end to end tests for PR check workflow and CI/CD internal-qa
workflow
- Added documentation on manual steps required for enabling mock
composite token against ephemeral developments
- Added documentation for NHS developer hub
- Added documentation for alternative Proxygen installation method
- Updated vale acceptance list
- Updated uv version
---
## 🧪 Developer Testing Carried Out
<!-- Describe what tests (automated/unit/manual etc.) have been done for
the ticket. Include: -->
<!-- - Any tests added/updated -->
<!-- - Evidence that each acceptance criterion from the Jira ticket is
met -->
- [Successful CI/CD
run](https://github.com/NHSDigital/im1-pfs-auth/actions/runs/18531838040)
- [Successful PR check
run](https://github.com/NHSDigital/im1-pfs-auth/actions/runs/18534306013)
---
## ✅ Developer Checklist
<!-- To be completed by the developer -->
- [x] I have set the PR title to follow the format: `NPA-XXXX:
<short-description>`
- [x] My branch name follows the convention:
`<type>/NPA-XXXX/<short-description>`
- [x] My commit messages follow the template: `NPA-XXXX:
<short-description>`
- [x] I have updated the documentation accordingly
- [x] I have set assignees and added appropriate labels
---
## 👀 Reviewer Checklist
<!-- To be completed by the reviewer -->
- [ ] Changes meet the acceptance criteria of the Jira ticket
- [ ] Code is able to be merged (no conflicts and adheres to coding
standards)
- [ ] Sufficient test evidence is provided (manual and/or automated)
---
## Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others
privacy, we kindly ask you to NOT including [PII (Personal Identifiable
Information) / PID (Personal Identifiable
Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public)
or any other sensitive data in this PR (Pull Request) and the codebase
changes. We will remove any PR that do contain any sensitive
information. We really appreciate your cooperation in this matter.
- [x] I confirm that neither PII/PID nor sensitive data are included in
this PR and the codebase changes.
Copy file name to clipboardExpand all lines: Makefile
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -166,12 +166,17 @@ sandbox-unit-test:
166
166
# Runs End to End tests against a deployed environment
167
167
e2e-testsend-to-end-tests:
168
168
# Mandatory arguments:
169
+
# TEST_APP_KEYCLOAK_CLIENT_ID: Client Id issued to the mocked authorisation provider client. Obtained by the GET Keycloak credentials endpoint.
170
+
# TEST_APP_KEYCLOAK_SECRET: Secret assigned to the mocked authorisation provider client. Obtained by the GET Keycloak credentials endpoint.
171
+
# TEST_APP_API_KEY: API Key for test application in the developer portal (https://dos-internal.ptl.api.platform.nhs.uk/MyApplications)
172
+
# TEST_APP_PRIVATE_KEY: Private Key from key pair for test application in the developer portal (https://dos-internal.ptl.api.platform.nhs.uk/MyApplications)
make end-to-end-tests PROXYGEN_URL_PATH=im1-pfs-auth-pr-46 PROXY_NAME=im1-pfs-auth APIGEE_PROXY_NAME=im1-pfs-auth--internal-dev--im1-pfs-auth-pr-46
153
157
```
154
158
159
+
-`TEST_APP_KEYCLOAK_CLIENT_ID`: Client Id issued to the mocked authorisation provider client. Obtained by the GET Keycloak credentials endpoint.
160
+
-`TEST_APP_KEYCLOAK_CLIENT_SECRET`: Secret assigned to the mocked authorisation provider client. Obtained by the GET Keycloak credentials endpoint.
161
+
-`TEST_APP_API_KEY`: API Key for test application in the developer portal (https://dos-internal.ptl.api.platform.nhs.uk/MyApplications)
162
+
-`TEST_APP_PRIVATE_KEY`: Private Key from key pair for test application in the developer portal (https://dos-internal.ptl.api.platform.nhs.uk/MyApplications)
155
163
-`PROXYGEN_URL_PATH`: The URL path for the Proxygen API (e.g. im1-pfs-auth-pr-31)
156
164
-`PROXY_NAME`: The name of the proxy (e.g. im1-pfs-auth)
157
165
-`APIGEE_PROXY_NAME`: The name of the proxy to test (e.g., im1-pfs-auth--internal-dev--im1-pfs-auth-pr-31)
The NHS developer hub is the platform for managing applications which interact with NHS APIs. The primary use case for IM1 is for the management of API keys and credentials used in accessing the mock credentials service used in testing.
6
+
7
+
## Registration
8
+
9
+
There are two instances of NHS developer hub, [production](https://onboarding.prod.api.platform.nhs.uk) and [internal](https://dos-internal.ptl.api.platform.nhs.uk). Developers are encouraged to register for both platforms however, for the purposes of IM1 development, the internal instance is of higher priority.
10
+
11
+
## Proxy Dev Team
12
+
13
+
Once registered with the developer hub, developers must be added to the `Proxy Dev Team`. This must be done by the one of the `Proxy Dev Team` owners.
14
+
15
+
## IM1 PFS Auth Developer Test App
16
+
17
+
The `Proxy Dev Team` maintains the IM1 PFS Auth Developer Test App on the internal NHS developer hub. This application is responsible for the management of API keys and public signing key.
18
+
19
+
### API keys
20
+
21
+
From the application page, the API key can be accessed via `Security details` -> `Active API keys` -> `Edit`. Here keys can be rotated, created, and revoked. This key is used as `TEST_APP_API_KEY` in our environment variables.
22
+
23
+
### Public key
24
+
25
+
The public signing key can be changed via `Security details` -> `Public key URL` -> `Edit`, where generation of the public key is documented under [Section 3](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/user-restricted-restful-apis-nhs-login-separate-authentication-and-authorisation#step-3-generate-a-key-pair) of [User-restricted RESTful APIs - NHS login separate authentication](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/user-restricted-restful-apis-nhs-login-separate-authentication-and-authorisation).
Copy file name to clipboardExpand all lines: docs/user-guides/Proxygen_CLI.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,18 @@ The proxygen CLI is a dedicated command-line interface tool designed to streamli
28
28
pip install proxygen-cli
29
29
```
30
30
31
+
Alternative proxygen install
32
+
33
+
Proxygen currently, 2025-10-09, fails to build with Python 3.13, the version used in the IM1 repository, due to an inability to build `lxml==4.9.4`.
34
+
35
+
A workaround is to create a separate virtual environment at a lower Python version, then build proxygen for that environment, and transfer the binary to the IM1 repository virtual environment.
36
+
37
+
```shell
38
+
uv venv -p 3.12 # In a directory not containing the IM1 repository
39
+
uv pip install proxygen-cli
40
+
cp .venv/bin/proxygen <IM1 Repository>/.venv/bin/
41
+
```
42
+
31
43
2. Confirm the installation by checking the version:
-[Guide: Setup end to end tests](#guide-setup-end-to-end-tests)
4
+
-[Overview](#overview)
5
+
-[Associating ephemeral deployments with IM1 PFS Auth Developer Test App](#associating-ephemeral-deployments-with-im1-pfs-auth-developer-test-app)
6
+
-[Launching the ephemeral deployment](#launching-the-ephemeral-deployment)
7
+
-[Associating the deployment with the developer app](#associating-the-deployment-with-the-developer-app)
8
+
-[Testing](#testing)
9
+
10
+
## Overview
11
+
12
+
When performing end to end tests, a composite authentication token is retrieved from APIM's `mock-jwks` API. Composite tokens are currently, 2025-10-13, only enabled for the `internal-dev` environment. Therefore they cannot be ran against `internal-qa` in the CI/CD pipeline.
13
+
14
+
End to end tests can be ran from `internal-dev`, including ephemeral deployments created by PRs. For ephemeral deployments however, this requires associating the API Product with the IM1 PFS Auth Developer Test App, which has access to the correct instance of `mock-jwks`, as outlined below.
15
+
16
+
## Associating ephemeral deployments with IM1 PFS Auth Developer Test App
A deployment is automatically span up upon the [creation of a PR](./Workflows.md#core-workflows) with the naming pattern `im1-pfs-auth-pr-<pr_number>`. The deployment can be verified by searching for `im1` in the APIGEE > Develop > API Proxies UI, the API proxy will be shown as `im1-pfs-auth--internal-dev--im1-pfs-auth-pr-<pr_number>`.
23
+
24
+
### Associating the deployment with the developer app
25
+
26
+
To allow the ephemeral deployment to access the `mock-jwks` service, it must be associated with the IM1 PFS Auth Developer Test App. To do so you must first be added to the `Proxy Dev Team` on the [NHS Internal Developer Hub](./NHS_developer_hub.md).
27
+
28
+
Once added to the `Proxy Dev Team`, the deployment can be associated to the developer app using [Apigee](https://apigee.com/edge) under the `nhsd-nonprod` organisation. To associate the deployment with the developer app:
29
+
30
+
- Navigate to `Publish` -> `Apps`
31
+
- Search for `IM1`
32
+
- Note: searching can be a slow process due to indexing time)
33
+
- Select IM1 PFS Auth Developer Test App
34
+
- Select `Edit` in the top right of the page
35
+
- Under `Credentials` select `Add product`
36
+
- Search for `pr-<pr_number>`
37
+
- Add the `IM1 PFS Auth API - IM1 PFS Auth - P9 User Restriced Access (dev) (Internal Development)` product
38
+
- Note: This is **not** the `(Internal Development Sandbox)` product
39
+
- Finalise the change by selecting `Save` in the top right of the page
40
+
41
+
## Testing
42
+
43
+
The deployment should now be associated with the app and end to end tests can be run as part of the [pull request checks GitHub workflow](../../.github/workflows/pull-request-checks.yml).
44
+
45
+
For the general overview of running end to end tests locally, see the relevant section of the README. The additional required inputs are:
The private key counterpart to the key pair registered on the internal NHS Developer Hub platform is required. This can be requested from the development team.
0 commit comments