Overwriting a file while moving and moving

This commit is contained in:
Viktor Scharf
2022-10-13 20:23:08 +02:00
parent 24807bbac8
commit 07dc73f382
5 changed files with 137 additions and 1 deletions

View File

@@ -37,3 +37,8 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSpacesShares/shareUploadTUS.feature:204](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareUploadTUS.feature#L204)
- [apiSpacesShares/shareUploadTUS.feature:219](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareUploadTUS.feature#L219)
- [apiSpacesShares/shareUploadTUS.feature:284](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareUploadTUS.feature#L284)
### [Copy or move on an existing resource doesn't create a new version but deletes instead](https://github.com/owncloud/ocis/issues/4797)
- [apiSpacesShares/moveSpaces.feature:304](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/moveSpaces.feature#L304)
- [apiSpacesShares/copySpaces.feature:711](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/copySpaces.feature#L711)
- [apiSpacesShares/copySpaces.feature:748](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/copySpaces.feature#L748)

View File

@@ -28,7 +28,8 @@ Feature:
Scenario: overwrite a received file share
Given user "Alice" has uploaded file with content "this is the old content" to "/textfile1.txt"
Given user "Alice" has uploaded file with content "old content version 1" to "/textfile1.txt"
And user "Alice" has uploaded file with content "old content version 2" 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
@@ -37,3 +38,9 @@ Feature:
| 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"
When user "Alice" downloads version of the file "/textfile1.txt" with the index "2" of the space "Personal" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 1"
When user "Brian" downloads version of the file "/textfile1.txt" with the index "1" of the space "Shares Jail" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 2"

View File

@@ -692,3 +692,77 @@ Feature: copy file
| /second-level-folder/second-level-folder |
And the response when user "Alice" gets the info of the last share should include
| file_target | /Shares/BRIAN-FOLDER |
Scenario: Copying a file with an option "keep both" inside of the project space
Given the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "Project" with the default quota using the GraphApi
And user "Alice" has created a folder "/newfolder" in space "Project"
And user "Alice" has uploaded a file inside space "Project" with content "some content" to "/newfolder/insideSpace.txt"
And user "Alice" has uploaded a file inside space "Project" with content "new content" to "/insideSpace.txt"
When user "Alice" copies file "/insideSpace.txt" to "/newfolder/insideSpace (1).txt" inside space "Project" using the WebDAV API
Then the HTTP status code should be "201"
And for user "Alice" the space "Project" should contain these entries:
| newfolder/insideSpace.txt |
| newfolder/insideSpace (1).txt |
And for user "Alice" the content of the file "/newfolder/insideSpace (1).txt" of the space "Project" should be "new content"
Scenario: Copying a file with an option "replace" inside of the project space
Given the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "Project" with the default quota using the GraphApi
And user "Alice" has created a folder "/newfolder" in space "Project"
And user "Alice" has uploaded a file inside space "Project" with content "old content version 1" to "/newfolder/insideSpace.txt"
And user "Alice" has uploaded a file inside space "Project" with content "old content version 2" to "/newfolder/insideSpace.txt"
And user "Alice" has uploaded a file inside space "Project" with content "new content" to "/insideSpace.txt"
When user "Alice" overwrites file "/insideSpace.txt" from space "Project" to "/newfolder/insideSpace.txt" inside space "Project" while copying using the WebDAV API
Then the HTTP status code should be "204"
And for user "Alice" the content of the file "/newfolder/insideSpace.txt" of the space "Project" should be "new content"
When user "Alice" downloads version of the file "/newfolder/insideSpace.txt" with the index "2" of the space "Project" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 1"
When user "Alice" downloads version of the file "/newfolder/insideSpace.txt" with the index "1" of the space "Project" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 2"
Scenario: Copying a file from Personal to Shares Jail with an option "keep both"
Given the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "Project" with the default quota using the GraphApi
And user "Alice" has created a folder "/newfolder" in space "Project"
And user "Alice" has uploaded a file inside space "Project" with content "some content" to "/newfolder/personal.txt"
And user "Alice" shares the following entity "newfolder" inside of space "Project" with user "Brian" with role "editor"
And user "Brian" has accepted share "/newfolder" offered by user "Alice"
And user "Brian" has uploaded file with content "new content" to "/personal.txt"
When user "Brian" copies file "/personal.txt" from space "Personal" to "/newfolder/personal (1).txt" inside space "Shares Jail" using the WebDAV API
Then the HTTP status code should be "201"
And for user "Alice" the space "Project" should contain these entries:
| newfolder/personal.txt |
| newfolder/personal (1).txt |
And for user "Alice" the content of the file "/newfolder/personal (1).txt" of the space "Project" should be "new content"
And for user "Brian" the space "Shares Jail" should contain these entries:
| newfolder/personal.txt |
| newfolder/personal (1).txt |
Scenario: Copying a file from Personal to Shares Jail with an option "replace"
Given the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "Project" with the default quota using the GraphApi
And user "Alice" has created a folder "/newfolder" in space "Project"
And user "Alice" has uploaded a file inside space "Project" with content "old content version 1" to "/newfolder/personal.txt"
And user "Alice" has uploaded a file inside space "Project" with content "old content version 2" to "/newfolder/personal.txt"
And user "Alice" shares the following entity "newfolder" inside of space "Project" with user "Brian" with role "editor"
And user "Brian" has accepted share "/newfolder" offered by user "Alice"
And user "Brian" has uploaded file with content "new content" to "/personal.txt"
When user "Brian" overwrites file "/personal.txt" from space "Personal" to "/newfolder/personal.txt" inside space "Shares Jail" while copying using the WebDAV API
Then the HTTP status code should be "204"
And for user "Alice" the space "Project" should contain these entries:
| newfolder/personal.txt |
And for user "Alice" the content of the file "/newfolder/personal.txt" of the space "Project" should be "new content"
When user "Alice" downloads version of the file "/newfolder/personal.txt" with the index "1" of the space "Project" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 2"
And for user "Brian" the content of the file "/newfolder/personal.txt" of the space "Shares Jail" should be "new content"
When user "Brian" downloads version of the file "/newfolder/personal.txt" with the index "2" of the space "Shares Jail" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 1"

View File

@@ -300,3 +300,21 @@ Feature: move (rename) file
| testsubfolder |
And for user "Brian" the space "Personal" should not contain these entries:
| /testshare/testsubfolder |
Scenario: Overwriting a file while moving
Given user "Brian" has created folder "/folder"
And user "Brian" has uploaded file with content "old content version 1" to "/folder/testfile.txt"
And user "Brian" has uploaded file with content "old content version 2" to "/folder/testfile.txt"
And user "Brian" has uploaded file with content "new data" to "/testfile.txt"
When user "Brian" overwrites file "/testfile.txt" from space "Personal" to "folder/testfile.txt" inside space "Personal" while moving using the WebDAV API
Then the HTTP status code should be "204"
And the content of file "/folder/testfile.txt" for user "Brian" should be "new data"
And for user "Brian" the space "Personal" should not contain these entries:
| /testfile.txt |
When user "Brian" downloads version of the file "/folder/testfile.txt" with the index "1" of the space "Personal" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 2"
When user "Brian" downloads version of the file "/folder/testfile.txt" with the index "2" of the space "Personal" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded content should be "old content version 1"

View File

@@ -1673,6 +1673,38 @@ class SpacesContext implements Context {
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
}
/**
* @When /^user "([^"]*)" overwrites file "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" while (copying|moving)\s? using the WebDAV API$/
*
* @param string $user
* @param string $fileSource
* @param string $fromSpaceName
* @param string $fileDestination
* @param string $toSpaceName
* @param string $action
*
* @return void
* @throws GuzzleException
*/
public function userOverwritesFileFromAndToSpaceBetweenSpaces(
string $user,
string $fileSource,
string $fromSpaceName,
string $fileDestination,
string $toSpaceName,
string $action
):void {
$space = $this->getSpaceByName($user, $fromSpaceName);
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName);
$headers['Overwrite'] = 'T';
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($fileSource, "/");
if ($action === 'copying') {
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
} else {
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
}
}
/**
* @Then /^user "([^"]*)" should not be able to download file "([^"]*)" from space "([^"]*)"$/
*