Skip to content

Commit d9e6493

Browse files
author
Adrian Clay
authored
Add PDS data within Wiremock migratestructuredrecord stub response (#641)
We believe this will reduce the time spend hand crafting and deploying specific wiremock stubs when testing in our INT Path to Live environment. Follows on from 4b2254b which was believed to have a similar effect, but it would appear that EMIS/TPP validate the patient details which come back. The only way I can see to avoid that failure in a pain-free way is to integrate with PDS directly, and inject the correct patients details into the response so that EMIS won't error. This only adds PDS data to `correctPatientNoDocsStructuredRecordResponse.json` but the same pattern could be expanded across all responses in a follow up PR.
1 parent 4c99d70 commit d9e6493

143 files changed

Lines changed: 591 additions & 16 deletions

File tree

Some content is hidden

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

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pipeline {
8888
if (sh(label: 'Running gp2gp docker build', script: 'docker build -f docker/service/Dockerfile -t ${DOCKER_IMAGE} .', returnStatus: true) != 0) {error("Failed to build gp2gp Docker image")}
8989

9090
if (publishWiremockImage) {
91-
if (sh(label: "Running ${WIREMOCK_ECR_REPO_DIR} docker build", script: 'docker build -f docker/wiremock/Dockerfile -t ${WIREMOCK_DOCKER_IMAGE} docker/wiremock', returnStatus: true) != 0) {error("Failed to build ${WIREMOCK_ECR_REPO_DIR} Docker image")}
91+
if (sh(label: "Running ${WIREMOCK_ECR_REPO_DIR} docker build", script: 'docker build -f docker/wiremock/Dockerfile -t ${WIREMOCK_DOCKER_IMAGE} .', returnStatus: true) != 0) {error("Failed to build ${WIREMOCK_ECR_REPO_DIR} Docker image")}
9292
}
9393
if (publishMhsMockImage) {
9494
if (sh(label: "Running ${MHS_MOCK_ECR_REPO_DIR} docker build", script: 'docker build -f docker/mock-mhs-adaptor/Dockerfile -t ${MHS_MOCK_DOCKER_IMAGE} .', returnStatus: true) != 0) {error("Failed to build ${MHS_MOCK_ECR_REPO_DIR} Docker image")}

developer-information.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ We provide mocks of external APIs (GPC, SDS) for local development and testing.
172172
* Navigate to `docker`
173173
* `docker-compose up wiremock`
174174

175-
The folder `docker/wiremock/stubs` describes the supported interactions.
175+
The folder `wiremock/stubs` and [README](wiremock/README.md) describe the supported interactions.
176176

177177
## How to use Mock MHS Adaptor
178178

docker/docker-compose.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,11 @@ services:
8282
wiremock:
8383
networks:
8484
- commonforgp2gp
85-
build: ./wiremock
85+
build:
86+
context: ../
87+
dockerfile: docker/wiremock/Dockerfile
8688
ports:
8789
- "8110:8080"
88-
command:
89-
- -global-response-templating
90-
- -no-request-journal
9190

9291
integration-wiremock:
9392
networks:

docker/wiremock/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
FROM wiremock/wiremock:2.33.2
1+
FROM gradle:8.5-jdk17
22

3-
COPY stubs /home/wiremock
3+
COPY --chown=gradle:gradle wiremock /home/gradle/wiremock
44

5-
CMD ["--global-response-templating", "--verbose"]
5+
WORKDIR /home/gradle/wiremock
6+
7+
RUN ["gradle", "jar"]
8+
9+
ENTRYPOINT ["java", "-jar", "build/libs/wiremock.jar"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ The `migratestructuredrecord` endpoint will also respond to unknown NHS Numbers,
5555
by default returning a NOT FOUND response, but can also be set up to reply with
5656
a valid patient record.
5757

58+
Wiremock can also be configured to fetch patient information (name, dob, address)
59+
from the PDS Application-Restricted FHIR API.
60+
61+
Using the [authentication guidance], you'll need to provide the following environment variables:
62+
63+
- PDS_KEY_ID - "Key Identifier" from Step 2
64+
- PDS_API_KEY - "API Key" from Step 1
65+
- PDS_PRIVATE_KEY - "Private key" from Step 2, as a string without whitespace, and the "---" header and footers removed.
66+
67+
[authentication guidance]: https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-signed-jwt-authentication
68+
5869
### Changing the default record
5970

6071
To change the patient record returned to be [No Documents](stubs/__files/correctPatientNoDocsStructuredRecordResponse.json):

wiremock/build.gradle

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apply plugin: 'java'
2+
apply plugin: 'application'
3+
repositories {
4+
mavenCentral()
5+
}
6+
7+
dependencies {
8+
implementation "org.wiremock:wiremock:3.4.1"
9+
implementation "org.json:json:20240303"
10+
implementation "com.auth0:java-jwt:4.4.0"
11+
implementation "org.slf4j:slf4j-simple:2.0.12"
12+
}
13+
14+
mainClassName = 'Wiremock'
15+
16+
jar {
17+
manifest {
18+
attributes 'Main-Class': application.mainClass
19+
}
20+
21+
from {
22+
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
23+
}
24+
25+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
26+
}
42.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

wiremock/gradlew

Lines changed: 249 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)