Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] List permission and share a project space with allowed roles #8959

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1668,8 +1668,14 @@ public static function getPermissionNameByPermissionRoleId(
return 'File Editor';
case '1c996275-f1c9-4e71-abdf-a42f6495e960':
return 'Uploader';
case 'a8d5fe5e-96e3-418d-825b-534dbdf22b99':
return 'Space Viewer';
case '58c63c02-1d89-4572-916a-870abc5a1b7d':
return 'Space Editor';
case '312c0871-5ef7-4b3a-85b6-0e4074c64049':
return 'Manager';
default:
throw new \Exception('Role ' . $permissionsRoleId . ' not found');
throw new \Exception('Permission role id: ' . $permissionsRoleId . ' not found');
}
}

Expand Down
21 changes: 17 additions & 4 deletions tests/acceptance/features/apiSharingNg/listPermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ Feature: List a sharing permissions
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
And user "Alice" should be able to send share the following invitation with all allowed permission roles
| resource | textfile.txt |
| space | Personal |
| sharee | Brian |
Expand All @@ -908,7 +908,7 @@ Feature: List a sharing permissions
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
And user "Alice" should be able to send share the following invitation with all allowed permission roles
| resource | folder |
| space | Personal |
| sharee | Brian |
Expand Down Expand Up @@ -1081,6 +1081,19 @@ Feature: List a sharing permissions
| Shares |


Scenario: space admin invites to a project space with all allowed roles
Given using spaces DAV path
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "new-space" with the default quota using the Graph API
And user "Brian" has been created with default attributes and without skeleton files
When user "Alice" lists the permissions of space "new-space" using permissions endpoint of the Graph API
Then the HTTP status code should be "200"
And user "Alice" should be able to send share the following invitation with all allowed permission roles
| space | new-space |
| sharee | Brian |
| shareType | user |


Scenario: user sends share invitation with all allowed roles for a file in project space
Given using spaces DAV path
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
Expand All @@ -1089,7 +1102,7 @@ Feature: List a sharing permissions
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 "new-space" 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
And user "Alice" should be able to send share the following invitation with all allowed permission roles
| resource | textfile.txt |
| space | new-space |
| sharee | Brian |
Expand Down Expand Up @@ -1311,7 +1324,7 @@ Feature: List a sharing permissions
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 "new-space" 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
And user "Alice" should be able to send share the following invitation with all allowed permission roles
| resource | folder |
| space | new-space |
| sharee | Brian |
Expand Down
11 changes: 7 additions & 4 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string
}

/**
* @Then user :user should be able to send share invitation with all allowed permission roles
* @Then user :user should be able to send share the following invitation with all allowed permission roles
*
* @param string $user
* @param TableNode $table
Expand All @@ -809,7 +809,7 @@ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string
* @throws Exception
* @throws GuzzleException
*/
public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
Assert::fail(
Expand All @@ -825,9 +825,12 @@ public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRol
$shareInvitationRequestResult = "From the given allowed role lists from the permissions:\n";
$areAllSendInvitationSuccessFullForAllowedRoles = true;
$rows = $table->getRowsHash();
$resource = $rows['resource'];
// when sending share invitation for a project space, the resource to be shared is project space itself. So resource can be put as empty
$resource = $rows['resource'] ?? '';
$shareType = $rows['shareType'];
$space = $rows['space'];
//this details is needed for result logging purpose to determine whether the resource shared is a resource or a project space
$resourceDetail = ($resource) ? "resource '" . $resource : "space '" . $space;
foreach ($allowedPermissionRoles as $role) {
//we should be able to send share invitation for each of the role allowed for the files/folders which are listed in permissions (allowed)
$roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
Expand All @@ -840,7 +843,7 @@ public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRol
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
} else {
$areAllSendInvitationSuccessFullForAllowedRoles = false;
$shareInvitationRequestResult .= "\tShare invitation for resource '" . $resource . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
$shareInvitationRequestResult .= "\tShare invitation for " . $resourceDetail . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
}
}
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
Expand Down