diff --git a/tests/TestHelpers/SharingHelper.php b/tests/TestHelpers/SharingHelper.php index da3458a68fd..a58c154fbd3 100644 --- a/tests/TestHelpers/SharingHelper.php +++ b/tests/TestHelpers/SharingHelper.php @@ -158,7 +158,6 @@ public static function createShare( $fd['expireDate'] = $expireDate; } $headers = ['OCS-APIREQUEST' => 'true']; - return HttpRequestHelper::post( $fullUrl, $xRequestId, diff --git a/tests/acceptance/expected-failures-API-on-OCIS-storage.md b/tests/acceptance/expected-failures-API-on-OCIS-storage.md index 4dcf6a97450..bc9edd3c266 100644 --- a/tests/acceptance/expected-failures-API-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-API-on-OCIS-storage.md @@ -642,7 +642,7 @@ Not everything needs to be implemented for ocis. While the oc10 testsuite covers - [coreApiCapabilities/capabilities.feature:136](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiCapabilities/capabilities.feature#L136) - [coreApiCapabilities/capabilities.feature:175](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiCapabilities/capabilities.feature#L175) -#### [Sharing of project space root via public link does no longer work](https://github.com/owncloud/ocis/issues/6278) +#### [sharing the shares folder to users exits with different status code than in oc10 backend](https://github.com/owncloud/ocis/issues/2215) - [coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature:23](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature#L23) - [coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature:24](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature#L24) diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index d59e7bd09cd..15eecacaad4 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -3529,6 +3529,25 @@ public function assertNoSharesOfUserAreInState(string $user, string $state):void * @throws JsonException */ public function userHasUnsharedResourceSharedTo(string $sharer, string $path, string $sharee): void { + $this->userUnsharesResourceSharedTo($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 userUnsharesResourceSharedTo(string $sharer, string $path, string $sharee): void { $sharer = $this->getActualUsername($sharer); $sharee = $this->getActualUsername($sharee); @@ -3550,12 +3569,6 @@ 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(); } /** diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 528703438a5..93993edc2de 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -3340,78 +3340,71 @@ public function theUserShouldNotBeAbleToDeleteEntry(string $user, string $entry, * @return void */ public function fileHasBeenDeleted(string $file, string $user):void { - $this->userHasDeletedFile($user, "deleted", "file", $file); + $this->userHasDeletedResource($user, "deleted", "file", $file); } /** - * @When /^user "([^"]*)" (?:deletes|unshares) (?:file|folder) "([^"]*)" using the WebDAV API$/ + * @When user :user deletes file/folder :resource using the WebDAV API * * @param string $user - * @param string $file + * @param string $resource * * @return void */ - public function userDeletesFile(string $user, string $file):void { + public function userDeletesFile(string $user, string $resource):void { $user = $this->getActualUsername($user); $this->pauseUploadDelete(); - $this->response = $this->makeDavRequest($user, 'DELETE', $file, []); + $this->response = $this->makeDavRequest($user, 'DELETE', $resource, []); $this->lastUploadDeleteTime = \time(); $this->pushToLastHttpStatusCodesArray((string) $this->getResponse()->getStatusCode()); } /** - * @Given /^user "([^"]*)" has (deleted|unshared) (?:file|folder|entity) "([^"]*)"$/ + * @Given /^user "([^"]*)" has deleted (?:file|folder|entity) "([^"]*)"$/ * * @param string $user - * @param string $deletedOrUnshared - * @param string $entry + * @param string $resource * * @return void * @throws Exception */ - public function userHasDeletedFile(string $user, string $deletedOrUnshared, string $entry):void { + public function userHasDeletedResource(string $user, string $resource):void { $user = $this->getActualUsername($user); - $this->userDeletesFile($user, $entry); + $this->userDeletesFile($user, $resource); // If the file or folder was there and got deleted then we get a 204 // That is good and the expected status // If the file or folder was already not there then we get a 404 // That is not expected. Scenarios that use "Given user has deleted..." // should only be using such steps when it is a file that exists and needs // to be deleted. - if ($deletedOrUnshared === "deleted") { - $deleteText = "delete"; - } else { - $deleteText = "unshare"; - } $this->theHTTPStatusCodeShouldBe( ["204"], - "HTTP status code was not 204 while trying to $deleteText resource '$entry' for user '$user'" + "HTTP status code was not 204 while trying to delete resource '$resource' for user '$user'" ); $this->emptyLastHTTPStatusCodesArray(); } /** - * @Given /^user "([^"]*)" has (deleted|unshared) the following (?:files|folders|resources)$/ + * @Given /^user "([^"]*)" has deleted the following (?:files|folders|resources)$/ * * @param string $user - * @param string $deletedOrUnshared * @param TableNode $table * * @return void * @throws Exception */ - public function userHasDeletedFollowingFiles(string $user, string $deletedOrUnshared, TableNode $table):void { + public function userHasDeletedFollowingFiles(string $user, TableNode $table):void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); foreach ($paths as $file) { - $this->userHasDeletedFile($user, $deletedOrUnshared, $file["path"]); + $this->userHasDeletedResource($user, $file["path"]); } } /** - * @When /^user "([^"]*)" (?:deletes|unshares) the following (?:files|folders)$/ + * @When /^user "([^"]*)" deletes the following (?:files|folders)$/ * * @param string $user * @param TableNode $table @@ -3431,7 +3424,7 @@ public function userDeletesFollowingFiles(string $user, TableNode $table):void { } /** - * @When /^the user (?:deletes|unshares) (?:file|folder) "([^"]*)" using the WebDAV API$/ + * @When /^the user deletes (?:file|folder) "([^"]*)" using the WebDAV API$/ * * @param string $file * @@ -3442,20 +3435,19 @@ public function theUserDeletesFile(string $file):void { } /** - * @Given /^the user has (deleted|unshared) (file|folder) "([^"]*)"$/ + * @Given /^the user has deleted (file|folder) "([^"]*)"$/ * - * @param string $deletedOrUnshared * @param string $fileOrFolder * @param string $file * * @return void */ - public function theUserHasDeletedFile(string $deletedOrUnshared, string $fileOrFolder, string $file):void { - $this->userHasDeletedFile($this->getCurrentUser(), $deletedOrUnshared, $fileOrFolder, $file); + public function theUserHasDeletedFile(string $fileOrFolder, string $file):void { + $this->userHasDeletedResource($this->getCurrentUser(), $fileOrFolder, $file); } /** - * @When /^user "([^"]*)" (?:deletes|unshares) these (?:files|folders|entries) without delays using the WebDAV API$/ + * @When /^user "([^"]*)" deletes these (?:files|folders|entries) without delays using the WebDAV API$/ * * @param string $user * @param TableNode $table of files or folders to delete @@ -3475,7 +3467,7 @@ public function userDeletesFilesFoldersWithoutDelays(string $user, TableNode $ta } /** - * @When /^the user (?:deletes|unshares) these (?:files|folders|entries) without delays using the WebDAV API$/ + * @When /^the user deletes these (?:files|folders|entries) without delays using the WebDAV API$/ * * @param TableNode $table of files or folders to delete * @@ -3487,7 +3479,7 @@ public function theUserDeletesFilesFoldersWithoutDelays(TableNode $table):void { } /** - * @When /^user "([^"]*)" on "(LOCAL|REMOTE)" (?:deletes|unshares) (?:file|folder) "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" on "(LOCAL|REMOTE)" deletes (?:file|folder) "([^"]*)" using the WebDAV API$/ * * @param string $user * @param string $server @@ -3502,30 +3494,24 @@ public function userOnDeletesFile(string $user, string $server, string $file):vo } /** - * @Given /^user "([^"]*)" on "(LOCAL|REMOTE)" has (deleted|unshared) (file|folder) "([^"]*)"$/ + * @Given /^user "([^"]*)" on "(LOCAL|REMOTE)" has deleted (file|folder) "([^"]*)"$/ * * @param string $user * @param string $server - * @param string $deletedOrUnshared * @param string $fileOrFolder * @param string $entry * * @return void */ - public function userOnHasDeletedFile(string $user, string $server, string $deletedOrUnshared, string $fileOrFolder, string $entry):void { + public function userOnHasDeletedFile(string $user, string $server, string $fileOrFolder, string $entry):void { $this->userOnDeletesFile($user, $server, $entry); // If the file was there and got deleted then we get a 204 // If the file was already not there then we get a 404 // Either way, the outcome of the "given" step is OK - if ($deletedOrUnshared === "deleted") { - $deleteText = "delete"; - } else { - $deleteText = "unshare"; - } $this->theHTTPStatusCodeShouldBe( ["204", "404"], - "HTTP status code was not 204 or 404 while trying to $deleteText $fileOrFolder '$entry' for user '$user' on server '$server'" + "HTTP status code was not 204 or 404 while trying to delete $fileOrFolder '$entry' for user '$user' on server '$server'" ); } @@ -4456,7 +4442,7 @@ public function userDeletesEverythingInFolder( foreach ($elementList as $element) { $element = \substr((string)$element, \strlen($davPrefix)); if ($checkEachDelete) { - $this->userHasDeletedFile($user, "deleted", "file", $element); + $this->userHasDeletedResource($user, "deleted", "file", $element); } else { $this->userDeletesFile($user, $element); } diff --git a/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature b/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature index ea2a685ee49..186273c8797 100644 --- a/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature +++ b/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature @@ -14,11 +14,11 @@ Feature: shares are received in the default folder for received shares And user "Alice" has created folder "FOLDER" When user "Alice" shares folder "/FOLDER" with user "Brian" using the sharing API And user "Brian" accepts share "/FOLDER" offered by user "Alice" using the sharing API - And user "Brian" unshares folder "Shares/FOLDER" using the WebDAV API + And user "Brian" declines share "/Shares/FOLDER" offered by user "Alice" using the sharing API And user "Brian" shares folder "/Shares" with user "Alice" using the sharing API Then the OCS status code of responses on each endpoint should be "" respectively And the HTTP status code of responses on each endpoint should be "" respectively Examples: - | ocs_api_version | ocs_status_code | http_status_code | - | 1 | 100, 100, 400 | 200, 200, 204, 200 | - | 2 | 200, 200, 400 | 200, 200, 204, 400 | + | ocs_api_version | ocs_status_code | http_status_code | + | 1 | 100, 100, 100, 400 | 200, 200, 200, 200 | + | 2 | 200, 200, 200, 400 | 200, 200, 200, 400 | diff --git a/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature b/tests/acceptance/features/coreApiShareManagementBasicToShares/deleteShareFromShares.feature index 3bd6210a7d2..0703a74ec19 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" @@ -106,8 +106,8 @@ Feature: sharing And user "Carol" has stored etag of element "/PARENT" And user "Brian" has stored etag of element "/" And user "Brian" has stored etag of element "/Shares" - When user "Brian" unshares file "/Shares/parent.txt" using the WebDAV API - Then the HTTP status code should be "204" + When user "Brian" declines share "/Shares/parent.txt" offered by user "Carol" using the sharing API + Then the HTTP status code should be "200" And the etag of element "/" of user "Brian" should have changed And the etag of element "/Shares" of user "Brian" should have changed And the etag of element "/PARENT" of user "Carol" should not have changed @@ -226,3 +226,17 @@ Feature: sharing | ocs_api_version | ocs_status_code | http_status_code | | 1 | 404 | 200 | | 2 | 404 | 404 | + + + Scenario Outline: unshare a shared resources + Given using OCS API version "" + 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 "" + And the HTTP status code should be "" + And as "Brian" file "/Shares/textfile0.txt" should not exist + Examples: + | ocs_api_version | ocs_status_code | http_status_code | + | 1 | 100 | 200 | + | 2 | 200 | 200 | diff --git a/tests/acceptance/features/coreApiVersions/fileVersions.feature b/tests/acceptance/features/coreApiVersions/fileVersions.feature index 07f4aa9e1aa..548df6b2798 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: sharee 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"