diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index feb522bb634..94de2d8f9c4 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -1983,4 +1983,31 @@ public static function enableShareSync( \json_encode($body) ); } + + /** + * @param string $baseUrl + * @param string $xRequestId + * @param string $user + * @param string $password + * @param string $spaceId + * + * @return ResponseInterface + * @throws GuzzleException + */ + public static function getDrivePermissionsList( + string $baseUrl, + string $xRequestId, + string $user, + string $password, + string $spaceId + ): ResponseInterface { + $url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/permissions"); + return HttpRequestHelper::get( + $url, + $xRequestId, + $user, + $password, + self::getRequestHeaders() + ); + } } diff --git a/tests/acceptance/features/apiSharingNg/listPermissions.feature b/tests/acceptance/features/apiSharingNg/listPermissions.feature index 7ba893df543..a642defa3c5 100644 --- a/tests/acceptance/features/apiSharingNg/listPermissions.feature +++ b/tests/acceptance/features/apiSharingNg/listPermissions.feature @@ -913,3 +913,169 @@ Feature: List a sharing permissions | space | Personal | | sharee | Brian | | shareType | user | + + @issues-8351 + Scenario: user lists permissions of a project space using root endpoint + Given using spaces DAV path + 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 root endpoint of 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": 3, + "maxItems": 3, + "uniqueItems": true, + "items": { + "oneOf": [ + { + "type": "object", + "required": [ + "@libre.graph.weight", + "description", + "displayName", + "id" + ], + "properties": { + "@libre.graph.weight": { + "const": 1 + }, + "description": { + "const": "View and download." + }, + "displayName": { + "const": "Can view" + }, + "id": { + "const": "a8d5fe5e-96e3-418d-825b-534dbdf22b99" + } + } + }, + { + "type": "object", + "required": [ + "@libre.graph.weight", + "description", + "displayName", + "id" + ], + "properties": { + "@libre.graph.weight": { + "const": 2 + }, + "description": { + "const": "View, download, upload, edit, add and delete." + }, + "displayName": { + "const": "Can edit" + }, + "id": { + "const": "58c63c02-1d89-4572-916a-870abc5a1b7d" + } + } + }, + { + "type": "object", + "required": [ + "@libre.graph.weight", + "description", + "displayName", + "id" + ], + "properties": { + "@libre.graph.weight": { + "const": 3 + }, + "description": { + "const": "View, download, upload, edit, add, delete and manage members." + }, + "displayName": { + "const": "Can manage" + }, + "id": { + "const": "312c0871-5ef7-4b3a-85b6-0e4074c64049" + } + } + } + ] + } + } + } + } + """ + + + Scenario Outline: try to lists the permissions of a Personal/Shares drive using root endpoint + Given using spaces DAV path + 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" tries to list the permissions of space "" using root endpoint of the Graph API + Then the HTTP status code should be "400" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["error"], + "properties": { + "error": { + "type": "object", + "required": [ + "code", + "innererror", + "message" + ], + "properties": { + "code": { + "const": "invalidRequest" + }, + "innererror": { + "type": "object", + "required": [ + "date", + "request-id" + ] + }, + "message": { + "const": "unsupported space type" + } + } + } + } + } + """ + Examples: + | drive | + | Personal | + | Shares | diff --git a/tests/acceptance/features/apiSharingNg/sharedWithMe.feature b/tests/acceptance/features/apiSharingNg/sharedWithMe.feature index 90e8f40c255..9484a419e1d 100755 --- a/tests/acceptance/features/apiSharingNg/sharedWithMe.feature +++ b/tests/acceptance/features/apiSharingNg/sharedWithMe.feature @@ -19,7 +19,7 @@ Feature: an user gets the resources shared to them | space | Personal | | sharee | Brian | | shareType | user | - | permissionsRole | Viewer | + | permissionsRole | Viewer | When user "Brian" lists the shares shared with him after clearing user cache using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match @@ -3540,7 +3540,7 @@ Feature: an user gets the resources shared to them } """ - + @issue-8027 Scenario: user lists the file shared with them from project space Given using spaces DAV path And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 815ae6d64fa..ebb45afa96d 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -21,6 +21,7 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use GuzzleHttp\Exception\GuzzleException; use Psr\Http\Message\ResponseInterface; use TestHelpers\GraphHelper; use TestHelpers\WebDavHelper; @@ -60,7 +61,7 @@ public function before(BeforeScenarioScope $scope): void { * * @return ResponseInterface * @throws Exception - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function createLinkShare(string $user, TableNode $body): ResponseInterface { $bodyRows = $body->getRowsHash(); @@ -159,7 +160,7 @@ public function userListsThePermissionsOfSpaceUsingTheGraphApi($user, $space):vo * @return ResponseInterface * * @throws JsonException - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException * @throws Exception */ public function sendShareInvitation(string $user, TableNode $table, string $fileId = null): ResponseInterface { @@ -230,7 +231,7 @@ public function sendShareInvitation(string $user, TableNode $table, string $file * * @return void * @throws Exception - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userHasSentTheFollowingShareInvitation(string $user, TableNode $table): void { $response = $this->sendShareInvitation($user, $table); @@ -247,7 +248,7 @@ public function userHasSentTheFollowingShareInvitation(string $user, TableNode $ * * @return void * @throws Exception - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $user, TableNode $table): void { $this->featureContext->setResponse( @@ -319,7 +320,7 @@ public function updateResourceShare(string $user, TableNode $body, string $perm * * @return void * @throws JsonException - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(string $user, string $fileId, TableNode $table): void { $this->featureContext->setResponse( @@ -334,7 +335,7 @@ public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(s * @param TableNode|null $body * * @return void - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body):void { $response = $this->createLinkShare($user, $body); @@ -348,7 +349,7 @@ public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode * @param TableNode|null $body * * @return void - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $body): void { $response = $this->createLinkShare($user, $body); @@ -418,7 +419,7 @@ public function updateLinkShare(string $user, TableNode $body, string $permissi * * @return void * @throws Exception - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(string $user, TableNode $body):void { $bodyRows = $body->getRowsHash(); @@ -495,7 +496,7 @@ public function removeSharePermission( * * @return void * @throws JsonException - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI( string $sharer, @@ -519,7 +520,7 @@ public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI * * @return void * @throws JsonException - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userRemovesSharePermissionOfUserFromSpaceUsingGraphAPI( string $sharer, @@ -641,7 +642,7 @@ public function userEnablesSyncOfShareUsingTheGraphApi(string $user, string $sha * @param string $resource * * @return void - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string $status, string $resource):void { $response = GraphHelper::getSharesSharedWithMe( @@ -676,7 +677,7 @@ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string * * @return void * @throws Exception - * @throws \GuzzleHttp\Exception\GuzzleException + * @throws GuzzleException */ public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void { $listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent(); @@ -714,4 +715,28 @@ public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRol } Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult); } + + /** + * @When /^user "([^"]*)" (?:tries to list|lists) the permissions of space "([^"]*)" using root endpoint of the Graph API$/ + * + * @param string $user + * @param string $space + * + * @return void + * @throws Exception + * @throws GuzzleException + * + */ + public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(string $user, string $space):void { + $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; + + $response = GraphHelper::getDrivePermissionsList( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $spaceId + ); + $this->featureContext->setResponse($response); + } }