Merge pull request #4413 from owncloud/ocis-2141/add-removed-space-examples

[tests-only] restore scenarios removed from core#40302
This commit is contained in:
Artur Neumann
2022-08-29 12:21:01 +05:45
committed by GitHub
4 changed files with 103 additions and 2 deletions

View File

@@ -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)

View File

@@ -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"

View File

@@ -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 |

View File

@@ -1346,6 +1346,20 @@ class SpacesContext implements Context {
}
}
/**
* 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 @@ class SpacesContext implements Context {
// 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 @@ class SpacesContext implements Context {
* @param string $spaceName
*
* @return void
* @throws GuzzleException
*/
public function userMovesFileWithinSpaceUsingTheWebDAVAPI(
string $user,
@@ -1864,10 +1882,42 @@ class SpacesContext implements Context {
$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 @@ class SpacesContext implements Context {
$headers,
)
);
$this->featureContext->pushToLastHttpStatusCodesArray(
(string)$this->featureContext->getResponse()->getStatusCode()
);
}
/**
@@ -1953,7 +2006,10 @@ class SpacesContext implements Context {
*/
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;
}
/**