Skip to content

Commit b4fcf4f

Browse files
Steve Buxtonnhsd-angel-pastor
authored andcommitted
[ERSSUP-78090]-[AP]-[Make getAttachment always return something for a valid UUID]-[SB]
1 parent c1f9a36 commit b4fcf4f

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
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) {

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)