Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6b0f825
Move towards using URL-based env var names.
davidhamill1-nhs Apr 15, 2026
a4675a8
Resolve this TODO later.
davidhamill1-nhs Apr 15, 2026
0202c90
Broaden vocabulary.
davidhamill1-nhs Apr 15, 2026
8d2f8a1
Log the client details.
davidhamill1-nhs Apr 16, 2026
dea2c64
Use env vars and pass those through an .env file in the make deploy c…
davidhamill1-nhs Apr 16, 2026
4204308
Make number go up.
davidhamill1-nhs Apr 16, 2026
899ba50
Make number go up.
davidhamill1-nhs Apr 16, 2026
4f47fa9
Make number go up.
davidhamill1-nhs Apr 16, 2026
d80e86e
Make explicit environment variables being passed to container.
davidhamill1-nhs Apr 16, 2026
67ef071
Make mypy happy again.
davidhamill1-nhs Apr 16, 2026
b289500
Place env vars in to app config.
davidhamill1-nhs Apr 16, 2026
69a2929
Pass URLs to controller.
davidhamill1-nhs Apr 16, 2026
5268215
Remove default URLs
davidhamill1-nhs Apr 16, 2026
3cdecdb
Tidy up.
davidhamill1-nhs Apr 16, 2026
ba67227
Improve make commands to build up env files for different environments.
davidhamill1-nhs Apr 16, 2026
c54bb04
Merge remote-tracking branch 'origin' into debt/GPCAPIM-359-sort-out-…
davidhamill1-nhs Apr 16, 2026
5b41732
FLASK env vars are not actually variable. Leave them hardcoded.
davidhamill1-nhs Apr 20, 2026
a2866c5
Enable test environment to be set up easily.
davidhamill1-nhs Apr 21, 2026
a0a47d3
Define shell.
davidhamill1-nhs Apr 21, 2026
e6e1c14
Inject env correctly and safely.
davidhamill1-nhs Apr 21, 2026
78663fa
Remove duplicate/unused make commands.
davidhamill1-nhs Apr 21, 2026
15528f8
Add simple logging to clients to demonstrate URLs being used.
davidhamill1-nhs Apr 21, 2026
629c53c
Remove unused pipeline env var.
davidhamill1-nhs Apr 21, 2026
405a7af
Merge remote-tracking branch 'origin' into debt/GPCAPIM-359-sort-out-…
davidhamill1-nhs Apr 21, 2026
71cf237
Don't need to do some TODOs
davidhamill1-nhs Apr 21, 2026
0c29fb2
Resolve some TODOs
davidhamill1-nhs Apr 22, 2026
3dd80ff
Handle unit test enviroment variables better.
davidhamill1-nhs Apr 22, 2026
c82811f
Simplify local vs remote paths.
davidhamill1-nhs Apr 22, 2026
247881f
Always overwrite.
davidhamill1-nhs Apr 22, 2026
d850d0e
Update docs. Improve env-ci output.
davidhamill1-nhs Apr 22, 2026
c3d633f
Tidy up.
davidhamill1-nhs Apr 22, 2026
2aafbee
Place the test user in to the env variables.
davidhamill1-nhs Apr 22, 2026
928d629
Tidy up.
davidhamill1-nhs Apr 22, 2026
9290a0a
Merge remote-tracking branch 'origin' into debt/GPCAPIM-359-sort-out-…
davidhamill1-nhs Apr 22, 2026
04092fd
Make linter happy.
davidhamill1-nhs Apr 22, 2026
0b7e583
More tightly define type.
davidhamill1-nhs Apr 22, 2026
bda2bb6
Doesn't seem to 'omit'
davidhamill1-nhs Apr 22, 2026
55a234b
Resolved to do.
davidhamill1-nhs Apr 22, 2026
bab15e1
Place make env file eariler in commands to run.
davidhamill1-nhs Apr 22, 2026
cff2eff
Update creation of .env.test. steps.
davidhamill1-nhs Apr 22, 2026
5fc19a2
Add an orangebox environment that would reflect env-organebox behaviour.
davidhamill1-nhs Apr 22, 2026
4082b47
Correctly print out logs.
davidhamill1-nhs Apr 22, 2026
f9be003
Make orange box test patient FHIR compliant.
davidhamill1-nhs Apr 22, 2026
5ded7c5
Update FHIR Parameters resource to include required name field.
davidhamill1-nhs Apr 22, 2026
03aff72
Add explicit return statements.
davidhamill1-nhs Apr 22, 2026
80bedaf
Add a default case for the test user - none. It should only be needed…
davidhamill1-nhs Apr 22, 2026
762b10b
Add local secret handling for int
davidhamill1-nhs Apr 23, 2026
f9f1319
Removing noise from "make deploy" output
davidhamill1-nhs Apr 23, 2026
5c99f53
Only log pertinent, non-sensitive env vars.
davidhamill1-nhs Apr 23, 2026
dd2c50b
Do not log sensitive headers.
davidhamill1-nhs Apr 23, 2026
b5445c5
clean up.
davidhamill1-nhs Apr 23, 2026
519efda
Remove env vars that did not exist before fiddling with the env vars.
davidhamill1-nhs Apr 23, 2026
057a4c4
Options not supported at this level.
davidhamill1-nhs Apr 23, 2026
548c49d
Do not log sensitive headers.
davidhamill1-nhs Apr 23, 2026
158f4c0
Stub for int environment, until 397 is worked.
davidhamill1-nhs Apr 23, 2026
c22c719
Provide useful error messages if env files do not exist.
davidhamill1-nhs Apr 23, 2026
9d39d0e
Merge remote-tracking branch 'origin' into debt/GPCAPIM-359-sort-out-…
davidhamill1-nhs Apr 23, 2026
d043161
Provide explanation around the expected secrets.
davidhamill1-nhs Apr 23, 2026
7a4fc64
Correct env file check.
davidhamill1-nhs Apr 23, 2026
f84e63e
Refine logger setup; test url that instantiates the client is being u…
davidhamill1-nhs Apr 23, 2026
5d2266e
Rename class to better reflect behaviour.
davidhamill1-nhs Apr 23, 2026
3775cb5
Test url that instantiates the controller is being used on the GET re…
davidhamill1-nhs Apr 23, 2026
c98e561
Remove unused fixture.
davidhamill1-nhs Apr 23, 2026
8c5c2fe
Provider a more helpful warning.
davidhamill1-nhs Apr 23, 2026
1212296
Explain what this decorator is doing.
davidhamill1-nhs Apr 23, 2026
b02ac58
Update fixture name.
davidhamill1-nhs Apr 23, 2026
71ea523
Remove toggling of sandbox/int services
davidhamill1-nhs Apr 23, 2026
4032bbc
Merge branch 'debt/GPCAPIM-359-sort-out-env-vars' into feature/GPCAPI…
davidhamill1-nhs Apr 23, 2026
f04a489
Remove toggling of sandbox/int services
davidhamill1-nhs Apr 23, 2026
99c4328
Merge branch 'debt/GPCAPIM-359-sort-out-env-vars' into feature/GPCAPI…
davidhamill1-nhs Apr 23, 2026
1901406
As of pytest 4, ini_options is no longer needed.
davidhamill1-nhs Apr 27, 2026
2c563f1
Merge remote-tracking branch 'origin' into feature/GPCAPIM-397-set-up…
davidhamill1-nhs Apr 27, 2026
7c5494d
Remove redundant only file in redundant folder.
davidhamill1-nhs Apr 27, 2026
fbfa9e1
Need to find a way to trust the CA for EMIS INT's certs.
davidhamill1-nhs Apr 27, 2026
d46ae9e
Enable easy test config for int.
davidhamill1-nhs Apr 27, 2026
23379f8
Seed EMIS INT patient into stub, to allow for testing while INT PDS A…
davidhamill1-nhs Apr 27, 2026
1372326
Update env make commands to allow for testing INT.
davidhamill1-nhs Apr 27, 2026
4f8706c
Update vocab.
davidhamill1-nhs Apr 27, 2026
96434d3
Handle additional kwargs that can be passed in a requests.post method.
davidhamill1-nhs Apr 27, 2026
2f54b36
Reduce friction in adding new endpoints to the stub.
davidhamill1-nhs Apr 27, 2026
ae1e161
Add body to provider response logging, in order to understand/confirm…
davidhamill1-nhs Apr 27, 2026
2ef3bd1
Provide value that are valid for INT environment requests - full end-…
davidhamill1-nhs Apr 27, 2026
b5a274a
Make it easier to build INT env file.
davidhamill1-nhs Apr 27, 2026
361c6e2
Update docs.
davidhamill1-nhs Apr 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/cspell-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dpkg
DSTU
eamodio
errstr
EMIS
Farsley
fhir
getfixturevalue
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ deploy: clean build # Build project artefact and deploy locally @Pipeline
deploy-%: # Build project artefact and deploy locally as specified environment - mandatory: name=[name of the environment, e.g. 'dev'] @Pipeline
make env-$* deploy

deploy-%: # Build project artefact and deploy locally as specified environment - mandatory: name=[name of the environment, e.g. 'dev'] @Pipeline
make env-$* deploy

clean:: stop # Clean-up project resources (main) @Operations
@echo "Removing Gateway API container..."
@$(docker) rm gateway-api || echo "No Gateway API container currently exists."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: INT
variables:
- name: nhs_number
value: "9692140466"
- name: from_ods
value: A12345
- name: base_url
value: http://localhost:5000
2 changes: 1 addition & 1 deletion gateway-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dev = [
[tool.mypy]
strict = true

[tool.pytest.ini_options]
[tool.pytest]
bdd_features_base_dir = "tests/acceptance/features"
markers = [
"status_auth_headers",
Expand Down
2 changes: 2 additions & 0 deletions gateway-api/src/gateway_api/provider/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@
headers=headers,
data=body,
timeout=TIMEOUT,
verify=False, # TODO: change this.

Check warning on line 143 in gateway-api/src/gateway_api/provider/client.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_clinical-data-gateway-api&issues=AZ3RGYLgqgvhdYcr4dLB&open=AZ3RGYLgqgvhdYcr4dLB&pullRequest=193
)
log_details = {
"description": "GPProvider FHIR API response received",
"status_code": str(response.status_code),
"body": response.text, # TODO: Remove me before putting up for review

Check warning on line 148 in gateway-api/src/gateway_api/provider/client.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_clinical-data-gateway-api&issues=AZ3RIs37BmlCJMSja_15&open=AZ3RIs37BmlCJMSja_15&pullRequest=193
}
_logger.info(log_details)

Expand Down
2 changes: 1 addition & 1 deletion gateway-api/src/gateway_api/provider/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _fake_post(
url: str,
headers: CaseInsensitiveDict[str],
data: str,
timeout: int, # NOQA ARG001 (unused in stub)
**_kwargs: str,
) -> Response:
"""A fake requests.post implementation."""

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"resourceType": "Patient",
"id": "593C97B5-7B99-4326-9140-B329CC03A0D1",
"meta": {
"versionId": "1533356236474679227",
"profile": [
"https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Patient-1"
]
},
"extension": [
{
"url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-RegistrationDetails-1",
"extension": [
{
"url": "preferredBranchSurgery",
"valueReference": {
"reference": "Location/EB3994A6-5A87-4B53-A414-913137072F57"
}
}
]
}
],
"identifier": [
{
"extension": [
{
"url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-NHSNumberVerificationStatus-1",
"valueCodeableConcept": {
"coding": [
{
"system": "https://fhir.nhs.uk/STU3/CodeSystem/CareConnect-NHSNumberVerificationStatus-1",
"code": "01",
"display": "Number present and verified"
}
],
"text": "Number present and verified"
}
}
],
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "9692140466"
}
],
"name": [
{
"use": "official",
"family": "Egan",
"given": [
"Lester"
],
"prefix": [
"Mr"
]
}
],
"gender": "male",
"birthDate": "1958-02-02",
"address": [
{
"use": "home",
"type": "physical",
"line": [
"Cornerways",
"Leek Hill",
"Winterton"
],
"city": "Scunthorpe",
"district": "S Humberside",
"postalCode": "DN15 9SR"
}
],
"generalPractitioner": [
{
"id": "1",
"type": "Organization",
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
"value": "EMIS_INT_ODS_CODE",
"period": {"start": "2020-01-01", "end": "9999-12-31"}
}
}
]
}
1 change: 1 addition & 0 deletions gateway-api/stubs/stubs/data/patients/patients.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ def load_patient(filename: str) -> dict[str, Any]:
)
ALICE_JONES_9999999999 = load_patient("alice_jones_9999999999.json")
ORANGE_BOX_TRIGGER_9690937278 = load_patient("orange_box_trigger_9690937278.json")
EMIS_INT_TEST_9692140466 = load_patient("emis_int_test_9692140466.json")
1 change: 1 addition & 0 deletions gateway-api/stubs/stubs/pds/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, strict_headers: bool = True) -> None:
("9000000012", Patients.INDUCE_PROVIDER_ERROR_9000000012),
("9000000013", Patients.BLANK_ENDPOINT_SDS_RESULT_9000000013),
("9690937278", Patients.ORANGE_BOX_TRIGGER_9690937278),
("9692140466", Patients.EMIS_INT_TEST_9692140466),
]
for nhs_number, patient in test_patients:
self.upsert_patient(
Expand Down
18 changes: 16 additions & 2 deletions gateway-api/stubs/stubs/sds/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def _seed_default_devices(self) -> None:
{
"org_ods": "CONSUMER",
"device_id": "C0C0E921-92CA-4A88-A550-2DBB36F703AF",
"asid": "asid_CONS",
"asid": "210987654321",
"display": "Example Consumer Organisation",
},
{
Expand Down Expand Up @@ -383,6 +383,13 @@ def _seed_default_devices(self) -> None:
"asid": "918999198738",
"display": "ODS/ASID triggering Orange Box",
},
{
"org_ods": "EMIS_INT_ODS_CODE",
"party_key": "EMIS_INT_ODS_CODE-0000809",
"device_id": "5CF77971-5732-43C6-959B-90F0DB6E49AD",
"asid": "200000000948",
"display": "GP with endpoint to get to EMIS INT TEST",
},
]

# Seed each device for both interaction IDs so the stub works whether
Expand Down Expand Up @@ -419,7 +426,7 @@ def _seed_default_endpoints(self) -> None:
{
"org_ods": "CONSUMER",
"endpoint_id": "E1E1E921-92CA-4A88-A550-2DBB36F703AF",
"asid": "asid_CONS",
"asid": "210987654321",
"address": "https://consumer.example.com/fhir",
},
{
Expand All @@ -434,6 +441,13 @@ def _seed_default_endpoints(self) -> None:
"asid": "918999198738",
"address": "https://orange.testlab.nhs.uk/B82617/STU3/1/gpconnect/structured/fhir/",
},
{
"org_ods": "EMIS_INT_ODS_CODE",
"party_key": "EMIS_INT_ODS_CODE-0000809",
"endpoint_id": "BD635368-97E0-4935-A0D7-55CFDE574C93",
"asid": "200000000948",
"address": "https://gpcassurance-b86047.emis.thirdparty.nhs.uk/A82038/STU3/1/GPConnect/structured",
},
]

# Seed each endpoint for both interaction IDs so the stub works whether
Expand Down
1 change: 1 addition & 0 deletions gateway-api/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Use the following commands to create the appropriate `.env.test` file for the ta
* `make env-test-ci` to write a `.env.test` file for testing a locally deployed application, from outside the dev container.
* `make env-test-pr-<pr number>` to write a `.env.test` file for testing an application deployed behind a PR proxy.
* `make env-test-alpha-int` to write a `.env.test` file for testing an application deployed to the "alpha integration" environment.
* `make env-test-int` to write a `.env.test` file for testing an application that sends requests to PDS, SDS and Provider integration environments.

_Note: Unit tests require the `.env` file, as these tests do not test a deployed application`_

Expand Down
25 changes: 21 additions & 4 deletions gateway-api/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Pytest configuration and shared fixtures for gateway API tests."""

import copy
import os
from collections.abc import Callable
from datetime import timedelta
from typing import Any, cast
from uuid import uuid4

import pytest
import requests
Expand All @@ -13,7 +13,7 @@
DEFAULT_REQUEST_HEADERS = {
"Content-Type": "application/fhir+json",
"Ods-from": "CONSUMER",
"Ssp-TraceID": "test-trace-id",
"Ssp-TraceID": str(uuid4()),
}


Expand Down Expand Up @@ -80,8 +80,25 @@ def send_health_check(self) -> requests.Response:


@pytest.fixture
def simple_request_payload() -> dict[str, Any]:
return copy.deepcopy(SIMPLE_PAYLOAD)
def nhs_number() -> str:
return _fetch_env_variable("TEST_NHS_NUMBER", str)


@pytest.fixture
def simple_request_payload(nhs_number: str) -> dict[str, Any]:
payload = {
"resourceType": "Parameters",
"parameter": [
{
"name": "patientNHSNumber",
"valueIdentifier": {
"system": FHIRSystem.NHS_NUMBER,
"value": nhs_number,
},
},
],
}
return payload


@pytest.fixture
Expand Down
14 changes: 2 additions & 12 deletions gateway-api/tests/contract/stub/test_sds_stub_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,22 +238,12 @@ def test_endpoint_bundle_matches_expected_response(
assert body["type"] == "searchset"
assert body["total"] == len(body["entry"])

assert len(body["entry"]) == 4
endpoint_ids = [
"E0E0E921-92CA-4A88-A550-2DBB36F703AF",
"E1E1E921-92CA-4A88-A550-2DBB36F703AF",
"E2E2E921-92CA-4A88-A550-2DBB36F703AF",
"E3E3E921-92CA-4A88-A550-2DBB36F703AF",
]
for i in range(len(endpoint_ids)):
entry = body["entry"][i]

endpoint_id = endpoint_ids[i]
for entry in body["entry"]:
endpoint_id = entry["resource"]["id"]
assert (
entry["fullUrl"]
== f"https://sandbox.api.service.nhs.uk/spine-directory/FHIR/R4/Endpoint/{endpoint_id}"
)
assert entry["resource"]["id"] == endpoint_id
assert entry["search"]["mode"] == "match"

def test_x_correlation_id_echoed_back_when_provided(
Expand Down
Loading
Loading