From aea15d90beea22ac4edd902f00a3fa77e6b7fcac Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Wed, 27 Nov 2024 12:51:20 +0545 Subject: [PATCH] add tests to remove access of shared resource to federated user Signed-off-by: prashant-gurung899 --- .../acceptance/bootstrap/SharingNgContext.php | 48 +++++++++++++------ .../acceptance/features/apiOcm/share.feature | 24 ++++++++++ 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index 96a0842fc2c..9c7e0182a01 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -1738,13 +1738,14 @@ public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGrap * @param string $sharer * @param string $space * @param bool $shouldExist + * @param bool $federatedShare * * @return void * @throws GuzzleException * @throws JsonException * @throws Exception */ - public function checkIfShareExists(string $share, string $sharee, string $sharer, string $space, bool $shouldExist = true): void { + public function checkIfShareExists(string $share, string $sharee, string $sharer, string $space, bool $shouldExist = true, bool $federatedShare = false): void { $share = \ltrim($share, "/"); if (\strtolower($space) === "personal") { $remoteDriveAlias = "personal/" . \strtolower($sharer); @@ -1752,22 +1753,24 @@ public function checkIfShareExists(string $share, string $sharee, string $sharer $remoteDriveAlias = "project/" . \strtolower($space); } - // check share mountpoint - $response = GraphHelper::getMySpaces( - $this->featureContext->getBaseUrl(), - $sharee, - $this->featureContext->getPasswordForUser($sharee), - "", - $this->featureContext->getStepLineRef() - ); - $driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value; - $foundShareMountpoint = false; - foreach ($driveList as $drive) { - if ($drive->driveType === "mountpoint" && $drive->name === $share && $drive->root->remoteItem->driveAlias === $remoteDriveAlias) { - $foundShareMountpoint = true; + if (!$federatedShare) { + // check share mountpoint + $response = GraphHelper::getMySpaces( + $this->featureContext->getBaseUrl(), + $sharee, + $this->featureContext->getPasswordForUser($sharee), + "", + $this->featureContext->getStepLineRef() + ); + $driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value; + $foundShareMountpoint = false; + foreach ($driveList as $drive) { + if ($drive->driveType === "mountpoint" && $drive->name === $share && $drive->root->remoteItem->driveAlias === $remoteDriveAlias) { + $foundShareMountpoint = true; + } } + Assert::assertSame($shouldExist, $foundShareMountpoint, "Share mountpoint '$share' was not found in the drives list."); } - Assert::assertSame($shouldExist, $foundShareMountpoint, "Share mountpoint '$share' was not found in the drives list."); // check share in shared-with-me list $response = GraphHelper::getSharesSharedWithMe( @@ -1808,6 +1811,21 @@ public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string $this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should"); } + /** + * @Then /^user "([^"]*)" (should|should not) have a federated share "([^"]*)" shared by user "([^"]*)" from space "([^"]*)"$/ + * + * @param string $sharee + * @param string $shouldOrNot + * @param string $share + * @param string $sharer + * @param string $space + * + * @return void + */ + public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void { + $this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should", true); + } + /** * @Given /^user "([^"]*)" has shared the following (?:files|folders) from space "([^"]*)" with user "([^"]*)" and role "([^"]*)":$/ * diff --git a/tests/acceptance/features/apiOcm/share.feature b/tests/acceptance/features/apiOcm/share.feature index 9fd1e0db627..fb54ff83b26 100755 --- a/tests/acceptance/features/apiOcm/share.feature +++ b/tests/acceptance/features/apiOcm/share.feature @@ -1229,3 +1229,27 @@ Feature: an user shares resources using ScienceMesh application } } """ + + @issue-10213 + Scenario Outline: local user removes access of federated user from a resource + Given using spaces DAV path + And using server "REMOTE" + And "Brian" has created the federation share invitation + And using server "LOCAL" + And "Alice" has accepted invitation + And user "Alice" has created a folder "FOLDER" in space "Personal" + And user "Alice" has sent the following resource share invitation to federated user: + | resource | FOLDER | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | | + When user "Alice" removes the access of user "Brian" from resource "FOLDER" of space "Personal" using the Graph API + Then the HTTP status code should be "204" + And using server "REMOTE" + And user "Brian" should not have a federated share "FOLDER" shared by user "Alice" from space "Personal" + Examples: + | permissionsRole | + | Viewer | + | Uploader | + | Editor |