Skip to content

Commit bcb5bbd

Browse files
committed
updated display names
1 parent aee662e commit bcb5bbd

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/Service.Tests/CosmosTests/MutationTests.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class MutationTests : TestBase
3939
name
4040
}
4141
}";
42+
private const string USER_NOT_AUTHORIZED = "The current user is not authorized to access this resource";
43+
private const string NO_ERROR_MESSAGE = null;
4244

4345
/// <summary>
4446
/// Executes once for the test.
@@ -257,12 +259,12 @@ public async Task MutationMissingRequiredPartitionKeyValueReturnError()
257259
/// It throws permission denied error if role doesn't have permission to perform the operation
258260
/// </summary>
259261
[TestMethod]
260-
[DataRow("field-mutation-with-read-permission", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = " exclude and include fields")]
261-
[DataRow("authenticated", null, DisplayName = "full permission")]
262+
[DataRow("field-mutation-with-read-permission", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = "When there is limited permission at field level but have full read permission")]
263+
[DataRow("authenticated", MutationTests.NO_ERROR_MESSAGE, DisplayName = "When CRUD permission is there without any restriction")]
262264
[DataRow("only-create-role", "The mutation operation createEarth was successful " +
263-
"but the current user is unauthorized to view the response due to lack of read permissions", DisplayName = "if only create permission is there")]
264-
[DataRow("wildcard-exclude-fields-role", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = "exclude wildcard")]
265-
[DataRow("only-update-role", "The current user is not authorized to access this resource", DisplayName = "if create permission is not there")]
265+
"but the current user is unauthorized to view the response due to lack of read permissions", DisplayName = "When ONLY create permission is there")]
266+
[DataRow("wildcard-exclude-fields-role", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = "When create permission is there at entity level but all the fields are excluded using wildcard")]
267+
[DataRow("only-update-role", MutationTests.USER_NOT_AUTHORIZED, DisplayName = "When create permission is NOT there")]
266268
public async Task CreateItemWithAuthPermissions(string roleName, string expectedErrorMessage)
267269
{
268270
// Run mutation Add Earth;
@@ -297,12 +299,12 @@ public async Task CreateItemWithAuthPermissions(string roleName, string expected
297299
/// It throws permission denied error if role doesn't have permission to perform the operation
298300
/// </summary>
299301
[TestMethod]
300-
[DataRow("field-mutation-with-read-permission", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = "exclude and include fields")]
301-
[DataRow("authenticated", null, DisplayName = "full permission")]
302+
[DataRow("field-mutation-with-read-permission", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = "When there is limited permission at field level but have full read permission")]
303+
[DataRow("authenticated", NO_ERROR_MESSAGE, DisplayName = "When CRUD permission is there without any restriction")]
302304
[DataRow("only-update-role", "The mutation operation updateEarth was successful " +
303-
"but the current user is unauthorized to view the response due to lack of read permissions", DisplayName = "if only update permission is there")]
304-
[DataRow("wildcard-exclude-fields-role", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = "exclude wildcard")]
305-
[DataRow("only-create-role", "The current user is not authorized to access this resource", DisplayName = "if update permission is not there")]
305+
"but the current user is unauthorized to view the response due to lack of read permissions", DisplayName = "When ONLY update permission is there")]
306+
[DataRow("wildcard-exclude-fields-role", DataApiBuilderException.GRAPHQL_MUTATION_FIELD_AUTHZ_FAILURE, DisplayName = "When update permission is there at entity level but all the fields are excluded using wildcard")]
307+
[DataRow("only-create-role", MutationTests.USER_NOT_AUTHORIZED, DisplayName = "When update permission is NOT there")]
306308
public async Task UpdateItemWithAuthPermissions(string roleName, string expectedErrorMessage)
307309
{
308310
// Create an item with "Authenticated" role
@@ -363,13 +365,12 @@ public async Task UpdateItemWithAuthPermissions(string roleName, string expected
363365
/// It throws permission denied error if role doesn't have permission to perform the operation
364366
/// </summary>
365367
[TestMethod]
366-
[DataRow("field-mutation-with-read-permission", null, DisplayName = " exclude and include fields. Response is BLANK")]
367-
[DataRow("authenticated", null, DisplayName = "full permission. Response is BLANK")]
368+
[DataRow("field-mutation-with-read-permission", MutationTests.NO_ERROR_MESSAGE, DisplayName = "When there is limited permission at field level but have full read permission, Response is EMPTY string.")]
369+
[DataRow("authenticated", MutationTests.NO_ERROR_MESSAGE, DisplayName = "When CRUD permission is there without any restriction, Response is EMPTY string.")]
368370
[DataRow("only-delete-role", "The mutation operation deleteEarth was successful " +
369-
"but the current user is unauthorized to view the response due to lack of read permissions", DisplayName = "if only update permission is there")]
370-
[DataRow("wildcard-exclude-fields-role", "The mutation operation deleteEarth was successful " +
371-
"but the current user is unauthorized to view the response due to lack of read permissions", DisplayName = "exclude wildcard")]
372-
[DataRow("only-create-role", "The current user is not authorized to access this resource", DisplayName = "if update permission is not there")]
371+
"but the current user is unauthorized to view the response due to lack of read permissions", DisplayName = "When ONLY delete permission is there")]
372+
[DataRow("wildcard-exclude-fields-role", MutationTests.NO_ERROR_MESSAGE, DisplayName = "When delete permission is there at entity level but all the fields are excluded using wildcard")]
373+
[DataRow("only-create-role", MutationTests.USER_NOT_AUTHORIZED, DisplayName = "When delete permission is NOT there")]
373374
public async Task DeleteItemWithAuthPermissions(string roleName, string expectedErrorMessage)
374375
{
375376
// Create an item with "Authenticated" role
@@ -407,6 +408,8 @@ public async Task DeleteItemWithAuthPermissions(string roleName, string expected
407408
authToken: authtoken,
408409
clientRoleHeader: roleName);
409410

411+
Console.WriteLine(response.ToString());
412+
410413
if (string.IsNullOrEmpty(expectedErrorMessage))
411414
{
412415
Assert.IsTrue(string.IsNullOrEmpty(response.ToString()));

0 commit comments

Comments
 (0)