[tests-only][full-ci] List permission and share a project space with allowed roles (#8959)
* List permission and share a project space with allowed roles Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com> * Review addres Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com> --------- Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
This commit is contained in:
@@ -1668,8 +1668,14 @@ class GraphHelper {
|
|||||||
return 'File Editor';
|
return 'File Editor';
|
||||||
case '1c996275-f1c9-4e71-abdf-a42f6495e960':
|
case '1c996275-f1c9-4e71-abdf-a42f6495e960':
|
||||||
return 'Uploader';
|
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:
|
default:
|
||||||
throw new \Exception('Role ' . $permissionsRoleId . ' not found');
|
throw new \Exception('Permission role id: ' . $permissionsRoleId . ' not found');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -896,7 +896,7 @@ Feature: List a sharing permissions
|
|||||||
And user "Brian" has been created with default attributes and without skeleton files
|
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
|
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"
|
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 |
|
| resource | textfile.txt |
|
||||||
| space | Personal |
|
| space | Personal |
|
||||||
| sharee | Brian |
|
| sharee | Brian |
|
||||||
@@ -908,7 +908,7 @@ Feature: List a sharing permissions
|
|||||||
And user "Brian" has been created with default attributes and without skeleton files
|
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
|
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"
|
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 |
|
| resource | folder |
|
||||||
| space | Personal |
|
| space | Personal |
|
||||||
| sharee | Brian |
|
| sharee | Brian |
|
||||||
@@ -1081,6 +1081,19 @@ Feature: List a sharing permissions
|
|||||||
| Shares |
|
| 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
|
Scenario: user sends share invitation with all allowed roles for a file in project space
|
||||||
Given using spaces DAV path
|
Given using spaces DAV path
|
||||||
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
|
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
|
||||||
@@ -1089,7 +1102,7 @@ Feature: List a sharing permissions
|
|||||||
And user "Brian" has been created with default attributes and without skeleton files
|
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
|
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"
|
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 |
|
| resource | textfile.txt |
|
||||||
| space | new-space |
|
| space | new-space |
|
||||||
| sharee | Brian |
|
| sharee | Brian |
|
||||||
@@ -1311,7 +1324,7 @@ Feature: List a sharing permissions
|
|||||||
And user "Brian" has been created with default attributes and without skeleton files
|
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
|
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"
|
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 |
|
| resource | folder |
|
||||||
| space | new-space |
|
| space | new-space |
|
||||||
| sharee | Brian |
|
| sharee | Brian |
|
||||||
|
|||||||
@@ -800,7 +800,7 @@ class SharingNgContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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 string $user
|
||||||
* @param TableNode $table
|
* @param TableNode $table
|
||||||
@@ -809,7 +809,7 @@ class SharingNgContext implements Context {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
|
public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
|
||||||
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
|
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
|
||||||
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
|
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
|
||||||
Assert::fail(
|
Assert::fail(
|
||||||
@@ -825,9 +825,12 @@ class SharingNgContext implements Context {
|
|||||||
$shareInvitationRequestResult = "From the given allowed role lists from the permissions:\n";
|
$shareInvitationRequestResult = "From the given allowed role lists from the permissions:\n";
|
||||||
$areAllSendInvitationSuccessFullForAllowedRoles = true;
|
$areAllSendInvitationSuccessFullForAllowedRoles = true;
|
||||||
$rows = $table->getRowsHash();
|
$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'];
|
$shareType = $rows['shareType'];
|
||||||
$space = $rows['space'];
|
$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) {
|
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)
|
//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);
|
$roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
|
||||||
@@ -840,7 +843,7 @@ class SharingNgContext implements Context {
|
|||||||
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
|
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
|
||||||
} else {
|
} else {
|
||||||
$areAllSendInvitationSuccessFullForAllowedRoles = false;
|
$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);
|
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
|
||||||
|
|||||||
Reference in New Issue
Block a user