diff --git a/tests/acceptance/features/apiSharingNg/listPermissions.feature b/tests/acceptance/features/apiSharingNg/listPermissions.feature index 65ecfee70a7..9c70cb1251d 100644 --- a/tests/acceptance/features/apiSharingNg/listPermissions.feature +++ b/tests/acceptance/features/apiSharingNg/listPermissions.feature @@ -199,3 +199,149 @@ Feature: List a sharing permissions } } """ + + + Scenario: user lists permissions of a project space + Given using spaces DAV path + And user "Brian" has been created with default attributes and without skeleton files + And the administrator has assigned the role "Space 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 + When user "Alice" lists the permissions of space "new-space" using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@libre.graph.permissions.actions.allowedValues", + "@libre.graph.permissions.roles.allowedValues" + ], + "properties": { + "@libre.graph.permissions.actions.allowedValues": { + "const": [ + "libre.graph/driveItem/permissions/create", + "libre.graph/driveItem/children/create", + "libre.graph/driveItem/standard/delete", + "libre.graph/driveItem/path/read", + "libre.graph/driveItem/quota/read", + "libre.graph/driveItem/content/read", + "libre.graph/driveItem/upload/create", + "libre.graph/driveItem/permissions/read", + "libre.graph/driveItem/children/read", + "libre.graph/driveItem/versions/read", + "libre.graph/driveItem/deleted/read", + "libre.graph/driveItem/path/update", + "libre.graph/driveItem/permissions/delete", + "libre.graph/driveItem/deleted/delete", + "libre.graph/driveItem/versions/update", + "libre.graph/driveItem/deleted/update", + "libre.graph/driveItem/basic/read", + "libre.graph/driveItem/permissions/update", + "libre.graph/driveItem/permissions/deny" + ] + }, + "@libre.graph.permissions.roles.allowedValues": { + "type": "array", + "minItems": 4, + "maxItems": 4, + "uniqueItems": true, + "items": { + "oneOf": [ + { + "type": "object", + "required": [ + "@libre.graph.weight", + "description", + "displayName", + "id" + ], + "properties": { + "@libre.graph.weight": { + "const": 1 + }, + "description": { + "const": "Allows reading the shared space" + }, + "displayName": { + "const": "Space Viewer" + }, + "id": { + "const": "a8d5fe5e-96e3-418d-825b-534dbdf22b99" + } + } + }, + { + "type": "object", + "required": [ + "@libre.graph.weight", + "description", + "displayName", + "id" + ], + "properties": { + "@libre.graph.weight": { + "const": 2 + }, + "description": { + "const": "Allows creating, reading, updating and deleting file or folder in the shared space" + }, + "displayName": { + "const": "Space Editor" + }, + "id": { + "const": "58c63c02-1d89-4572-916a-870abc5a1b7d" + } + } + }, + { + "type": "object", + "required": [ + "@libre.graph.weight", + "description", + "displayName", + "id" + ], + "properties": { + "@libre.graph.weight": { + "const": 3 + }, + "description": { + "const": "Grants co-owner permissions on a resource" + }, + "displayName": { + "const": "Co Owner" + }, + "id": { + "const": "3a4ba8e9-6a0d-4235-9140-0e7a34007abe" + } + } + }, + { + "type": "object", + "required": [ + "@libre.graph.weight", + "description", + "displayName", + "id" + ], + "properties": { + "@libre.graph.weight": { + "const": 4 + }, + "description": { + "const": "Grants manager permissions on a resource. Semantically equivalent to co-owner" + }, + "displayName": { + "const": "Manager" + }, + "id": { + "const": "312c0871-5ef7-4b3a-85b6-0e4074c64049" + } + } + } + ] + } + } + } + } + """ \ No newline at end of file diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index bd33bc41670..85e2edae0c8 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -92,17 +92,15 @@ public function createLinkShare(string $user, TableNode $body): ResponseInterfac } /** - * @When /^user "([^"]*)" gets permissions list for (folder|file) "([^"]*)" of the space "([^"]*)" using the Graph API$/ - * * @param string $user * @param string $fileOrFolder (file|folder) * @param string $resource * @param string $space * - * @return void + * @return ResponseInterface * @throws Exception */ - public function theUserPermissionsListOfResource(string $user, string $fileOrFolder, string $resource, string $space):void { + public function getPermissionsList(string $user, string $fileOrFolder, string $resource, string $space):ResponseInterface { $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; if ($fileOrFolder === 'folder') { @@ -110,15 +108,46 @@ public function theUserPermissionsListOfResource(string $user, string $fileOrFol } else { $itemId = $this->spacesContext->getFileId($user, $space, $resource); } + + return GraphHelper::getPermissionsList( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $spaceId, + $itemId + ); + } + + /** + * @When /^user "([^"]*)" gets permissions list for (folder|file) "([^"]*)" of the space "([^"]*)" using the Graph API$/ + * + * @param string $user + * @param string $fileOrFolder (file|folder) + * @param string $resource + * @param string $space + * + * @return void + * @throws Exception + */ + public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphiAPI(string $user, string $fileOrFolder, string $resource, string $space):void { $this->featureContext->setResponse( - GraphHelper::getPermissionsList( - $this->featureContext->getBaseUrl(), - $this->featureContext->getStepLineRef(), - $user, - $this->featureContext->getPasswordForUser($user), - $spaceId, - $itemId - ) + $this->userGetsPermissionsListOfResourceOrSpace($user, $fileOrFolder, $resource, $space) + ); + } + + /** + * @When /^user "([^"]*)" lists the permissions of space "([^"]*)" using the Graph API$/ + * + * @param string $user + * @param string $space + * + * @return void + * @throws Exception + */ + public function userListsThePermissionsOfSpaceUsingTheGraphApi($user, $space):void { + $this->featureContext->setResponse( + $this->userGetsPermissionsListOfResourceOrSpace($user, 'folder', '', $space) ); }