From fe01fec98a71e100776500ce6d2488d63c34461b Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Tue, 18 Feb 2025 17:03:41 +0545 Subject: [PATCH] add test to enable federated shared resource Signed-off-by: prashant-gurung899 --- .../acceptance/bootstrap/SharingNgContext.php | 25 +++++ tests/acceptance/bootstrap/SpacesContext.php | 1 + ...ected-failures-localAPI-on-OCIS-storage.md | 1 + .../acceptance/features/apiOcm/share.feature | 93 +++++++++++++++++++ 4 files changed, 120 insertions(+) diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index c7e1d19ee77..746b74d6106 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -1405,6 +1405,31 @@ class SharingNgContext implements Context { $this->featureContext->setResponse($response); } + /** + * @When user :user enables sync of federated share :share using the Graph API + * + * @param string $user + * @param string $share + * + * @return void + * @throws Exception + */ + public function userEnablesSyncOfFederatedShareUsingTheGraphApi( + string $user, + string $share, + ): void { + $remoteItemId = $this->spacesContext->getSharesRemoteItemId($user, $share); + $response = GraphHelper::enableShareSync( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getPasswordForUser($user), + $remoteItemId, + GraphHelper::SHARES_SPACE_ID + ); + $this->featureContext->setResponse($response); + } + /** * step definition for enabling sync for items for non-existing group|user|space sharer * diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 8a99d1b1bd9..1ed893029ee 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -298,6 +298,7 @@ class SpacesContext implements Context { * @throws Exception|GuzzleException */ public function getSharesRemoteItemId(string $user, string $share): string { + $share = ltrim($share, '/'); $credentials = $this->featureContext->graphContext->getAdminOrUserCredentials($user); $response = GraphHelper::getSharesSharedWithMe( $this->featureContext->getBaseUrl(), diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 8d1dc7897a4..a42a132fb46 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -331,6 +331,7 @@ The expected failures in this file are from features in the owncloud/ocis repo. #### [[OCM] Hide & Enable Sync fail with received federated shares](https://github.com/owncloud/ocis/issues/10719) - [apiOcm/share.feature:1204](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L1204) - [apiOcm/share.feature:1228](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L1228) +- [apiOcm/share.feature:1339](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L1339) #### [[OCM] federated user trying to download file shared with permissions role Secure Viewer returns 500 status code](https://github.com/owncloud/ocis/issues/10822) - [apiOcm/enableDisablePermissionsRole.feature:18](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/enableDisablePermissionsRole.feature#L18) diff --git a/tests/acceptance/features/apiOcm/share.feature b/tests/acceptance/features/apiOcm/share.feature index 78cf208a506..0d4018f8aaf 100755 --- a/tests/acceptance/features/apiOcm/share.feature +++ b/tests/acceptance/features/apiOcm/share.feature @@ -1297,3 +1297,96 @@ Feature: an user shares resources using ScienceMesh application And as user "Alice" the PROPFIND response should contain a resource "newFolder" with these key and value pairs: | key | value | | oc:name | newFolder | + + @issue-10719 + Scenario: enable sync of a federated shared resource + Given using server "LOCAL" + And user "Alice" has created folder "folderToShare" + And user "Alice" has sent the following resource share invitation to federated user: + | resource | folderToShare | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And using server "REMOTE" + When user "Brian" enables sync of federated share "folderToShare" using the Graph API + Then the HTTP status code should be "201" + 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", + "minItems": 1, + "maxItems": 1, + "items": { + "type": "object", + "required": ["@client.synchronize"], + "properties": { + "@client.synchronize": { "const": true } + } + } + } + } + } + """ + + @issue-10719 + Scenario: enable sync of a federated shared resource when multiple federated shares exist + Given using server "LOCAL" + And user "Alice" has created folder "folderOneShare" + And user "Alice" has created folder "folderTwoShare" + And user "Alice" has sent the following resource share invitation to federated user: + | resource | folderOneShare | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Alice" has sent the following resource share invitation to federated user: + | resource | folderTwoShare | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And using server "REMOTE" + When user "Brian" enables sync of federated share "folderOneShare" using the Graph API + Then the HTTP status code should be "201" + 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", + "minItems": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf":[ + { + "type": "object", + "required": ["@client.synchronize"], + "properties": { + "@client.synchronize": { "const": true } + } + }, + { + "type": "object", + "required": ["@client.synchronize"], + "properties": { + "@client.synchronize": { "const": false } + } + } + ] + } + } + } + } + """