mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-05 19:09:56 -05:00
Added test for the copy with file-id in url (#7308)
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
Feature: copying file using file id
|
||||
As a user
|
||||
I want to copy the file using file id
|
||||
So that I can manage my resource
|
||||
|
||||
Background:
|
||||
Given using spaces DAV path
|
||||
And user "Alice" has been created with default attributes and without skeleton files
|
||||
|
||||
|
||||
Scenario Outline: copy a file into a folder in 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" copies 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" the space "Personal" should contain these entries:
|
||||
| folder/textfile.txt |
|
||||
| textfile.txt |
|
||||
Examples:
|
||||
| dav-path |
|
||||
| /remote.php/dav/spaces/<<FILEID>> |
|
||||
| /dav/spaces/<<FILEID>> |
|
||||
|
||||
|
||||
Scenario Outline: copy a file into a sub-folder in 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" copies 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" the space "Personal" should contain these entries:
|
||||
| folder/sub-folder/textfile.txt |
|
||||
| textfile.txt |
|
||||
Examples:
|
||||
| dav-path |
|
||||
| /remote.php/dav/spaces/<<FILEID>> |
|
||||
| /dav/spaces/<<FILEID>> |
|
||||
|
||||
|
||||
Scenario Outline: copy a file from a folder into root of 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" copies 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 |
|
||||
| folder/textfile.txt |
|
||||
Examples:
|
||||
| dav-path |
|
||||
| /remote.php/dav/spaces/<<FILEID>> |
|
||||
| /dav/spaces/<<FILEID>> |
|
||||
|
||||
|
||||
Scenario Outline: copy a file from sub-folder into root of 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" copies 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 |
|
||||
| folder/sub-folder/textfile.txt |
|
||||
Examples:
|
||||
| dav-path |
|
||||
| /remote.php/dav/spaces/<<FILEID>> |
|
||||
| /dav/spaces/<<FILEID>> |
|
||||
@@ -1753,15 +1753,19 @@ class SpacesContext implements Context {
|
||||
* @param string $user
|
||||
* @param string $fileDestination
|
||||
* @param string $spaceName
|
||||
* @param string|null $endPath
|
||||
*
|
||||
* @return string
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function destinationHeaderValueWithSpaceName(string $user, string $fileDestination, string $spaceName):string {
|
||||
public function destinationHeaderValueWithSpaceName(string $user, string $fileDestination, string $spaceName, string $endPath = null):string {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
|
||||
$fileDestination = $this->escapePath(\ltrim($fileDestination, "/"));
|
||||
|
||||
if ($endPath && str_contains($endPath, 'remote.php')) {
|
||||
// this is check for when we want to test with the endpoint having `remote.php` in space webdav
|
||||
// by default spaces webdav is '/dav/spaces'
|
||||
return $this->featureContext->getBaseUrl() . '/remote.php/dav/spaces/' . $space['id'] . '/' . $fileDestination;
|
||||
}
|
||||
return $space["root"]["webDavUrl"] . '/' . $fileDestination;
|
||||
}
|
||||
|
||||
@@ -1786,6 +1790,27 @@ class SpacesContext implements Context {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" copies a file "([^"]*)" into "([^"]*)" inside space "([^"]*)" using file-id path "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $sourceFile
|
||||
* @param string $destinationFile
|
||||
* @param string $toSpaceName
|
||||
* @param string $url
|
||||
*
|
||||
* @throws GuzzleException
|
||||
* @return void
|
||||
*/
|
||||
public function userCopiesFileWithFileIdFromAndToSpaceBetweenSpaces(string $user, 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), "/"));
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $url);
|
||||
$fullUrl = $this->featureContext->getBaseUrl() . $url;
|
||||
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has uploaded a file inside space "([^"]*)" with content "([^"]*)" to "([^"]*)"$/
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user