Skip to content

Commit 8410bd3

Browse files
NPA-4699: Updated scripts to account not break api tests
1 parent 33fc5a3 commit 8410bd3

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
path_suffix = flow.getVariable("proxy.pathsuffix").lower()
22
request_verb = flow.getVariable("request.verb").lower()
33

4-
blocked_resources = [
5-
("/fhir/r4/relatedperson", "get"),
6-
("/fhir/r4/questionnaire", "get"),
7-
("/fhir/r4/questionnaireresponse", "post"),
8-
("/fhir/r4/questionnaireresponse", "get"),
9-
("/fhir/r4/consent", "post"),
10-
("/fhir/r4/consent", "patch"),
11-
]
12-
134
auth_forbidden = False
14-
for blocked_resources in blocked_resources:
15-
if blocked_resources[0] in path_suffix and blocked_resources[1] == request_verb:
16-
auth_forbidden = True
5+
if request_verb == "patch":
6+
# Check blocked endpoint is within path suffix i.e. ignore path parameters
7+
blocked_resources = ["/fhir/r4/consent"]
8+
for blocked_resource in blocked_resources:
9+
if blocked_resource in path_suffix:
10+
auth_forbidden = True
11+
else:
12+
# Check blocked endpoint is equal to path suffix
13+
requested_resource = (path_suffix, request_verb)
14+
blocked_resources = [
15+
("/fhir/r4/relatedperson", "get"),
16+
("/fhir/r4/questionnaire", "get"),
17+
("/fhir/r4/questionnaireresponse", "post"),
18+
("/fhir/r4/questionnaireresponse", "get"),
19+
("/fhir/r4/consent", "post"),
20+
]
21+
auth_forbidden = requested_resource in blocked_resources
1722

1823
flow.setVariable("app_auth_forbidden", auth_forbidden)

proxies/live/apiproxy/resources/py/check-user-enabled-endpoint.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
path_suffix = flow.getVariable("proxy.pathsuffix").lower()
33
request_verb = flow.getVariable("request.verb").lower()
44

5+
requested_resource = (path_suffix, request_verb)
6+
57
if auth_level == "p9":
68
blocked_resources = [
79
("/fhir/r4/questionnaire", "get"),
@@ -12,9 +14,6 @@
1214
else:
1315
blocked_resources = []
1416

15-
auth_forbidden = False
16-
for blocked_resources in blocked_resources:
17-
if blocked_resources[0] in path_suffix and blocked_resources[1] == request_verb:
18-
auth_forbidden = True
17+
auth_forbidden = requested_resource in blocked_resources
1918

2019
flow.setVariable("user_auth_forbidden", auth_forbidden)

0 commit comments

Comments
 (0)