Skip to content

Commit

Permalink
Review address
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarGi committed Apr 16, 2024
1 parent 0b1816f commit cf9e4ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ public static function getPermissionsRoleIdByName(
}

/**
* Get the role id by name
* Get the role name by role id
*
* @param string $permissionsRoleId
*
Expand Down
11 changes: 6 additions & 5 deletions tests/acceptance/features/apiSharingNg/listPermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -561,24 +561,25 @@ Feature: List a sharing permissions
}
"""


Scenario: user send share invitation for all allowed roles defined in permission lists for a file
@issues-8331
Scenario: user sends share invitation with all allowed roles for a file
Given user "Alice" has uploaded file with content "hello text" to "textfile.txt"
And user "Brian" has been created with default attributes and without skeleton files
When user "Alice" gets permissions list for file "textfile.txt" of the space "Personal" using the Graph API
Then the HTTP status code should be "200"
And user "Alice" should be able to send share invitation with all allowed permission roles from the above response:
And user "Alice" should be able to send share invitation with all allowed permission roles
| resource | textfile.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |

Scenario: user send share invitation for all allowed roles defined in permission lists for a folder
@issues-8331
Scenario: user sends share invitation with all allowed roles for a folder
Given user "Alice" has created folder "folder"
And user "Brian" has been created with default attributes and without skeleton files
When user "Alice" gets permissions list for folder "folder" of the space "Personal" using the Graph API
Then the HTTP status code should be "200"
And user "Alice" should be able to send share invitation with all allowed permission roles from the above response:
And user "Alice" should be able to send share invitation with all allowed permission roles
| resource | folder |
| space | Personal |
| sharee | Brian |
Expand Down
12 changes: 5 additions & 7 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string
}

/**
* @Then user :user should be able to send share invitation with all allowed permission roles from the above response:
* @Then user :user should be able to send share invitation with all allowed permission roles
*
* @param string $user
* @param TableNode $table
Expand All @@ -678,17 +678,16 @@ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function userCanSendShareInvitationToUserWithAllAllowedPermissionRolesForFolder(string $user, TableNode $table): void {
public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
Assert::fail(
'The response' . $listPermissionResponse .
'does not contain any @libre.graph.permissions.roles.allowedValues'
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" . $listPermissionResponse
);
}
Assert::assertNotEmpty(
$listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'},
'@libre.graph.permissions.roles.allowedValues in the response should not be empty!'
"'@libre.graph.permissions.roles.allowedValues' should not be empty"
);
$allowedPermissionRoles = $listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'};
// this info is needed for log to see which roles allowed and which were not when tests fail
Expand All @@ -705,13 +704,12 @@ public function userCanSendShareInvitationToUserWithAllAllowedPermissionRolesFor
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation);
$httpsStatusCode = $responseSendInvitation->getStatusCode();
if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) {
$shareInvitationRequestResult = $shareInvitationRequestResult . "\tShare invitation for resource '" . $resource . "' with role '" . $roleAllowed . "' was allowed.\n";
// remove the share so that the same user can be share for the next allowed roles
$removePermissionsResponse = $this->removeSharePermission($user, $shareType, $space, $resource);
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
} else {
$areAllSendInvitationSuccessFullForAllowedRoles = false;
$shareInvitationRequestResult = $shareInvitationRequestResult . "\tShare invitation for resource '" . $resource . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
$shareInvitationRequestResult .= "\tShare invitation for resource '" . $resource . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
}
}
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
Expand Down

0 comments on commit cf9e4ce

Please sign in to comment.