diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index d6596c9aa4..40f02936e7 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -2010,6 +2010,39 @@ class GraphHelper { ); } + /** + * @param string $baseUrl + * @param string $xRequestId + * @param string $user + * @param string $password + * @param string $itemId + * @param string $shareSpaceId + * @param array $body + * + * @return ResponseInterface + * @throws GuzzleException + */ + public static function hideShare( + string $baseUrl, + string $xRequestId, + string $user, + string $password, + string $itemId, + string $shareSpaceId, + array $body + ):ResponseInterface { + $url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/items/$itemId"); + return HttpRequestHelper::sendRequest( + $url, + $xRequestId, + 'PATCH', + $user, + $password, + self::getRequestHeaders(), + \json_encode($body) + ); + } + /** * @param string $baseUrl * @param string $xRequestId diff --git a/tests/acceptance/features/apiSharingNg/sharedWithMe.feature b/tests/acceptance/features/apiSharingNg/sharedWithMe.feature index 02d641f37b..dc498b5517 100755 --- a/tests/acceptance/features/apiSharingNg/sharedWithMe.feature +++ b/tests/acceptance/features/apiSharingNg/sharedWithMe.feature @@ -4840,3 +4840,171 @@ Feature: an user gets the resources shared to them } } """ + + + Scenario Outline: sharee hides the shared resource (Personal space) + Given user "Alice" has created folder "folder" + And user "Alice" has uploaded file with content "hello world" to "testfile.txt" + And user "Alice" has sent the following share invitation: + | resource | | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Brian" hides the shared resource "" using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["hidden", "mount_point"], + "properties": { + "hidden": { + "const": true + }, + "mount_point": { + "type": "object", + "required": ["path"], + "properties": { + "path": { + "const": "" + } + } + } + } + } + """ + Examples: + | resource | + | testfile.txt | + | folder | + + + Scenario Outline: sharee hides the shared resource (Project space) + 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 "NewSpace" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "NewSpace" with content "share space items" to "testfile.txt" + And user "Alice" has created a folder "FolderToShare" in space "NewSpace" + And user "Alice" has sent the following share invitation: + | resource | | + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Brian" hides the shared resource "" using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["hidden", "mount_point"], + "properties": { + "hidden": { + "const": true + }, + "mount_point": { + "type": "object", + "required": ["path"], + "properties": { + "path": { + "const": "" + } + } + } + } + } + """ + Examples: + | resource | + | testfile.txt | + | FolderToShare | + + + Scenario Outline: sharee lists the shares after hiding (Personal space) + Given user "Alice" has created folder "folder" + And user "Alice" has uploaded file with content "hello world" to "testfile.txt" + And user "Alice" has sent the following share invitation: + | resource | | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has hidden the share "" + When user "Brian" lists the shares shared with him using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["value"], + "properties": { + "value": { + "type": "array", + "maxItems": 1, + "minItems": 1, + "items": { + "type": "object", + "required": [ + "@UI.Hidden" + ], + "properties": { + "@UI.Hidden":{ + "const": true + } + } + } + } + } + } + """ + Examples: + | resource | + | testfile.txt | + | folder | + + + Scenario Outline: sharee lists the shares after hiding (Project space) + 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 "NewSpace" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "NewSpace" with content "share space items" to "testfile.txt" + And user "Alice" has created a folder "FolderToShare" in space "NewSpace" + And user "Alice" has sent the following share invitation: + | resource | | + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has hidden the share "" + When user "Brian" lists the shares shared with him using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["value"], + "properties": { + "value": { + "type": "array", + "maxItems": 1, + "minItems": 1, + "items": { + "type": "object", + "required": [ + "@UI.Hidden" + ], + "properties": { + "@UI.Hidden":{ + "const": true + } + } + } + } + } + } + """ + Examples: + | resource | + | testfile.txt | + | FolderToShare | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index fe91c8ffbf..0bbcf2c776 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -697,6 +697,29 @@ class SharingNgContext implements Context { $this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response); } + /** + * @param string $sharee + * @param string $shareID + * + * @return ResponseInterface + * @throws GuzzleException + * @throws JsonException + */ + public function hideSharedResource(string $sharee, string $shareID): ResponseInterface { + $shareSpaceId = FeatureContext::SHARES_SPACE_ID; + $itemId = $shareSpaceId . '!' . $shareID; + $body['@UI.Hidden'] = true; + return GraphHelper::hideShare( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $this->featureContext->getActualUsername($sharee), + $this->featureContext->getPasswordForUser($sharee), + $itemId, + $shareSpaceId, + $body + ); + } + /** * @Then /^for user "([^"]*)" the space Shares should (not|)\s?contain these (files|entries):$/ * @@ -774,6 +797,36 @@ class SharingNgContext implements Context { $this->featureContext->pushToLastStatusCodesArrays(); } + /** + * @When user :user hides the shared resource :sharedResource using the Graph API + * + * @param string $user + * + * @return void + * @throws Exception + * @throws GuzzleException + */ + public function userHidesTheSharedResourceUsingTheGraphApi(string $user):void { + $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); + $response = $this->hideSharedResource($user, $shareItemId); + $this->featureContext->setResponse($response); + } + + /** + * @Given user :user has hidden the share :sharedResource + * + * @param string $user + * + * @return void + * @throws Exception + * @throws GuzzleException + */ + public function userHasHiddenTheShare(string $user):void { + $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); + $response = $this->hideSharedResource($user, $shareItemId); + $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); + } + /** * @When user :user enables sync of share :share offered by :offeredBy from :space space using the Graph API *