From 00ed2ce58cc5bee58368ab2e54b2187e1e7e2b23 Mon Sep 17 00:00:00 2001 From: Amrita <54478846+amrita-shrestha@users.noreply.github.com> Date: Fri, 10 May 2024 16:28:58 +0545 Subject: [PATCH] add tests for removing share link (#9123) --- ...ected-failures-localAPI-on-OCIS-storage.md | 2 + .../apiSharingNg/removeAccessToDrive.feature | 58 ++++++++++++++++++ .../features/bootstrap/SharingNgContext.php | 60 +++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 45168d4e79..07b4e21fe9 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -266,6 +266,8 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiSharingNg/removeAccessToDriveItem.feature:141](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDriveItem.feature#L141) - [apiSharingNg/removeAccessToDriveItem.feature:161](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDriveItem.feature#L161) - [apiSharingNg/removeAccessToDriveItem.feature:179](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDriveItem.feature#L179) +- [apiSharingNg/removeAccessToDrive.feature:178](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature#L178) +- [apiSharingNg/removeAccessToDrive.feature:207](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature#L207) ### [sharee (editor role) MOVE a file by file-id into same shared folder returns 403](https://github.com/owncloud/ocis/issues/7617) diff --git a/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature b/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature index d78bff5b75..0cec5a60d5 100644 --- a/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature +++ b/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature @@ -157,3 +157,61 @@ Feature: Remove access to a drive When user "Brian" tries to remove the access of group "group1" from space "NewSpace" using root endpoint of the Graph API Then the HTTP status code should be "403" And the user "Brian" should have a space called "NewSpace" + + @issue-7879 + Scenario Outline: user removes link share 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 created the following space link share: + | space | NewSpace | + | permissionsRole | | + | password | %public% | + When user "Alice" removes the link from space "NewSpace" using root endpoint of the Graph API + Then the HTTP status code should be "204" + And user "Alice" should not have any "link" permissions on space "NewSpace" + Examples: + | permissions-role | + | view | + | edit | + | upload | + | createOnly | + | blocksDownload | + + + Scenario: user removes internal link share 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 created the following space link share: + | space | NewSpace | + | permissionsRole | internal | + When user "Alice" removes the link from space "NewSpace" using root endpoint of the Graph API + Then the HTTP status code should be "204" + And user "Alice" should not have any "link" permissions on space "NewSpace" + + @issue-7879 + Scenario Outline: user tries to remove link share of project space owned by next user + 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 created the following space link share: + | space | NewSpace | + | permissionsRole | | + | password | %public% | + When user "Brian" tries to remove the link from space "NewSpace" owned by "Alice" using root endpoint of the Graph API + Then the HTTP status code should be "500" + Examples: + | permissions-role | + | view | + | edit | + | upload | + | createOnly | + | blocksDownload | + + + Scenario: user tries to remove internal link share of project space owned by next user + 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 created the following space link share: + | space | NewSpace | + | permissionsRole | internal | + When user "Brian" tries to remove the link from space "NewSpace" owned by "Alice" using root endpoint of the Graph API + Then the HTTP status code should be "500" diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index bd29beb73b..76e1afd13d 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -1316,4 +1316,64 @@ class SharingNgContext implements Context { ); $this->featureContext->setResponse($response); } + + /** + * @When user :user tries to remove the link from space :space owned by :owner using root endpoint of the Graph API + * + * @param string $user + * @param string $space + * @param string $spaceOwner + * + * @return void + * @throws GuzzleException + */ + public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void { + $permissionID = $this->featureContext->shareNgGetLastCreatedLinkShareID(); + $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"]; + + $response = GraphHelper::removeAccessToSpace( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $spaceId, + $permissionID + ); + $this->featureContext->setResponse($response); + } + + /** + * @Then user :user should not have any :shareType permissions on space :space + * + * @param string $user + * @param string $shareType + * @param string $space + * + * @return void + * @throws GuzzleException + */ + public function userShouldNotHaveAnyPermissionsOnSpace(string $user, string $shareType, 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 + ); + $responseBody = $this->featureContext->getJsonDecodedResponse($response); + foreach ($responseBody['value'] as $value) { + switch ($shareType) { + case $shareType === 'link': + Assert::assertArrayNotHasKey('link', $value, $space . ' space should not have any link permissions but found ' . print_r($value, true)); + break; + case $shareType === "share": + Assert::assertArrayNotHasKey('grantedToV2', $value, $space . ' space should not have any share permissions but found ' . print_r($value, true)); + break; + default: + Assert::fail('Invalid share type has been specified'); + } + } + } }