From 9f6267ed62c213f5ae50f54cd46a2ea76fb107fb Mon Sep 17 00:00:00 2001 From: Kiran Parajuli Date: Thu, 18 Aug 2022 17:20:57 +0545 Subject: [PATCH] [tests-only] restore the removed scenarios for the core repository Signed-off-by: Kiran Parajuli --- .drone.env | 2 +- .../expected-failures-API-on-OCIS-storage.md | 2 + .../apiSpaces/changingFilesShare.feature | 97 +++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 77 ++++++++++++++- 4 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 tests/acceptance/features/apiSpaces/changingFilesShare.feature diff --git a/.drone.env b/.drone.env index bf41b89dff6..0c394ff4935 100644 --- a/.drone.env +++ b/.drone.env @@ -1,5 +1,5 @@ # The test runner source for API tests -CORE_COMMITID=f79fbff0a0d129df7b6ec20bc202665c4fda5fad +CORE_COMMITID=809f7256bdea4cd3dee45dfd5cd078542f4c55cf CORE_BRANCH=master # The test runner source for UI tests diff --git a/tests/acceptance/expected-failures-API-on-OCIS-storage.md b/tests/acceptance/expected-failures-API-on-OCIS-storage.md index e39067d0abb..d379bcbc63c 100644 --- a/tests/acceptance/expected-failures-API-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-API-on-OCIS-storage.md @@ -450,6 +450,8 @@ File and sync features in a shared scenario #### [not possible to move file into a received folder](https://github.com/owncloud/ocis/issues/764) - [apiShareManagementBasicToShares/createShareToSharesFolder.feature:500](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementBasicToShares/createShareToSharesFolder.feature#L500) +- [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12) +- [apiSpaces/changingFilesShare.feature:67](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L67) #### [File deletion using dav gives unique string in filename in the trashbin](https://github.com/owncloud/product/issues/178) diff --git a/tests/acceptance/features/apiSpaces/changingFilesShare.feature b/tests/acceptance/features/apiSpaces/changingFilesShare.feature new file mode 100644 index 00000000000..782c4861ebb --- /dev/null +++ b/tests/acceptance/features/apiSpaces/changingFilesShare.feature @@ -0,0 +1,97 @@ +@api @skipOnOcV10 +Feature: + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + And using spaces DAV path + + @issue-764 + Scenario: Moving a file into a share as recipient + Given user "Alice" has created folder "/shared" + And user "Alice" has shared folder "/shared" with user "Brian" + And user "Brian" has accepted share "/shared" offered by user "Alice" + And user "Brian" has uploaded file with content "some data" to "/textfile0.txt" + When user "Brian" moves file "textfile0.txt" from space "Personal" to "shared/shared_file.txt" inside space "Shares Jail" using the WebDAV API + Then the HTTP status code should be "201" + And for user "Brian" folder "shared" of the space "Shares Jail" should contain these entries: + | shared_file.txt | + And for user "Alice" the space "Personal" should contain these entries: + | shared_file.txt | + + + Scenario: Moving files between shares by same user + And user "Alice" has created folder "share1" + And user "Alice" has created folder "share2" + And user "Alice" has uploaded file with content "some data" to "/textfile0.txt" + And user "Alice" has moved file "textfile0.txt" to "share1/textfile0.txt" + And user "Alice" has shared folder "/share1" with user "Brian" + And user "Alice" has shared folder "/share2" with user "Brian" + And user "Brian" has accepted share "/share1" offered by user "Alice" + And user "Brian" has accepted share "/share2" offered by user "Alice" + When user "Brian" moves file "share1/textfile0.txt" to "share2/textfile0.txt" in space "Shares Jail" using the WebDAV API + Then the HTTP status code should be "201" + And for user "Brian" folder "share1" of the space "Shares Jail" should not contain these entries: + | textfile0.txt | + And for user "Brian" folder "share2" of the space "Shares Jail" should contain these entries: + | textfile0.txt | + And for user "Alice" the space "Personal" should not contain these entries: + | share1/textfile0.txt | + And for user "Alice" the space "Personal" should contain these entries: + | share2/textfile0.txt | + + @issue-764 + Scenario: Moving files added by sharee between shares by same user + And user "Alice" has created folder "share1" + And user "Alice" has created folder "share2" + And user "Brian" has uploaded file with content "some data" to "/textfile0.txt" + And user "Alice" has shared folder "/share1" with user "Brian" + And user "Alice" has shared folder "/share2" with user "Brian" + And user "Brian" has accepted share "/share1" offered by user "Alice" + And user "Brian" has accepted share "/share2" offered by user "Alice" + When user "Brian" moves file "textfile0.txt" from space "Personal" to "share1/shared_file.txt" inside space "Shares Jail" using the WebDAV API + And user "Brian" moves file "share1/shared_file.txt" to "share2/shared_file.txt" in space "Shares Jail" using the WebDAV API + Then the HTTP status code of responses on all endpoints should be "201" + And for user "Brian" folder "share1" of the space "Shares Jail" should not contain these entries: + | shared_file.txt | + And for user "Alice" the space "Personal" should contain these entries: + | share1/shared_file.txt | + And for user "Brian" folder "share2" of the space "Shares Jail" should contain these entries: + | shared_file.txt | + And for user "Alice" the space "Personal" should contain these entries: + | share2/shared_file.txt | + + @issue-4421 + Scenario: Move files between shares by different users + Given user "Carol" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file with content "some data" to "/textfile0.txt" + And user "Alice" has created folder "/PARENT" + And user "Brian" has created folder "/PARENT" + And user "Alice" has moved file "textfile0.txt" to "PARENT/shared_file.txt" in space "Personal" + And user "Alice" has shared folder "/PARENT" with user "Carol" + And user "Brian" has shared folder "/PARENT" with user "Carol" + And user "Carol" has accepted share "/PARENT" offered by user "Alice" + And user "Carol" has accepted share "/PARENT" offered by user "Brian" + When user "Carol" moves file "PARENT/shared_file.txt" to "PARENT (1)/shared_file.txt" in space "Shares Jail" using the WebDAV API + Then the HTTP status code should be "201" + And as "Carol" file "/Shares/PARENT (1)/shared_file.txt" should exist + And for user "Brian" folder "PARENT (1)" of the space "Shares Jail" should contain these entries: + | shared_file.txt | + And for user "Brian" the space "Personal" should contain these entries: + | PARENT/shared_file.txt | + And for user "Alice" the space "Personal" should not contain these entries: + | PARENT/shared_file.txt | + + + Scenario: overwrite a received file share + Given user "Alice" has uploaded file with content "this is the old content" to "/textfile1.txt" + And user "Alice" has shared file "/textfile1.txt" with user "Brian" + And user "Brian" has accepted share "/textfile1.txt" offered by user "Alice" + When user "Brian" uploads a file inside space "Shares Jail" with content "this is a new content" to "textfile1.txt" using the WebDAV API + Then the HTTP status code should be "204" + And for user "Brian" the space "Shares Jail" should contain these entries: + | textfile1.txt | + And the content of file "textfile1.txt" inside space "Shares Jail" for user "Brian" should be "this is a new content" + And the content of file "textfile1.txt" inside space "Personal" for user "Alice" should be "this is a new content" diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 590b085a7c2..86778f9780f 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1371,6 +1371,9 @@ public function findEntryFromPropfindResponse( // trim any leading "/" passed by the caller, we can just match the "raw" name $trimmedEntryNameToSearch = \trim($entryNameToSearch, "/"); + // url encode for spaces and brackets that may appear in the filePath + $folderPath = \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $folderPath); + // topWebDavPath should be something like /remote.php/webdav/ or // /remote.php/dav/files/alice/ $topWebDavPath = "/" . "dav/spaces/" . $spaceId . "/" . $folderPath; @@ -1846,6 +1849,7 @@ public function userCopiesFileWithinSpaceUsingTheWebDAVAPI( * @param string $spaceName * * @return void + * @throws GuzzleException */ public function userMovesFileWithinSpaceUsingTheWebDAVAPI( string $user, @@ -1860,10 +1864,43 @@ public function userMovesFileWithinSpaceUsingTheWebDAVAPI( $spaceName ); - $fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/"); + $fileSource = \trim($fileSource, "/"); + $fileSource = \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $fileSource); + $fullUrl = $space["root"]["webDavUrl"] . '/' . $fileSource; $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers); } + /** + * @Given /^user "([^"]*)" has moved (?:file|folder) "([^"]*)" to "([^"]*)" in space "([^"]*)"$/ + * + * @param string $user + * @param string $fileSource + * @param string $fileDestination + * @param string $spaceName + * + * @return void + * @throws GuzzleException + */ + public function userHasMovedFileWithinSpaceUsingTheWebDAVAPI( + string $user, + string $fileSource, + string $fileDestination, + string $spaceName + ):void { + $this->userMovesFileWithinSpaceUsingTheWebDAVAPI( + $user, + $fileSource, + $fileDestination, + $spaceName + ); + $this->featureContext->theHTTPStatusCodeShouldBe( + 201, + __METHOD__ . "Expected response status code should be 201 (Created)\n" . + "Actual response status code was: " . $this->featureContext->getResponse()->getStatusCode() . "\n" . + "Actual response body was: " . $this->featureContext->getResponse()->getBody() + ); + } + /** * MOVE request for files|folders * @@ -1885,6 +1922,9 @@ public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array $headers, ) ); + $this->featureContext->pushToLastHttpStatusCodesArray( + (string)$this->featureContext->getResponse()->getStatusCode() + ); } /** @@ -1949,7 +1989,11 @@ public function userMovesFileFromAndToSpaceBetweenSpaces( */ public function destinationHeaderValueWithSpaceName(string $user, string $fileDestination, string $spaceName):string { $space = $this->getSpaceByName($user, $spaceName); - return $space["root"]["webDavUrl"] . '/' . \ltrim($fileDestination, '/'); + + $fileDestination = \ltrim($fileDestination, "/"); + $fileDestination = \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $fileDestination); + + return $space["root"]["webDavUrl"] . '/' . $fileDestination; } /** @@ -3027,7 +3071,7 @@ public function forUserSpaceShouldContainLinks( string $fileName = '' ): void { $body = ''; - if (!empty ($fileName)) { + if (!empty($fileName)) { $body = $this->getFileId($user, $spaceName, $fileName); } else { $space = $this->getSpaceByName($user, $spaceName); @@ -3142,4 +3186,31 @@ public function asUserFileInsideSpaceShouldContainAPropertyWithValue( $expectedValue ); } + + /** + * @Given /^the content of file "([^"]*)" inside space "([^"]*)" for user "([^"]*)" should be "([^"]*)"$/ + * @throws GuzzleException + */ + public function theContentOfFileInsideSpaceForUserShouldBe($fileSource, $spaceName, $user, $expectedContent) { + $user = $this->featureContext->getActualUsername($user); + $space = $this->getSpaceByName($user, $spaceName); + $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($fileSource, "/"); + $this->featureContext->setResponse( + HttpRequestHelper::get( + $fullUrl, + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + ) + ); + $this->featureContext->theHttpStatusCodeShouldBe(200); + $actualContent = (string) $this->featureContext->getResponse()->getBody(); + Assert::assertEquals( + $expectedContent, + $actualContent, + __METHOD__ . " Downloaded content mis-match for resource at '$fileSource' inside space '$spaceName'" . + "\n- Expected content: $expectedContent" . + "\n+ Actual content: $actualContent" + ); + } }