You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cosmos DB: Added Authorization related tests (#2034)
## Why make this change?
No Code Change as of Now.
## What is this change?
Added tests to cover scenarios related to auth in cosmos DB, with below
config changes:
a) Added different combinations of role for `Earth` entity
b) Removed `Anonymous` role for `Earth` entity
**NOTE:** Item level authorization tests are not covered here.
## How was this tested?
- [x] Integration Tests
- [ ] Unit Tests
[DataRow("field-mutation-with-read-permission",DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE,DisplayName="AuthZ failure for create mutation because of reference to excluded/disallowed fields.")]
263
+
[DataRow("authenticated",MutationTests.NO_ERROR_MESSAGE,DisplayName="AuthZ success when role has no create/read operation restrictions.")]
264
+
[DataRow("only-create-role","The mutation operation createEarth was successful "+
265
+
"but the current user is unauthorized to view the response due to lack of read permissions",DisplayName="Successful create operation but AuthZ failure for read when role has ONLY create permission and NO read permission.")]
266
+
[DataRow("wildcard-exclude-fields-role",DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE,DisplayName="AuthZ failure for create mutation because of reference to excluded/disallowed field using wildcard.")]
267
+
[DataRow("only-update-role",MutationTests.USER_NOT_AUTHORIZED,DisplayName="AuthZ failure when create permission is NOT there.")]
[DataRow("field-mutation-with-read-permission",DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE,DisplayName="AuthZ failure for update mutation because of reference to excluded/disallowed fields.")]
303
+
[DataRow("authenticated",NO_ERROR_MESSAGE,DisplayName="AuthZ success when role has no update/read operation restrictions.")]
304
+
[DataRow("only-update-role","The mutation operation updateEarth was successful "+
305
+
"but the current user is unauthorized to view the response due to lack of read permissions",DisplayName="AuthZ failure but sucessful operation where role has ONLY update permission and NO read permission.")]
306
+
[DataRow("wildcard-exclude-fields-role",DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE,DisplayName="AuthZ failure for update mutation because of reference to excluded/disallowed field using wildcard.")]
307
+
[DataRow("only-create-role",MutationTests.USER_NOT_AUTHORIZED,DisplayName="AuthZ failure when update permission is NOT there.")]
/// Delete Mutation performed on the fields with different auth permissions
366
+
/// It throws permission denied error if role doesn't have permission to perform the operation
367
+
/// </summary>
368
+
[TestMethod]
369
+
[DataRow("field-mutation-with-read-permission",MutationTests.NO_ERROR_MESSAGE,DisplayName="AuthZ success and blank response for delete mutation because of reference to excluded/disallowed fields.")]
370
+
[DataRow("authenticated",MutationTests.NO_ERROR_MESSAGE,DisplayName="AuthZ success and blank response when role has no delete operation restrictions.")]
371
+
[DataRow("only-delete-role","The mutation operation deleteEarth was successful "+
372
+
"but the current user is unauthorized to view the response due to lack of read permissions",DisplayName="AuthZ failure but sucessful operation where role has ONLY delete permission and NO read permission.")]
373
+
[DataRow("wildcard-exclude-fields-role",MutationTests.NO_ERROR_MESSAGE,DisplayName="AuthZ success and blank response for delete mutation because of reference to excluded/disallowed fields using wildcard")]
374
+
[DataRow("only-create-role",MutationTests.USER_NOT_AUTHORIZED,DisplayName="AuthZ failure when delete permission is NOT there.")]
0 commit comments