Skip to content

Commit 169e780

Browse files
authored
Merge pull request #60 from NHSDigital/NPA-2777_Update_Sandbox
NPA-2797 Update Sandbox for All Errors Have Correct Mime Type
2 parents 996b2ff + 007c9b4 commit 169e780

File tree

5 files changed

+77
-15
lines changed

5 files changed

+77
-15
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<AssignMessage async="false" continueOnError="false" enabled="true" name="SetMimeType">
3+
<DisplayName>Set Mime Type</DisplayName>
4+
<Set>
5+
<Headers>
6+
<Header name="Content-Type">application/fhir+json</Header>
7+
</Headers>
8+
</Set>
9+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
10+
<AssignTo createNew="false" transport="http" type="response"/>
11+
</AssignMessage>

proxies/sandbox/apiproxy/policies/RaiseFault.400BadRequest.xml

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

proxies/sandbox/apiproxy/policies/RaiseFault.401Unauthorized.xml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
This policy raises a 401 error response for an invalid or missing access token.
4+
5+
Raisefault policies stop the execution of the current flow and move to the error flow, which returns the error response defined here to the requesting application.
6+
7+
For more information on RaiseFault policies within Apigee see the following resource:
8+
* https://docs.apigee.com/api-platform/reference/policies/raise-fault-policy
9+
-->
210
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.401Unauthorized">
311
<DisplayName>RaiseFault.401Unauthorized</DisplayName>
412
<Properties/>
513
<FaultResponse>
614
<Set>
7-
<Headers/>
8-
<Payload contentType="text/plain"/>
15+
<Headers>
16+
<Header name="Content-Type">application/fhir+json</Header>
17+
</Headers>
918
<StatusCode>401</StatusCode>
10-
<ReasonPhrase>Access Denied</ReasonPhrase>
19+
<ReasonPhrase>Unauthorized</ReasonPhrase>
20+
<Payload>
21+
{
22+
"issue": [
23+
{
24+
"code": "forbidden",
25+
"details": {
26+
"coding": [
27+
{
28+
"code": "ACCESS_DENIED",
29+
"display": "Missing or invalid OAuth 2.0 bearer token in request.",
30+
"system": "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode",
31+
"version": "1"
32+
}
33+
]
34+
},
35+
"diagnostics": "Invalid access token - Access Denied.",
36+
"severity": "error"
37+
}
38+
],
39+
"resourceType": "OperationOutcome"
40+
}
41+
</Payload>
1142
</Set>
1243
</FaultResponse>
1344
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
This policy raises when an error occurs in the AWS Application.
4+
5+
Raisefault policies stop the execution of the current flow and move to the error flow, which returns the error response defined here to the requesting application.
6+
7+
For more information on RaiseFault policies within Apigee see the following resource:
8+
* https://docs.apigee.com/api-platform/reference/policies/raise-fault-policy
9+
-->
10+
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.DefaultError">
11+
<DisplayName>RaiseFault.DefaultError</DisplayName>
12+
<Properties/>
13+
<FaultResponse>
14+
<Set>
15+
<Headers>
16+
<Header name="Content-Type">application/fhir+json</Header>
17+
</Headers>
18+
</Set>
19+
</FaultResponse>
20+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
21+
</RaiseFault>

proxies/sandbox/apiproxy/targets/sandbox.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
<FaultRules/>
44
<Flows/>
55
<PostFlow name="PostFlow">
6-
<Request/>
7-
<Response/>
6+
<Response>
7+
<Step>
8+
<Name>SetMimeType</Name>
9+
</Step>
10+
</Response>
811
</PostFlow>
912
<PreFlow name="PreFlow">
1013
<Request/>
@@ -17,6 +20,12 @@
1720
</Step>
1821
</Response>
1922
</PreFlow>
23+
<DefaultFaultRule name="DefaultFaultRule">
24+
<Step>
25+
<Name>RaiseFault.DefaultError</Name>
26+
</Step>
27+
<AlwaysEnforce>true</AlwaysEnforce>
28+
</DefaultFaultRule>
2029
<HTTPTargetConnection>
2130
{{ HOSTED_TARGET_CONNECTION }}
2231
</HTTPTargetConnection>

0 commit comments

Comments
 (0)