mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-05 14:43:30 -04:00
[tests-only] add API test coverage for file MOVE to space-id as destination (#8459)
This commit is contained in:
@@ -706,3 +706,67 @@ Feature: moving/renaming file using file id
|
||||
| dav-path |
|
||||
| /remote.php/dav/spaces/<<FILEID>> |
|
||||
| /dav/spaces/<<FILEID>> |
|
||||
|
||||
@issue-6739
|
||||
Scenario Outline: try to move personal file to other spaces using its id as the destination
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has created a space "myspace" with the default quota using the Graph API
|
||||
And user "Alice" has uploaded file with content "some data" to "textfile.txt"
|
||||
When user "Alice" tries to move file "textfile.txt" of space "Personal" to space "<space>" using its id in destination path "<dav-path>"
|
||||
Then the HTTP status code should be "400"
|
||||
And for user "Alice" the space "Personal" should contain these entries:
|
||||
| textfile.txt |
|
||||
Examples:
|
||||
| dav-path | space |
|
||||
| /remote.php/dav/spaces | Personal |
|
||||
| /dav/spaces | Personal |
|
||||
| /remote.php/dav/spaces | myspace |
|
||||
| /dav/spaces | myspace |
|
||||
|
||||
@issue-6739
|
||||
Scenario Outline: try to move project file to other spaces using its id as the destination
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has created a space "myspace" with the default quota using the Graph API
|
||||
And user "Alice" has uploaded a file inside space "myspace" with content "some data" to "textfile.txt"
|
||||
When user "Alice" tries to move file "textfile.txt" of space "myspace" to space "<space>" using its id in destination path "<dav-path>"
|
||||
Then the HTTP status code should be "400"
|
||||
And for user "Alice" the space "myspace" should contain these entries:
|
||||
| textfile.txt |
|
||||
Examples:
|
||||
| dav-path | space |
|
||||
| /remote.php/dav/spaces | Personal |
|
||||
| /dav/spaces | Personal |
|
||||
| /remote.php/dav/spaces | myspace |
|
||||
| /dav/spaces | myspace |
|
||||
|
||||
@issue-6739
|
||||
Scenario Outline: move a file to folder using its id as the destination (Personal space)
|
||||
Given user "Alice" has uploaded file with content "some data" to "textfile.txt"
|
||||
And user "Alice" has created folder "docs"
|
||||
When user "Alice" moves file "textfile.txt" of space "Personal" to folder "docs" using its id in destination path "<dav-path>"
|
||||
Then the HTTP status code should be "204"
|
||||
And the content of file "docs" for user "Alice" should be "some data"
|
||||
And as "Alice" file "textfile.txt" should not exist
|
||||
And as "Alice" folder "docs" should not exist
|
||||
And as "Alice" folder "docs" should exist in the trashbin of the space "Personal"
|
||||
Examples:
|
||||
| dav-path |
|
||||
| /remote.php/dav/spaces |
|
||||
| /dav/spaces |
|
||||
|
||||
@issue-6739
|
||||
Scenario Outline: move a file to folder using its id as the destination (Project space)
|
||||
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||
And user "Alice" has created a space "myspace" with the default quota using the Graph API
|
||||
And user "Alice" has uploaded a file inside space "myspace" with content "some data" to "textfile.txt"
|
||||
And user "Alice" has created a folder "docs" in space "myspace"
|
||||
When user "Alice" moves file "textfile.txt" of space "myspace" to folder "docs" using its id in destination path "<dav-path>"
|
||||
Then the HTTP status code should be "204"
|
||||
And for user "Alice" the content of the file "docs" of the space "myspace" should be "some data"
|
||||
And as "Alice" folder "docs" should exist in the trashbin of the space "myspace"
|
||||
And for user "Alice" folder "/" of the space "myspace" should not contain these files:
|
||||
| textfile.txt |
|
||||
Examples:
|
||||
| dav-path |
|
||||
| /remote.php/dav/spaces |
|
||||
| /dav/spaces |
|
||||
|
||||
@@ -2060,6 +2060,48 @@ class SpacesContext implements Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" tries to move (?:file|folder) "([^"]*)" of space "([^"]*)" to (space|folder) "([^"]*)" using its id in destination path "([^"]*)"$/
|
||||
* @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" of space "([^"]*)" to (folder) "([^"]*)" using its id in destination path "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $source
|
||||
* @param string $sourceSpace
|
||||
* @param string $destinationType
|
||||
* @param string $destinationName
|
||||
* @param string $destinationPath
|
||||
*
|
||||
* @throws GuzzleException
|
||||
* @return void
|
||||
*/
|
||||
public function userMovesFileToResourceUsingItsIdAsDestinationPath(
|
||||
string $user,
|
||||
string $source,
|
||||
string $sourceSpace,
|
||||
string $destinationType,
|
||||
string $destinationName,
|
||||
string $destinationPath
|
||||
): void {
|
||||
$source = \trim($source, "/");
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
$suffix = "";
|
||||
if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
$suffix = $this->getSpaceIdByName($user, $sourceSpace) . "/";
|
||||
}
|
||||
$fullUrl = $baseUrl . \rtrim($destinationPath, "/") . "/{$suffix}{$source}";
|
||||
|
||||
$destinationId = "";
|
||||
if ($destinationType === "space") {
|
||||
$destinationId = $this->getSpaceIdByName($user, $destinationName);
|
||||
} else {
|
||||
$destinationId = $this->getResourceId($user, $sourceSpace, $destinationName);
|
||||
}
|
||||
$headers['Destination'] = $baseUrl . \rtrim($destinationPath, "/") . "/$destinationId";
|
||||
|
||||
$response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has uploaded a file inside space "([^"]*)" with content "([^"]*)" to "([^"]*)"$/
|
||||
*
|
||||
|
||||
@@ -1752,9 +1752,12 @@ trait WebDav {
|
||||
} else {
|
||||
$actualResourceType = "folder";
|
||||
}
|
||||
Assert::fail(
|
||||
"$entry '$path' should not exist. But it does exist and is a $actualResourceType"
|
||||
);
|
||||
|
||||
if ($entry === $actualResourceType) {
|
||||
Assert::fail(
|
||||
"$entry '$path' should not exist. But it does."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user