Skip to content

Commit

Permalink
List permission and share a project space with allowed roles
Browse files Browse the repository at this point in the history
Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
  • Loading branch information
SagarGi committed Apr 25, 2024
1 parent 5cc4c78 commit 12278fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
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
13 changes: 13 additions & 0 deletions tests/acceptance/features/apiSharingNg/listPermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,19 @@ Feature: List a sharing permissions
| Shares |


Scenario: space admin share invitation with all allowed roles for a project space
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 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
| 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 Down
9 changes: 6 additions & 3 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function userListsThePermissionsOfSpaceUsingTheGraphApi($user, $space):vo
public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner):void {
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$itemId = $this->spacesContext->getResourceId($spaceOwner, $space, '');

$this->featureContext->setResponse(
GraphHelper::getPermissionsList(
$this->featureContext->getBaseUrl(),
Expand Down Expand Up @@ -821,9 +821,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 @@ -836,7 +839,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

0 comments on commit 12278fb

Please sign in to comment.