Skip to content

Commit cd56544

Browse files
Merge remote-tracking branch 'origin/main' into feature/GPCAPIM-396-sds-int
2 parents 8896249 + a1b413d commit cd56544

63 files changed

Lines changed: 1271 additions & 892 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.template

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/SECURITY.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/actions/run-test-suite/action.yaml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,25 @@ inputs:
99
test-type:
1010
description: "Type of test to run"
1111
required: true
12-
apigee-access-token:
13-
description: "Apigee access token"
14-
required: false
15-
base-url:
16-
description: "The URL of the environment to test"
17-
required: false
1812
env:
19-
description: "Environment: local or remote"
13+
description: "Environment to run tests against: ci, alpha-int, pr-<number> - see env.mk"
2014
required: false
21-
default: "remote"
15+
default: "ci"
2216

2317
runs:
2418
using: composite
2519
steps:
26-
- name: "Run ${{ inputs.test-type }} tests"
20+
- name: Set up environment
2721
shell: bash
2822
env:
29-
APIGEE_ACCESS_TOKEN: ${{ inputs.apigee-access-token }}
30-
BASE_URL: ${{ inputs.base-url }}
3123
ENV: ${{ inputs.env }}
24+
run: make env-test-"${ENV}"
25+
26+
- name: "Run ${{ inputs.test-type }} tests"
27+
shell: bash
28+
env:
3229
TEST_TYPE: ${{ inputs.test-type }}
3330
run: |
34-
if [[ -n "${APIGEE_ACCESS_TOKEN}" ]]; then
35-
echo "::add-mask::${APIGEE_ACCESS_TOKEN}"
36-
fi
37-
38-
# Clean test artefacts so each suite uploads only its own results
3931
rm -rf gateway-api/test-artefacts/* || true
4032
mkdir -p gateway-api/test-artefacts
4133
make test-"${TEST_TYPE}"

.github/actions/start-app/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ inputs:
44
deploy-command:
55
description: "Command to start app"
66
required: false
7-
default: "make deploy"
7+
default: "make deploy-ci"
88
health-path:
99
description: "Health check path"
1010
required: false

.github/instructions/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository is for handling HTTP requests from "Consumer systems" and forwar
88

99
We use other NHSE services to assist in the validation and processing of the requests including PDS FHIR API for obtaining GP practice codes for the patient, SDS FHIR API for obtaining the "Provider system" details of that GP practice and Healthcare Worker FHIR API for obtaining details of the requesting practitioner using the "Consumer System" that will then be added to the forwarded request.
1010

11-
`make deploy` will build and start a container running Gateway API at `localhost:5000`.
11+
`make deploy-dev` will build and start a container running Gateway API at `localhost:5000`.
1212

1313
After deploying the container locally, `make test` will run all tests and capture their coverage. Note: env variables control the use of stubs for the PDS FHIR API, SDS FHIR API, Healthcare Worker FHIR API and Provider system services.
1414

.github/workflows/alpha-integration-env.yml

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ env:
1414
TF_STATE_KEY: "dev/preview/alpha-integration.tfstate"
1515
BRANCH_NAME: "alpha-integration"
1616
ALB_RULE_PRIORITY: "900"
17-
BASE_URL: "https://internal-dev.api.service.nhs.uk/clinical-data-gateway-api-poc-alpha-integration"
1817
python_version: "3.14"
1918
PROXYGEN_API_NAME: ${{ vars.PROXYGEN_API_NAME }}
2019

@@ -196,63 +195,34 @@ jobs:
196195
echo "http_result=unexpected-status" >> "$GITHUB_OUTPUT"
197196
exit 0
198197
199-
- name: Retrieve Apigee Token
200-
id: apigee-token
201-
shell: bash
202-
run: |
203-
set -euo pipefail
204-
205-
APIGEE_TOKEN="$(proxygen pytest-nhsd-apim get-token | jq -r '.pytest_nhsd_apim_token' 2>/dev/null)"
206-
if [ -z "$APIGEE_TOKEN" ] || [ "$APIGEE_TOKEN" = "null" ]; then
207-
echo "::error::Failed to retrieve Apigee token"
208-
exit 1
209-
fi
210-
211-
echo "::add-mask::$APIGEE_TOKEN"
212-
printf 'apigee-access-token=%s\n' "$APIGEE_TOKEN" >> "$GITHUB_OUTPUT"
213-
echo "Token retrieved successfully (length: ${#APIGEE_TOKEN})"
214-
215198
- name: Run unit tests
216199
uses: ./.github/actions/run-test-suite
217200
with:
218201
test-type: unit
219-
env: local
220202

221203
- name: Run contract tests
222204
uses: ./.github/actions/run-test-suite
223-
env:
224-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-alpha-integration"
225205
with:
226206
test-type: contract
227-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
228-
base-url: ${{ env.BASE_URL }}
207+
env: alpha-int
229208

230209
- name: Run schema validation tests
231210
uses: ./.github/actions/run-test-suite
232-
env:
233-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-alpha-integration"
234211
with:
235212
test-type: schema
236-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
237-
base-url: ${{ env.BASE_URL }}
213+
env: alpha-int
238214

239215
- name: Run integration tests
240216
uses: ./.github/actions/run-test-suite
241-
env:
242-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-alpha-integration"
243217
with:
244218
test-type: integration
245-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
246-
base-url: ${{ env.BASE_URL }}
219+
env: alpha-int
247220

248221
- name: Run acceptance tests
249222
uses: ./.github/actions/run-test-suite
250-
env:
251-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-alpha-integration"
252223
with:
253224
test-type: acceptance
254-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
255-
base-url: ${{ env.BASE_URL }}
225+
env: alpha-int
256226

257227
- name: Remove mTLS temp files
258228
run: rm -f /tmp/client1-key.pem /tmp/client1-cert.pem

.github/workflows/preview-env.yml

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ env:
1010
ECR_REPOSITORY_NAME: "whoami"
1111
TF_STATE_BUCKET: "cds-cdg-dev-tfstate-900119715266"
1212
PREVIEW_STATE_PREFIX: "dev/preview/"
13-
BASE_URL: "https://internal-dev.api.service.nhs.uk/clinical-data-gateway-api-poc-pr-${{ github.event.pull_request.number }}"
1413
python_version: "3.14"
1514
PROXYGEN_API_NAME: ${{ vars.PROXYGEN_API_NAME }}
1615
PR_NUMBER: ${{ github.event.pull_request.number }}
@@ -314,28 +313,11 @@ jobs:
314313
315314
# ---------- QUALITY CHECKS (Test Suites) ----------
316315

317-
- name: Retrieve Apigee Token
318-
id: apigee-token
319-
shell: bash
320-
run: |
321-
set -euo pipefail
322-
323-
APIGEE_TOKEN="$(proxygen pytest-nhsd-apim get-token | jq -r '.pytest_nhsd_apim_token' 2>/dev/null)"
324-
if [ -z "$APIGEE_TOKEN" ] || [ "$APIGEE_TOKEN" = "null" ]; then
325-
echo "::error::Failed to retrieve Apigee token"
326-
exit 1
327-
fi
328-
329-
echo "::add-mask::$APIGEE_TOKEN"
330-
printf 'apigee-access-token=%s\n' "$APIGEE_TOKEN" >> "$GITHUB_OUTPUT"
331-
echo "Token retrieved successfully (length: ${#APIGEE_TOKEN})"
332-
333316
- name: "Run unit tests"
334317
if: github.event.action != 'closed'
335318
uses: ./.github/actions/run-test-suite
336319
with:
337320
test-type: unit
338-
env: local
339321

340322
- name: "Run load tests"
341323
if: github.event.action != 'closed' && steps.smoke-test.outputs.http_result != 'unexpected-status'
@@ -349,42 +331,30 @@ jobs:
349331
- name: "Run contract tests"
350332
if: github.event.action != 'closed'
351333
uses: ./.github/actions/run-test-suite
352-
env:
353-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-pr-${{ github.event.pull_request.number }}"
354334
with:
355335
test-type: contract
356-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
357-
base-url: ${{ env.BASE_URL }}
336+
env: pr-${{ github.event.pull_request.number }}
358337

359338
- name: "Run schema validation tests"
360339
if: github.event.action != 'closed'
361340
uses: ./.github/actions/run-test-suite
362-
env:
363-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-pr-${{ github.event.pull_request.number }}"
364341
with:
365342
test-type: schema
366-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
367-
base-url: ${{ env.BASE_URL }}
343+
env: pr-${{ github.event.pull_request.number }}
368344

369345
- name: "Run integration tests"
370346
if: github.event.action != 'closed'
371347
uses: ./.github/actions/run-test-suite
372-
env:
373-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-pr-${{ github.event.pull_request.number }}"
374348
with:
375349
test-type: integration
376-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
377-
base-url: ${{ env.BASE_URL }}
350+
env: pr-${{ github.event.pull_request.number }}
378351

379352
- name: "Run acceptance tests"
380353
if: github.event.action != 'closed'
381354
uses: ./.github/actions/run-test-suite
382-
env:
383-
PROXY_BASE_PATH: "clinical-data-gateway-api-poc-pr-${{ github.event.pull_request.number }}"
384355
with:
385356
test-type: acceptance
386-
apigee-access-token: ${{ steps.apigee-token.outputs.apigee-access-token }}
387-
base-url: ${{ env.BASE_URL }}
357+
env: pr-${{ github.event.pull_request.number }}
388358

389359
# Cleanup after tests
390360
- name: Remove mTLS temp files

.github/workflows/stage-2-test.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
name: "Test stage"
22

3-
env:
4-
BASE_URL: "http://localhost:5000"
5-
HOST: "localhost"
6-
STUB_SDS: "true"
7-
STUB_PDS: "true"
8-
STUB_PROVIDER: "true"
9-
103
on:
114
workflow_call:
125
inputs:
@@ -45,6 +38,8 @@ jobs:
4538
uses: ./.github/actions/setup-python-project
4639
with:
4740
python-version: ${{ inputs.python_version }}
41+
- name: Set environment variables
42+
run: make env-test-ci
4843
- name: "Run unit test suite"
4944
run: make test-unit
5045
- name: "Upload unit test results"
@@ -75,6 +70,8 @@ jobs:
7570
uses: ./.github/actions/start-app
7671
with:
7772
python-version: ${{ inputs.python_version }}
73+
- name: Set environment variables
74+
run: make env-test-ci
7875
- name: "Run contract tests"
7976
run: make test-contract
8077
- name: "Upload contract test results"
@@ -105,6 +102,8 @@ jobs:
105102
uses: ./.github/actions/start-app
106103
with:
107104
python-version: ${{ inputs.python_version }}
105+
- name: Set environment variables
106+
run: make env-test-ci
108107
- name: "Run schema validation tests"
109108
run: make test-schema
110109
- name: "Upload schema test results"
@@ -135,6 +134,8 @@ jobs:
135134
uses: ./.github/actions/start-app
136135
with:
137136
python-version: ${{ inputs.python_version }}
137+
- name: Set environment variables
138+
run: make env-test-ci
138139
- name: "Run integration test"
139140
run: make test-integration
140141
- name: "Upload integration test results"
@@ -166,6 +167,8 @@ jobs:
166167
with:
167168
python-version: ${{ inputs.python_version }}
168169
max-seconds: 90
170+
- name: Set environment variables
171+
run: make env-test-ci
169172
- name: "Run acceptance test"
170173
run: make test-acceptance
171174
- name: "Upload acceptance test results"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ gateway-api/test-artefacts/
2626
**/.env.*
2727
**/.DS_Store
2828
**/.terraform.lock.hcl
29+
30+
# Any file within .secrets
31+
.secrets/**
32+
!.secrets/README.md

.secrets/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Secrets
2+
3+
This directory is used to store secrets.
4+
5+
The secrets are accessed through `make env-<int|int-pds|int-sds>` which sets the secrets required for PDS FHIR API and SDS FHIR API to `.env` file, which is then fed in to the locally deployed application through `make deploy`.
6+
7+
## PDS
8+
9+
PDS FHIR API requires [signed JWT for application-resrtictecd access](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-signed-jwt-authentication). As such, the following three secrets enable the Gateway API to authenticate:
10+
11+
* `.secrets/pds/api_token` - the API key of the application through which the Gateway API will consume NHSE APIs.
12+
* `.secrets/pds/api_secret` - the private key of the public/private key pair created for application identified by `api_token`
13+
* `.secrets/pds/api_kid` - the key identifier for the private/public key pair used for the `api_secret`.
14+
15+
## SDS
16+
17+
SDS FHIR API requires [API key authentication](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-api-key-authentication) for application-restricted access. As such, the only secret required is
18+
19+
* `.secrets/sds/api_token` - the API key of the application through which the Gateway API will consume NHSE APIs.

0 commit comments

Comments
 (0)