Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only]Added test for the move with file-id in web-dav-url #7318

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
Feature: moving/renaming file using file id
As a user
I want to be able to move or rename files using file id
So that I can manage my file system

Background:
Given using spaces DAV path
And user "Alice" has been created with default attributes and without skeleton files


Scenario Outline: move a file into a folder inside personal space
SagarGi marked this conversation as resolved.
Show resolved Hide resolved
Given user "Alice" has created folder "/folder"
And user "Alice" has uploaded file with content "some data" to "/textfile.txt"
And we save it into "FILEID"
When user "Alice" moves a file "/textfile.txt" into "/folder" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" folder "folder" of the space "Personal" should contain these files:
| textfile.txt |
But for user "Alice" the space "Personal" should not contain these entries:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: move a file into a sub-folder inside personal space
Given user "Alice" has created folder "/folder"
And user "Alice" has created folder "folder/sub-folder"
And user "Alice" has uploaded file with content "some data" to "/textfile.txt"
And we save it into "FILEID"
When user "Alice" moves a file "/textfile.txt" into "/folder/sub-folder" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" folder "folder/sub-folder/" of the space "Personal" should contain these files:
| textfile.txt |
But for user "Alice" the space "Personal" should not contain these entries:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: move a file from folder to root inside personal space
Given user "Alice" has created folder "/folder"
And user "Alice" has uploaded file with content "some data" to "folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" moves a file "folder/textfile.txt" into "/" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" the space "Personal" should contain these entries:
| textfile.txt |
But for user "Alice" folder "folder" of the space "Personal" should not contain these files:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: move a file from sub-folder to root inside personal space
Given user "Alice" has created folder "/folder"
And user "Alice" has created folder "folder/sub-folder"
And user "Alice" has uploaded file with content "some data" to "folder/sub-folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" moves a file "folder/sub-folder/textfile.txt" into "/" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" the space "Personal" should contain these entries:
| textfile.txt |
But for user "Alice" folder "folder/sub-folder" of the space "Personal" should not contain these files:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: rename a root file inside personal space
Given user "Alice" has uploaded file with content "some data" to "textfile.txt"
And we save it into "FILEID"
When user "Alice" renames a file "textfile.txt" into "renamed.txt" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" the space "Personal" should contain these entries:
| renamed.txt |
But for user "Alice" the space "Personal" should not contain these entries:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: rename a file and move into a folder inside personal space
Given user "Alice" has created folder "/folder"
And user "Alice" has uploaded file with content "some data" to "/textfile.txt"
And we save it into "FILEID"
When user "Alice" renames a file "textfile.txt" into "/folder/renamed.txt" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" folder "folder" of the space "Personal" should contain these files:
| renamed.txt |
But for user "Alice" the space "Personal" should not contain these entries:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: rename a file and move into a sub-folder inside personal space
Given user "Alice" has created folder "/folder"
And user "Alice" has created folder "folder/sub-folder"
And user "Alice" has uploaded file with content "some data" to "/textfile.txt"
And we save it into "FILEID"
When user "Alice" renames a file "textfile.txt" into "/folder/sub-folder/renamed.txt" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" folder "folder/sub-folder" of the space "Personal" should contain these files:
| renamed.txt |
But for user "Alice" the space "Personal" should not contain these entries:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: rename a file and move from a folder to root inside personal space
Given user "Alice" has created folder "/folder"
And user "Alice" has uploaded file with content "some data" to "folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" renames a file "folder/textfile.txt" into "/renamed.txt" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" the space "Personal" should contain these entries:
| renamed.txt |
But for user "Alice" folder "folder" of the space "Personal" should not contain these files:
| renamed.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: rename a file and move from sub-folder to root inside personal space
Given user "Alice" has created folder "/folder"
And user "Alice" has created folder "folder/sub-folder"
And user "Alice" has uploaded file with content "some data" to "folder/sub-folder/textfile.txt"
And we save it into "FILEID"
When user "Alice" renames a file "folder/sub-folder/textfile.txt" into "/renamed.txt" inside space "Personal" using file-id path "<dav-path>"
Then the HTTP status code should be "201"
And for user "Alice" the space "Personal" should contain these entries:
| renamed.txt |
But for user "Alice" folder "folder/sub-folder" of the space "Personal" should not contain these files:
| textfile.txt |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |
18 changes: 14 additions & 4 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1791,9 +1791,10 @@ public function copyFilesAndFoldersRequest(string $user, string $fullUrl, array
}

/**
* @When /^user "([^"]*)" copies a file "([^"]*)" into "([^"]*)" inside space "([^"]*)" using file-id path "([^"]*)"$/
* @When /^user "([^"]*)" (copies|moves|renames) a file "([^"]*)" into "([^"]*)" inside space "([^"]*)" using file-id path "([^"]*)"$/
*
* @param string $user
* @param string $actionType
* @param string $sourceFile
* @param string $destinationFile
* @param string $toSpaceName
Expand All @@ -1802,13 +1803,22 @@ public function copyFilesAndFoldersRequest(string $user, string $fullUrl, array
* @throws GuzzleException
* @return void
*/
public function userCopiesFileWithFileIdFromAndToSpaceBetweenSpaces(string $user, string $sourceFile, string $destinationFile, string $toSpaceName, string $url): void {
public function userCopiesOrMovesFileWithFileIdFromAndToSpaceBetweenSpaces(string $user, string $actionType, string $sourceFile, string $destinationFile, string $toSpaceName, string $url): void {
// split the source when there are sub-folders
$sourceFile = explode("/", $sourceFile);
$fileDestination = $this->escapePath(\ltrim($destinationFile, "/")) . '/' . $this->escapePath(\ltrim(end($sourceFile), "/"));
$fileDestination = '';
if ($actionType === 'copies' || $actionType === 'moves') {
$fileDestination = $this->escapePath(\ltrim($destinationFile, "/")) . '/' . $this->escapePath(\ltrim(end($sourceFile), "/"));
} elseif ($actionType === 'renames') {
$fileDestination = $destinationFile;
}
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $url);
$fullUrl = $this->featureContext->getBaseUrl() . $url;
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
if ($actionType === 'copies') {
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
} elseif ($actionType === 'moves' || $actionType === 'renames') {
$this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers));
}
}

/**
Expand Down