|
| 1 | +Feature: Producer v2 APP-LEVEL permissions by pointer type - Success and Failure Scenarios |
| 2 | + For the v2 permissions model, permissions are resolved from a JSON file stored in the |
| 3 | + nrlf_permissions Lambda layer. Permissions for the feature tests are baked into the layer by |
| 4 | + `scripts/get_s3_permissions.py` at build time, so no dynamic seeding step is required for |
| 5 | + success scenarios. |
| 6 | + |
| 7 | + Scenario: HAPPY PATH V2 Permissions with access for pointer type - createDocumentReference |
| 8 | + Given the application 'ProducerTest001' (ID 'app-t001') is registered to access the API |
| 9 | + When producer v2 'ORGA' creates a DocumentReference with values: |
| 10 | + | property | value | |
| 11 | + | subject | 9278693472 | |
| 12 | + | status | current | |
| 13 | + | type | 861421000000109 | |
| 14 | + | category | 734163000 | |
| 15 | + | custodian | ORGA | |
| 16 | + | author | HAR1 | |
| 17 | + | url | https://example.org/my-doc.pdf | |
| 18 | + | practiceSetting | 788002001 | |
| 19 | + Then the response status code is 201 |
| 20 | + And the response is an OperationOutcome with 1 issue |
| 21 | + And the OperationOutcome contains the issue: |
| 22 | + """ |
| 23 | + { |
| 24 | + "severity": "information", |
| 25 | + "code": "informational", |
| 26 | + "details": { |
| 27 | + "coding": [ |
| 28 | + { |
| 29 | + "system": "https://fhir.nhs.uk/ValueSet/NRL-ResponseCode", |
| 30 | + "code": "RESOURCE_CREATED", |
| 31 | + "display": "Resource created" |
| 32 | + } |
| 33 | + ] |
| 34 | + }, |
| 35 | + "diagnostics": "The document has been created" |
| 36 | + } |
| 37 | + """ |
| 38 | + And the response has a Location header |
| 39 | + And the Location header starts with '/DocumentReference/ORGA-' |
| 40 | + And the resource in the Location header exists with values: |
| 41 | + | property | value | |
| 42 | + | subject | 9278693472 | |
| 43 | + | status | current | |
| 44 | + | type | 861421000000109 | |
| 45 | + | category | 734163000 | |
| 46 | + | custodian | ORGA | |
| 47 | + | author | HAR1 | |
| 48 | + | url | https://example.org/my-doc.pdf | |
| 49 | + | practiceSetting | 788002001 | |
| 50 | + |
| 51 | + Scenario: V2 Permissions with no producer access at all (but app level consumer access for specified type) |
| 52 | + Given the application 'ProducerTest002' (ID 'app-t002') is registered to access the API |
| 53 | + When producer v2 'ORGA' creates a DocumentReference with values: |
| 54 | + | property | value | |
| 55 | + | subject | 9278693472 | |
| 56 | + | status | current | |
| 57 | + | type | 736366004 | |
| 58 | + | category | 734163000 | |
| 59 | + | custodian | ORGA | |
| 60 | + | author | HAR1 | |
| 61 | + | url | https://example.org/my-doc.pdf | |
| 62 | + | practiceSetting | 788002001 | |
| 63 | + Then the response status code is 403 |
| 64 | + And the response is an OperationOutcome with 1 issue |
| 65 | + And the OperationOutcome contains the issue: |
| 66 | + """ |
| 67 | + { |
| 68 | + "severity": "error", |
| 69 | + "code": "forbidden", |
| 70 | + "details": { |
| 71 | + "coding": [ |
| 72 | + { |
| 73 | + "system": "https://fhir.nhs.uk/CodeSystem/Spine-ErrorOrWarningCode", |
| 74 | + "code": "ACCESS DENIED", |
| 75 | + "display": "Access has been denied to process this request" |
| 76 | + } |
| 77 | + ] |
| 78 | + }, |
| 79 | + "diagnostics": "Your organisation 'ORGA' does not have permission to access this resource. Contact the onboarding team." |
| 80 | + } |
| 81 | + """ |
| 82 | + |
| 83 | + Scenario: V2 Permissions with no access to specified type |
| 84 | + Given the application 'ProducerTest003' (ID 'app-t003') is registered to access the API |
| 85 | + When producer v2 'ORGA' creates a DocumentReference with values: |
| 86 | + | property | value | |
| 87 | + | subject | 9278693472 | |
| 88 | + | status | current | |
| 89 | + | type | 749001000000101 | |
| 90 | + | category | 419891008 | |
| 91 | + | custodian | ORGA | |
| 92 | + | author | HAR1 | |
| 93 | + | url | https://example.org/my-doc.pdf | |
| 94 | + | practiceSetting | 788002001 | |
| 95 | + Then the response status code is 403 |
| 96 | + And the response is an OperationOutcome with 1 issue |
| 97 | + And the OperationOutcome contains the issue: |
| 98 | + """ |
| 99 | + { |
| 100 | + "severity": "error", |
| 101 | + "code": "forbidden", |
| 102 | + "details": { |
| 103 | + "coding": [ |
| 104 | + { |
| 105 | + "system": "https://fhir.nhs.uk/CodeSystem/Spine-ErrorOrWarningCode", |
| 106 | + "code": "AUTHOR_CREDENTIALS_ERROR", |
| 107 | + "display": "Author credentials error" |
| 108 | + } |
| 109 | + ] |
| 110 | + }, |
| 111 | + "diagnostics": "The type of the provided DocumentReference is not in the list of allowed types for this organisation", |
| 112 | + "expression": [ |
| 113 | + "type.coding[0].code" |
| 114 | + ] |
| 115 | + } |
| 116 | + """ |
| 117 | + |
| 118 | + Scenario: V2 Permissions with org-level permissions for requested type but app level permissions for other types |
| 119 | + Given the application 'ProducerTest004' (ID 'app-t004') is registered to access the API |
| 120 | + When producer v2 'ODS1' creates a DocumentReference with values: |
| 121 | + | property | value | |
| 122 | + | subject | 9278693472 | |
| 123 | + | status | current | |
| 124 | + | type | 2181441000000107 | |
| 125 | + | category | 734163000 | |
| 126 | + | custodian | ODS1 | |
| 127 | + | author | HAR1 | |
| 128 | + | url | https://example.org/my-doc.pdf | |
| 129 | + | practiceSetting | 788002001 | |
| 130 | + Then the response status code is 403 |
| 131 | + And the response is an OperationOutcome with 1 issue |
| 132 | + And the OperationOutcome contains the issue: |
| 133 | + """ |
| 134 | + { |
| 135 | + "severity": "error", |
| 136 | + "code": "forbidden", |
| 137 | + "details": { |
| 138 | + "coding": [ |
| 139 | + { |
| 140 | + "system": "https://fhir.nhs.uk/CodeSystem/Spine-ErrorOrWarningCode", |
| 141 | + "code": "AUTHOR_CREDENTIALS_ERROR", |
| 142 | + "display": "Author credentials error" |
| 143 | + } |
| 144 | + ] |
| 145 | + }, |
| 146 | + "diagnostics": "The type of the provided DocumentReference is not in the list of allowed types for this organisation", |
| 147 | + "expression": [ |
| 148 | + "type.coding[0].code" |
| 149 | + ] |
| 150 | + } |
| 151 | + """ |
0 commit comments