diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 95d2ea34126..bf78a60bf5a 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -29,3 +29,7 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiGraph/createGroupCaseSensitive.feature:19](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L19) - [apiGraph/createGroupCaseSensitive.feature:20](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L20) - [apiGraph/createGroupCaseSensitive.feature:21](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L21) + +### [PROPFIND on accepted shares with identical names containing brackets exit with 404](https://github.com/owncloud/ocis/issues/4421) + +- [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12) diff --git a/tests/acceptance/features/apiSpaces/changingFilesShare.feature b/tests/acceptance/features/apiSpaces/changingFilesShare.feature new file mode 100644 index 00000000000..8ecb4c80017 --- /dev/null +++ b/tests/acceptance/features/apiSpaces/changingFilesShare.feature @@ -0,0 +1,39 @@ +@api @skipOnOcV10 +Feature: + + Background: + Given using spaces DAV path + And these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + + @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/from_alice.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/from_alice.txt" to "PARENT (1)/from_alice.txt" in space "Shares Jail" using the WebDAV API + Then the HTTP status code should be "201" + And for user "Carol" folder "PARENT" of the space "Shares Jail" should not contain these entries: + | from_alice.txt | + And for user "Carol" folder "PARENT (1)" of the space "Shares Jail" should contain these entries: + | from_alice.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 for user "Brian" the content of the file "/textfile1.txt" of the space "Shares Jail" should be "this is a new content" + And for user "Alice" the content of the file "/textfile1.txt" of the space "Personal" should be "this is a new content" diff --git a/tests/acceptance/features/apiSpaces/moveSpaces.feature b/tests/acceptance/features/apiSpaces/moveSpaces.feature index 6d34fd37fa2..0d743ed0344 100644 --- a/tests/acceptance/features/apiSpaces/moveSpaces.feature +++ b/tests/acceptance/features/apiSpaces/moveSpaces.feature @@ -198,6 +198,8 @@ Feature: move (rename) file Then the HTTP status code should be "201" And for user "Alice" folder "testshare2" of the space "Shares Jail" should contain these entries: | testshare1.txt | + And for user "Alice" folder "testshare1" of the space "Shares Jail" should not contain these entries: + | testshare1.txt | And for user "Brian" the space "Personal" should contain these entries: | /testshare2/testshare1.txt | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index a498656b54e..eaee3dc526b 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1346,6 +1346,20 @@ public function verifyTableNodeColumnsCount( } } + /** + * Escapes the given string for + * 1. Space --> %20 + * 2. Opening Small Bracket --> %28 + * 3. Closing Small Bracket --> %29 + * + * @param string $path - File path to parse + * + * @return string + */ + public function escapePath(string $path): string { + return \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $path); + } + /** * parses a PROPFIND response from $this->response into xml * and returns found search results if found else returns false @@ -1375,6 +1389,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 = $this->escapePath($folderPath); + // topWebDavPath should be something like /remote.php/webdav/ or // /remote.php/dav/files/alice/ $topWebDavPath = "/" . "dav/spaces/" . $spaceId . "/" . $folderPath; @@ -1850,6 +1867,7 @@ public function userCopiesFileWithinSpaceUsingTheWebDAVAPI( * @param string $spaceName * * @return void + * @throws GuzzleException */ public function userMovesFileWithinSpaceUsingTheWebDAVAPI( string $user, @@ -1864,10 +1882,42 @@ public function userMovesFileWithinSpaceUsingTheWebDAVAPI( $spaceName ); - $fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/"); + $fileSource = $this->escapePath(\trim($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 * @@ -1889,6 +1939,9 @@ public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array $headers, ) ); + $this->featureContext->pushToLastHttpStatusCodesArray( + (string)$this->featureContext->getResponse()->getStatusCode() + ); } /** @@ -1953,7 +2006,10 @@ 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 = $this->escapePath(\ltrim($fileDestination, "/")); + + return $space["root"]["webDavUrl"] . '/' . $fileDestination; } /**