From 39131cabbe761ab5814371ca88b8b40878889f65 Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 19 Jun 2023 09:16:13 +0545 Subject: [PATCH 1/2] added unshare scenerio --- .../acceptance/features/bootstrap/Sharing.php | 34 +++++++++++++++++++ .../deleteShareFromShares.feature | 14 +++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index 0742ec5c22a..771c3b0d201 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -3520,6 +3520,40 @@ public function userHasUnsharedResourceSharedTo(string $sharer, string $path, st $this->emptyLastOCSStatusCodesArray(); } + /** + * @When /^user "([^"]*)" unshares (?:folder|file|entity) "([^"]*)" shared to "([^"]*)"$/ + * + * @param string $sharer + * @param string $path + * @param string $sharee + * + * @return void + * @throws JsonException + */ + public function userUnsharesSharedTo(string $sharer, string $path, string $sharee): void { + $sharer = $this->getActualUsername($sharer); + $sharee = $this->getActualUsername($sharee); + + $response = $this->getShares($sharer, "$path&share_types=0"); + $shareId = null; + foreach ($response as $shareElement) { + if ((string)$shareElement->share_with[0] === $sharee) { + $shareId = (string) $shareElement->id; + break; + } + } + Assert::assertNotNull( + $shareId, + __METHOD__ . " could not find share, offered by $sharer to $sharee" + ); + + $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( + $sharer, + 'DELETE', + '/apps/files_sharing/api/v' . $this->sharingApiVersion . '/shares/' . $shareId + ); + } + /** * @Then the sharing API should report that no shares are shared with user :user * diff --git a/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature b/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature index 3bd6210a7d2..2023070fd28 100644 --- a/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature +++ b/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature @@ -74,7 +74,7 @@ Feature: sharing And as "Alice" file "/shared_file.txt" should exist in the trashbin And as "Brian" file "/shared_file.txt" should exist in the trashbin - + Scenario: deleting a folder out of a share as recipient creates a backup for the owner Given using OCS API version "1" And user "Alice" has created folder "/shared" @@ -226,3 +226,15 @@ Feature: sharing | ocs_api_version | ocs_status_code | http_status_code | | 1 | 404 | 200 | | 2 | 404 | 404 | + + + Scenario: unshare a shared resources + Given using OCS API version "1" + And user "Alice" has shared file "textfile0.txt" with user "Brian" + And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice" + When user "Alice" unshares file "textfile0.txt" shared to "Brian" +# Then the OCS status code should be "200" + Then the HTTP status code should be "204" + And as "Brian" file "/Shares/shared/textfile0.txt" should not exist + + From 98f82e060b2ecab9dac22d14b9ae1bf59b3d87a3 Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 19 Jun 2023 10:14:25 +0545 Subject: [PATCH 2/2] remove unshare keyword from step definition --- .../acceptance/features/bootstrap/Sharing.php | 59 ++++++------------- .../acceptance/features/bootstrap/WebDav.php | 2 +- .../deleteShareFromShares.feature | 4 +- .../coreApiVersions/fileVersions.feature | 2 +- 4 files changed, 23 insertions(+), 44 deletions(-) diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index 771c3b0d201..8b74ae39509 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -3491,6 +3491,25 @@ public function assertNoSharesOfUserAreInState(string $user, string $state):void * @throws JsonException */ public function userHasUnsharedResourceSharedTo(string $sharer, string $path, string $sharee): void { + $this->userUnsharesSharedTo($sharer, $path, $sharee); + $this->ocsContext->assertOCSResponseIndicatesSuccess( + 'The ocs share response does not indicate success.', + ); + $this->emptyLastHTTPStatusCodesArray(); + $this->emptyLastOCSStatusCodesArray(); + } + + /** + * @When /^user "([^"]*)" unshares (?:folder|file|entity) "([^"]*)" shared to "([^"]*)"$/ + * + * @param string $sharer + * @param string $path + * @param string $sharee + * + * @return void + * @throws JsonException + */ + public function userUnsharesSharedTo(string $sharer, string $path, string $sharee): void { $sharer = $this->getActualUsername($sharer); $sharee = $this->getActualUsername($sharee); @@ -3512,48 +3531,8 @@ public function userHasUnsharedResourceSharedTo(string $sharer, string $path, st 'DELETE', '/apps/files_sharing/api/v' . $this->sharingApiVersion . '/shares/' . $shareId ); - - $this->ocsContext->assertOCSResponseIndicatesSuccess( - 'The ocs share response does not indicate success.', - ); - $this->emptyLastHTTPStatusCodesArray(); - $this->emptyLastOCSStatusCodesArray(); } - /** - * @When /^user "([^"]*)" unshares (?:folder|file|entity) "([^"]*)" shared to "([^"]*)"$/ - * - * @param string $sharer - * @param string $path - * @param string $sharee - * - * @return void - * @throws JsonException - */ - public function userUnsharesSharedTo(string $sharer, string $path, string $sharee): void { - $sharer = $this->getActualUsername($sharer); - $sharee = $this->getActualUsername($sharee); - - $response = $this->getShares($sharer, "$path&share_types=0"); - $shareId = null; - foreach ($response as $shareElement) { - if ((string)$shareElement->share_with[0] === $sharee) { - $shareId = (string) $shareElement->id; - break; - } - } - Assert::assertNotNull( - $shareId, - __METHOD__ . " could not find share, offered by $sharer to $sharee" - ); - - $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( - $sharer, - 'DELETE', - '/apps/files_sharing/api/v' . $this->sharingApiVersion . '/shares/' . $shareId - ); - } - /** * @Then the sharing API should report that no shares are shared with user :user * diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 2bf82133033..5e2835638b2 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -3338,7 +3338,7 @@ public function fileHasBeenDeleted(string $file, string $user):void { } /** - * @When /^user "([^"]*)" (?:deletes|unshares) (?:file|folder) "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" deletes (?:file|folder) "([^"]*)" using the WebDAV API$/ * * @param string $user * @param string $file diff --git a/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature b/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature index 2023070fd28..0671417a878 100644 --- a/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature +++ b/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature @@ -233,8 +233,8 @@ Feature: sharing And user "Alice" has shared file "textfile0.txt" with user "Brian" And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice" When user "Alice" unshares file "textfile0.txt" shared to "Brian" -# Then the OCS status code should be "200" - Then the HTTP status code should be "204" + Then the OCS status code should be "100" + And the HTTP status code should be "200" And as "Brian" file "/Shares/shared/textfile0.txt" should not exist diff --git a/tests/acceptance/features/coreApiVersions/fileVersions.feature b/tests/acceptance/features/coreApiVersions/fileVersions.feature index 07f4aa9e1aa..5ae11ba824b 100644 --- a/tests/acceptance/features/coreApiVersions/fileVersions.feature +++ b/tests/acceptance/features/coreApiVersions/fileVersions.feature @@ -421,7 +421,7 @@ Feature: dav-versions | new | Brian | /testshare | - Scenario: receiver tries to get file versions of unshared file from the sharer + Scenario: receiver tries to get file versions of file not shared by the sharer Given user "Brian" has been created with default attributes and without skeleton files And user "Alice" has uploaded file with content "textfile0" to "textfile0.txt" And user "Alice" has uploaded file with content "textfile1" to "textfile1.txt"