-
Notifications
You must be signed in to change notification settings - Fork 1
NPA-6546: fix end to end tests #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ehallam
wants to merge
19
commits into
main
Choose a base branch
from
task/NPA-6546/fix-end-to-end-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
66a282d
NPA-6546: fix end to end tests
ehallam 1b61b4c
NPA-6546: address copilot comments
ehallam bc6ad53
NPA-6546: testing with new proxygen credentials
ehallam 58a861c
NPA-6546: prepended inputs with NEW_
ehallam 55df056
empty commit to retrigger build
ehallam 0195c1e
NPA-6546: changed all GH secrets instances to match new naming
ehallam 7732b40
NPA-6546: Add glossasry of terms to documentation
tomknapp 078b638
NPA-6546: try to fix pipeline
ehallam 5b9f628
Merge branch 'task/NPA-6546/fix-end-to-end-tests' of github.com:NHSDi…
ehallam 9ecfefe
NPA-6546: fix markdown formatting
ehallam 896b139
NPA-6546: change NEW_ to PTL_
ehallam 360e219
NPA-6546: added prod configuration
ehallam e9edff9
NPA-6546: update secrets to generic name and make them environment based
ehallam 1702b8e
NPA-6546: removed variable 'environment' from non-prod actions
ehallam 5e2a78a
NPA-6546: renamed prod to production
ehallam cf6088d
NPA-6546: revert previous change
ehallam aa939be
NPA-6546: adding quotes for consistency
ehallam 90d91ff
NPA-6546: generate apim yaml file for int spec
ehallam 1c637bf
NPA-6546: rename credentials.yaml and settings.yaml files for consist…
ehallam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: "Setup Proxygen CLI (Prod)" | ||
| description: "Setup Proxygen CLI for production deployments" | ||
|
|
||
| inputs: | ||
| ENVIRONMENT: | ||
| description: "The environment to configure Proxygen for" | ||
| required: true | ||
| PROXYGEN_CLIENT_ID: | ||
| description: "Client ID for Proxygen CLI (Prod)" | ||
| required: true | ||
| PROXYGEN_KEY_ID: | ||
| description: "Key ID for Proxygen CLI (Prod)" | ||
| required: true | ||
| PROXYGEN_PRIVATE_KEY: | ||
| description: "Private key for Proxygen CLI (Prod)" | ||
| required: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Install Proxygen CLI | ||
| run: pip install proxygen-cli | ||
| shell: bash | ||
|
|
||
| - name: Create Proxygen configuration directory | ||
| run: mkdir -p ~/.proxygen | ||
| shell: bash | ||
|
|
||
| - name: Copy Proxygen credentials | ||
| run: cp proxygen/credentials-prod.yaml ~/.proxygen/credentials.yaml | ||
| shell: bash | ||
|
|
||
| - name: Create Proxygen private key file | ||
| run: | | ||
| echo "${{ inputs.PROXYGEN_PRIVATE_KEY }}" > ~/.proxygen/private_key.pem | ||
| chmod 600 ~/.proxygen/private_key.pem | ||
| shell: bash | ||
|
|
||
| - name: Update Proxygen Credentials | ||
| run: | | ||
| sed -i "s|CLIENT_ID_TO_BE_REPLACED|${{ inputs.PROXYGEN_CLIENT_ID }}|" ~/.proxygen/credentials.yaml | ||
| sed -i "s|KEY_ID_TO_BE_REPLACED|${{ inputs.PROXYGEN_KEY_ID }}|" ~/.proxygen/credentials.yaml | ||
| sed -i "s|PRIVATE_KEY_PATH_TO_BE_REPLACED|private_key.pem|" ~/.proxygen/credentials.yaml | ||
| shell: bash | ||
|
|
||
| - name: Copy Proxygen settings | ||
| run: cp proxygen/settings-prod.yaml ~/.proxygen/settings.yaml | ||
| shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # Glossary | ||
|
|
||
| A reference guide for key terms, tools, and concepts used in the IM1 PFS Auth project. | ||
|
|
||
| --- | ||
|
|
||
| ## APIM (API Management Platform) | ||
|
|
||
| The **NHS API Management Platform**, built and operated by NHS England. It provides the infrastructure for publishing, securing, monitoring, and managing APIs across the NHS. APIM is built on top of **Apigee** and is the platform that `im1-pfs-auth` is deployed to. It is accessible via `*.api.service.nhs.uk` URLs (e.g. `https://int.api.service.nhs.uk/im1-pfs-auth`). | ||
|
|
||
| --- | ||
|
|
||
| ## Apigee | ||
|
|
||
| **Apigee** is Google's API gateway and management product, which underpins the NHS APIM platform. It handles: | ||
|
|
||
| - Routing inbound API requests to backend containers | ||
| - Authentication and authorisation enforcement (e.g. composite token validation) | ||
| - Analytics and monitoring | ||
|
|
||
| In this project, Apigee proxies are deployed via the **Proxygen CLI** using the OpenAPI specification in the `specification/` directory. The Apigee UI is accessible at [https://apigee.com/edge](https://apigee.com/edge) under the `nhsd-nonprod` (non-production) and `nhsd-prod` (production) organisations. | ||
|
|
||
| --- | ||
|
|
||
| ## Proxygen (Service) | ||
|
|
||
| **Proxygen** (short for Proxy Generator) is an NHS England-built service that sits in front of Apigee and acts as the control plane for API producers. It abstracts the complexity of directly interacting with Apigee by accepting an OpenAPI specification and handling the creation and management of Apigee API proxies on your behalf. | ||
|
|
||
| The Proxygen service is accessible at: | ||
|
|
||
| ```text | ||
| https://proxygen.prod.api.platform.nhs.uk | ||
| ``` | ||
|
|
||
| It is also responsible for managing the **AWS ECR container registry** that holds the Docker images that back deployed API proxies. | ||
|
|
||
| --- | ||
|
|
||
| ## Proxygen CLI | ||
|
|
||
| The **Proxygen CLI** (`proxygen-cli`) is a Python command-line tool provided by NHS England that allows API producer teams to interact with the Proxygen service. In this project it is used to: | ||
|
|
||
| - **Deploy API proxy instances** to APIM environments (e.g. `internal-dev`, `int`, `prod`) via `proxygen instance deploy` | ||
| - **Publish the OpenAPI spec** to the NHS developer portal via `proxygen spec publish` | ||
| - **Obtain Docker credentials** for pushing container images to the NHS ECR registry via `proxygen docker get-login` | ||
| - **Obtain test tokens** for running end-to-end tests via `proxygen pytest-nhsd-apim get-token` | ||
|
|
||
| The CLI authenticates against the NHS identity service at: | ||
|
|
||
| ```text | ||
| https://identity.prod.api.platform.nhs.uk/realms/api-producers | ||
| ``` | ||
|
|
||
| This is a **Keycloak** identity provider used for machine-to-machine authentication for API producer teams. Authentication requires three credentials: a `client_id`, a `key_id`, and a `private_key` (PEM file). In CI/CD these are stored as GitHub secrets (`PROXYGEN_CLIENT_ID`, `PROXYGEN_KEY_ID`, `PROXYGEN_PRIVATE_KEY`) and also in the VRS AWS Prod Secrets Manager under the prefix `im1-pfs-auth/proxygen/<secret>`. | ||
|
|
||
| See the [Proxygen CLI guide](./Proxygen_CLI.md) for installation and configuration instructions. | ||
|
|
||
| --- | ||
|
|
||
| ## IM1 | ||
|
|
||
| **IM1** (Interface Mechanism 1) is a GP system integration standard used in the NHS. It defines how third-party applications (such as patient-facing services) can integrate with GP clinical systems (supplied by GPIT suppliers such as EMIS and TPP/SystmOne). IM1 allows authorised applications to act on behalf of patients, interacting with their GP practice's system. | ||
|
|
||
| --- | ||
|
|
||
| ## IM1 PFS Auth (`im1-pfs-auth`) | ||
|
|
||
| **IM1 Patient Facing Service Auth** is this project. It is an intermediary API service that enables patient-facing applications to authenticate and establish sessions with GP practice systems via the IM1 interface. It sits between a patient-facing application and a GPIT supplier system (e.g. EMIS, TPP), handling: | ||
|
|
||
| - Validation of NHS login proxy tokens | ||
| - Session initiation with the appropriate supplier system based on ODS code | ||
| - Transformation of supplier responses | ||
|
|
||
| It is deployed as an Apigee API proxy backed by a Docker container, and is accessible at `*.api.service.nhs.uk/im1-pfs-auth`. | ||
|
|
||
| --- | ||
|
|
||
| ## IM1 PFS Auth Developer Test App | ||
|
|
||
| The **IM1 PFS Auth Developer Test App** is a registered application in the Apigee developer portal (under the `nhsd-nonprod` organisation) used specifically for running end-to-end tests. It has access to the `mock-jwks` service, which is required for generating composite authentication tokens in the `internal-dev` environment. | ||
|
|
||
| When a new ephemeral deployment is created (e.g. from a pull request), it must be manually associated with this test app in the Apigee UI before end-to-end tests can be run against it. See the [Setup end to end tests guide](./Setup_end_to_end_tests.md) for instructions. | ||
|
|
||
| --- | ||
|
|
||
| ## Composite Token / mock-jwks | ||
|
|
||
| A **composite token** is a development-environment authentication token used in APIM's `internal-dev` environment to simulate authenticated requests without requiring real NHS login credentials. It is obtained from APIM's `mock-jwks` service. | ||
|
|
||
| The `mock-jwks` service is only enabled in the `internal-dev` environment. The **IM1 PFS Auth Developer Test App** must be associated with a deployment before composite tokens can be used against it. | ||
|
|
||
| --- | ||
|
|
||
| ## GPIT Supplier | ||
|
|
||
| A **GPIT supplier** is a provider of GP IT systems in the NHS — primarily **EMIS Health** and **TPP (The Phoenix Partnership)**, who make SystmOne. These are the systems that `im1-pfs-auth` communicates with when establishing patient sessions. Their base URLs are configured at build time via the `EMIS_BASE_URL` and `TPP_BASE_URL` environment variables. | ||
|
|
||
| --- | ||
|
|
||
| ## ODS Code | ||
|
|
||
| An **ODS (Organisation Data Service) code** is a unique identifier assigned to NHS organisations, including GP practices. `im1-pfs-auth` uses the ODS code of a patient's GP practice to determine which GPIT supplier system to route a session request to. | ||
|
|
||
| --- | ||
|
|
||
| ## ECR (Elastic Container Registry) | ||
|
|
||
| **AWS ECR** is the container image registry used to store the Docker images for `im1-pfs-auth`. The NHS-managed registry is at: | ||
|
|
||
| ```text | ||
| 958002497996.dkr.ecr.eu-west-2.amazonaws.com/im1-pfs-auth | ||
| ``` | ||
|
|
||
| Docker credentials to push to this registry are obtained via `proxygen docker get-login`. Apigee pulls the container from this registry when serving API requests. | ||
|
|
||
| --- | ||
|
|
||
| ## NHS Developer Hub / Developer Portal | ||
|
|
||
| The **NHS Internal Developer Hub** (accessible at `https://dos-internal.ptl.api.platform.nhs.uk`) is the portal where API producer teams manage their applications, API keys, and key pairs used for testing. It is also where the **IM1 PFS Auth Developer Test App** API key (`TEST_APP_API_KEY`) and private key (`TEST_APP_PRIVATE_KEY`) are registered and managed. | ||
|
|
||
| Access to the developer hub for end-to-end testing requires membership of the `Proxy Dev Team`. See the [NHS Developer Hub guide](./NHS_developer_hub.md) for more detail. | ||
|
|
||
| --- | ||
|
|
||
| ## Keycloak | ||
|
|
||
| **Keycloak** is an open-source identity and access management solution. NHS England uses a Keycloak instance at `https://identity.prod.api.platform.nhs.uk/realms/api-producers` as the identity provider for authenticating API producer machine users (i.e. the Proxygen CLI). It is also used in the test setup — `TEST_APP_KEYCLOAK_CLIENT_ID` and `TEST_APP_KEYCLOAK_CLIENT_SECRET` are credentials for a mocked authorisation provider client used in end-to-end tests. | ||
|
|
||
| --- | ||
|
|
||
| ## Sandbox | ||
|
|
||
| The **sandbox** is a simulated version of the `im1-pfs-auth` API that returns mock responses without connecting to real GPIT supplier systems. It is deployed alongside the main app in certain environments (e.g. `internal-dev-sandbox`, `sandbox`) and does not require authentication. It allows developers and API consumers to explore the API without needing to onboard or hold real credentials. | ||
|
|
||
| --- | ||
|
|
||
| ## Ephemeral Deployment | ||
|
|
||
| An **ephemeral deployment** is a temporary deployment of `im1-pfs-auth` created automatically when a pull request is opened. It is deployed to the `internal-dev` environment with a URL path following the pattern `im1-pfs-auth-pr-<pr_number>`, resulting in an Apigee proxy named `im1-pfs-auth--internal-dev--im1-pfs-auth-pr-<pr_number>`. These deployments are used to run end-to-end tests against code changes before they are merged to `main`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| base_url: https://identity.ptl.api.platform.nhs.uk/realms/api-producers | ||
| client_id: CLIENT_ID_TO_BE_REPLACED | ||
| key_id: KEY_ID_TO_BE_REPLACED | ||
| private_key_path: PRIVATE_KEY_PATH_TO_BE_REPLACED |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "endpoint_url": "https://proxygen.ptl.api.platform.nhs.uk", | ||
| "spec_output_format": "json", | ||
| "api": "im1-pfs-auth", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.