From eac8fb86496a32ec5048e08651770e00914d29ad Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Mon, 29 Jul 2024 11:43:05 +0200 Subject: [PATCH 1/2] unhide share --- tests/TestHelpers/GraphHelper.php | 2 +- .../apiSharingNg1/sharedWithMe.feature | 117 ++++++++++++++++++ .../features/bootstrap/SharingNgContext.php | 22 +++- 3 files changed, 137 insertions(+), 4 deletions(-) diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index 6926a633a4..302d360a72 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -2021,7 +2021,7 @@ class GraphHelper { * @return ResponseInterface * @throws GuzzleException */ - public static function hideShare( + public static function hideOrUnhideShare( string $baseUrl, string $xRequestId, string $user, diff --git a/tests/acceptance/features/apiSharingNg1/sharedWithMe.feature b/tests/acceptance/features/apiSharingNg1/sharedWithMe.feature index 7aa05959e8..d81ebe4859 100755 --- a/tests/acceptance/features/apiSharingNg1/sharedWithMe.feature +++ b/tests/acceptance/features/apiSharingNg1/sharedWithMe.feature @@ -5010,3 +5010,120 @@ Feature: an user gets the resources shared to them | resource | | testfile.txt | | FolderToShare | + + + Scenario Outline: sharee lists the shares after unhiding share (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 resource share invitation: + | resource | | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has hidden the share "" + When user "Brian" unhides 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": ["@UI.Hidden"], + "properties": { + "@UI.Hidden": { + "const": false + } + } + } + """ + 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": false + } + } + } + } + } + } + """ + Examples: + | resource | + | testfile.txt | + | folder | + + + Scenario Outline: sharee lists the shares after unhiding share (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 resource share invitation: + | resource | | + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has hidden the share "" + When user "Brian" unhides 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": ["@UI.Hidden"], + "properties": { + "@UI.Hidden": { + "const": false + } + } + } + """ + 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": false + } + } + } + } + } + } + """ + Examples: + | resource | + | testfile.txt | + | FolderToShare | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 8ca8b0e972..ec977e1e7d 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -1036,16 +1036,17 @@ class SharingNgContext implements Context { /** * @param string $sharee * @param string $shareID + * @param bool $hide * * @return ResponseInterface * @throws GuzzleException * @throws JsonException */ - public function hideSharedResource(string $sharee, string $shareID): ResponseInterface { + public function hideSharedResource(string $sharee, string $shareID, bool $hide = true): ResponseInterface { $shareSpaceId = FeatureContext::SHARES_SPACE_ID; $itemId = $shareSpaceId . '!' . $shareID; - $body['@UI.Hidden'] = true; - return GraphHelper::hideShare( + $body['@UI.Hidden'] = $hide; + return GraphHelper::hideOrUnhideShare( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), $this->featureContext->getActualUsername($sharee), @@ -1166,6 +1167,21 @@ class SharingNgContext implements Context { $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); } + /** + * @When user :user unhides the shared resource :sharedResource using the Graph API + * + * @param string $user + * + * @return void + * @throws Exception + * @throws GuzzleException + */ + public function userUnhidesTheSharedResourceUsingTheGraphApi(string $user):void { + $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); + $response = $this->hideSharedResource($user, $shareItemId, false); + $this->featureContext->setResponse($response); + } + /** * @When user :user enables sync of share :share offered by :offeredBy from :space space using the Graph API * From eb4de64f33f506d4ae4e80e134eb5f5dbeac9a71 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Mon, 29 Jul 2024 12:30:05 +0200 Subject: [PATCH 2/2] fix after review --- tests/acceptance/features/bootstrap/SharingNgContext.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index ec977e1e7d..fe792794e2 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -1042,7 +1042,7 @@ class SharingNgContext implements Context { * @throws GuzzleException * @throws JsonException */ - public function hideSharedResource(string $sharee, string $shareID, bool $hide = true): ResponseInterface { + public function hideOrUnhideSharedResource(string $sharee, string $shareID, bool $hide = true): ResponseInterface { $shareSpaceId = FeatureContext::SHARES_SPACE_ID; $itemId = $shareSpaceId . '!' . $shareID; $body['@UI.Hidden'] = $hide; @@ -1148,7 +1148,7 @@ class SharingNgContext implements Context { */ public function userHidesTheSharedResourceUsingTheGraphApi(string $user):void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); - $response = $this->hideSharedResource($user, $shareItemId); + $response = $this->hideOrUnhideSharedResource($user, $shareItemId); $this->featureContext->setResponse($response); } @@ -1163,7 +1163,7 @@ class SharingNgContext implements Context { */ public function userHasHiddenTheShare(string $user):void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); - $response = $this->hideSharedResource($user, $shareItemId); + $response = $this->hideOrUnhideSharedResource($user, $shareItemId); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); } @@ -1178,7 +1178,7 @@ class SharingNgContext implements Context { */ public function userUnhidesTheSharedResourceUsingTheGraphApi(string $user):void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); - $response = $this->hideSharedResource($user, $shareItemId, false); + $response = $this->hideOrUnhideSharedResource($user, $shareItemId, false); $this->featureContext->setResponse($response); }