Skip to content

Commit debd58c

Browse files
Merge pull request #1939 from NHSDigital/feature/ERSSUP-81596-81565
Feature/erssup 81596 81565
2 parents f431e8f + fcf4400 commit debd58c

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

sandbox/src/routes/stu3/services/mockResponseProvider.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,24 @@ module.exports = {
166166

167167
getExampleResponseForRetrieveAttachment: function (request) {
168168

169-
const attachmentId = request.params.attachmentLogicalID
169+
const attachmentId = request.params.attachmentLogicalID;
170170

171171
if (attachmentId) {
172172

173173
if (attachmentId.startsWith('att-')) {
174-
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 }
174+
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 };
175175
}
176176

177-
if (attachmentId === 'c5d2d200-7613-4a69-9c5f-1bb68e04b8d8') {
178-
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 }
177+
if (this.isvalidUuid(attachmentId)) {
178+
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 };
179179
}
180180
}
181181

182+
return {};
183+
},
184+
185+
isvalidUuid: function(string) {
186+
return /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i.test(string);
182187
},
183188

184189
getExampleResponseForRetrieveReferralRequest: function (request) {

specification/components/stu3/schemas/endpoints/a006-retrieve-attachment.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ description: |
6565
## Related endpoints
6666
6767
You can retrieve a clinical information summary for a referral using [[HYPERLINK_A007]].
68+
69+
## Sandbox test scenarios
70+
71+
The sandbox for this endpoint is a simple implementation that only supports success cases.
72+
73+
A successful response will always be returned, provided the Binary ID is in a valid format. The Availability Status of a file is not considered in the sandbox and a file will always be available for retrieval.
74+
75+
Successful responses will always return the same example PDF file.
6876
6977
summary: Retrieve attachment (A006, FHIR STU3) [deprecated]
7078
operationId: a006-retrieve-attachment

specification/components/stu3/schemas/endpoints/a044-create-advice-and-guidance-request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ description: |
2020
In order to retrieve an attachment using the [[HYPERLINK_A042]] (or deprecated [[HYPERLINK_A006]]) endpoint, the attachment must be available for download.
2121
The availability status of attachments associated with a referral are returned via this endpoint as a eRS-AvailabilityStatus-1 code.
2222
23-
Further details on attachment availability status and eRS-AvailabilityStatus-1 codes can be found in the [[HYPERLINK_A005]] and [[HYPERLINK_A042]] specifications.
23+
Further details on attachment availability status and eRS-AvailabilityStatus-1 codes can be found in the [[HYPERLINK_A024]], [[HYPERLINK_A025]] and [[HYPERLINK_A042]] specifications.
2424
2525
## Pre-requisites
2626
To use this endpoint, you must be an authenticated e-RS user and use one of the following e-RS roles:

tests/sandbox/stu3/test_a006_get_attachment.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ class TestGetAttachment(SandboxTest):
2222
required_business_functions=allowed_business_function_data
2323
)
2424

25-
testdata = [
25+
valid_test_data = [
2626
(
2727
"att-70000-70001",
2828
"stu3/retrieveAttachment/responses/example_attachment.pdf",
2929
"example_attachment.pdf",
3030
),
3131
(
32-
"c5d2d200-7613-4a69-9c5f-1bb68e04b8d8",
32+
# Any arbitrary v4 UUID should work here
33+
"f1b1b2b1-30db-48f9-8906-8b703adca5fb",
3334
"stu3/retrieveAttachment/responses/example_attachment.pdf",
3435
"example_attachment.pdf",
3536
),
@@ -63,7 +64,7 @@ def call_endpoint(
6364
)
6465

6566
@pytest.mark.parametrize("actor", authorised_actor_data)
66-
@pytest.mark.parametrize("id,response, filename", testdata)
67+
@pytest.mark.parametrize("id,response, filename", valid_test_data)
6768
def test_success(
6869
self,
6970
call_endpoint_url_with_pathParams: Callable[
@@ -90,3 +91,16 @@ def test_success(
9091
"content-length": str(len(expected_response)),
9192
},
9293
)
94+
95+
@pytest.mark.parametrize("actor", authorised_actor_data)
96+
def test_failure_not_a_uuid(
97+
self,
98+
call_endpoint_url_with_pathParams: Callable[
99+
[Actor, Dict[str, str], Dict[str, str]], Response
100+
],
101+
actor: Actor,
102+
):
103+
response = call_endpoint_url_with_pathParams(
104+
actor, {"attachmentLogicalID": "f1bb2b1-30db-48f9-8906-8b703adca5fb"}
105+
)
106+
asserts.assert_status_code(404, response.status_code)

0 commit comments

Comments
 (0)