From 81bf10b577dcb574c5965cb9250fa0657fb371a9 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Thu, 11 Apr 2024 09:20:00 +0200 Subject: [PATCH] [test-only] remove user/group from space (#8826) * remove user/grop from space * fix after review --- .../apiSharingNg/deletePermissions.feature | 38 +++++++++++++ .../features/bootstrap/SharingNgContext.php | 54 +++++++++++++------ 2 files changed, 77 insertions(+), 15 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/deletePermissions.feature b/tests/acceptance/features/apiSharingNg/deletePermissions.feature index 2cac0783b..68563621a 100644 --- a/tests/acceptance/features/apiSharingNg/deletePermissions.feature +++ b/tests/acceptance/features/apiSharingNg/deletePermissions.feature @@ -177,3 +177,41 @@ Feature: Remove access to a drive item | view | | edit | | blocksDownload | + + + Scenario Outline: user removes user member from project space + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "NewSpace" with the default quota using the Graph API + And user "Alice" has sent the following share invitation: + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | | + When user "Alice" removes the share permission of user "Brian" from space "NewSpace" using the Graph API + Then the HTTP status code should be "204" + And the user "Brian" should not have a space called "NewSpace" + Examples: + | permissions-role | + | Space Viewer | + | Space Editor | + | Manager | + + @issue-8768 + Scenario Outline: user removes group from project space + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "NewSpace" with the default quota using the Graph API + And group "group1" has been created + And user "Brian" has been added to group "group1" + And user "Alice" has sent the following share invitation: + | space | NewSpace | + | sharee | group1 | + | shareType | group | + | permissionsRole | | + When user "Alice" removes the share permission of group "group1" from space "NewSpace" using the Graph API + Then the HTTP status code should be "204" + And the user "Brian" should not have a space called "NewSpace" + Examples: + | permissions-role | + | Space Viewer | + | Space Editor | + | Manager | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 81e8185ad..e68d86446 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -450,10 +450,10 @@ class SharingNgContext implements Context { /** * @param string $sharer - * @param string $shareType (user|group) - * @param string $resource + * @param string $shareType (user|group|link) * @param string $space - * @param string|null $sharee can be both user or group + * @param string|null $resource + * @param string|null $recipient * * @return ResponseInterface * @throws GuzzleException @@ -462,12 +462,12 @@ class SharingNgContext implements Context { public function removeSharePermission( string $sharer, string $shareType, - string $resource, string $space, - ?string $sharee = null + ?string $resource = null, + ?string $recipient = null ): ResponseInterface { $spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"]; - $itemId = $this->spacesContext->getResourceId($sharer, $space, $resource); + $itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource) : $this->spacesContext->getResourceId($sharer, $space, $space); $permId = ($shareType === 'link') ? $this->featureContext->shareNgGetLastCreatedLinkShareID() @@ -488,8 +488,8 @@ class SharingNgContext implements Context { * @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from (?:file|folder|resource) "([^"]*)" of space "([^"]*)" using the Graph API$/ * * @param string $sharer - * @param string $shareType (user|group) - * @param string $sharee can be both user or group + * @param string $recipientType (user|group) + * @param string $recipient can be both user or group * @param string $resource * @param string $space * @@ -499,13 +499,36 @@ class SharingNgContext implements Context { */ public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI( string $sharer, - string $shareType, - string $sharee, + string $recipientType, + string $recipient, string $resource, string $space ): void { $this->featureContext->setResponse( - $this->removeSharePermission($sharer, $shareType, $resource, $space) + $this->removeSharePermission($sharer, $recipientType, $space, $resource) + ); + } + + /** + * @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from space "([^"]*)" using the Graph API$/ + * + * @param string $sharer + * @param string $recipientType (user|group) + * @param string $recipient can be both user or group + * @param string $space + * + * @return void + * @throws JsonException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function userRemovesSharePermissionOfUserFromSpaceUsingGraphAPI( + string $sharer, + string $recipientType, + string $recipient, + string $space + ): void { + $this->featureContext->setResponse( + $this->removeSharePermission($sharer, $recipientType, $space) ); } @@ -526,7 +549,7 @@ class SharingNgContext implements Context { string $space ):void { $this->featureContext->setResponse( - $this->removeSharePermission($sharer, 'link', $resource, $space) + $this->removeSharePermission($sharer, 'link', $space, $resource) ); } @@ -629,18 +652,19 @@ class SharingNgContext implements Context { ); $responseBody = $this->featureContext->getJsonDecodedResponse($response); $expectedValue = $status === "enabled" ? "true" : "false"; + $actualValue = ""; foreach ($responseBody["value"] as $value) { if ($value["remoteItem"]["name"] === $resource) { // var_export converts values to their string representations // e.g.: true -> 'true' - $actaulValue = var_export($value["@client.synchronize"], true); + $actualValue = var_export($value["@client.synchronize"], true); break; } } Assert::assertSame( - $actaulValue, + $actualValue, $expectedValue, - "Expected property '@client.synchronize' to be '$expectedValue' but found '$actaulValue'" + "Expected property '@client.synchronize' to be '$expectedValue' but found '$actualValue'" ); } }