Merge pull request #2769 from owncloud/archivesRessourcePaths
[tests-only] use archiver endpoint with path
This commit is contained in:
3 files changed
+192
-17
No files matched your search
@@ -3,3 +3,6 @@
|
|||||||
#### [downloading the /Shares folder using the archiver endpoint does not work](https://github.com/owncloud/ocis/issues/2751)
|
#### [downloading the /Shares folder using the archiver endpoint does not work](https://github.com/owncloud/ocis/issues/2751)
|
||||||
- [apiArchiver/downloadById.feature:134](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadById.feature#L134)
|
- [apiArchiver/downloadById.feature:134](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadById.feature#L134)
|
||||||
- [apiArchiver/downloadById.feature:135](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadById.feature#L135)
|
- [apiArchiver/downloadById.feature:135](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadById.feature#L135)
|
||||||
|
|
||||||
|
#### [downloading an archive with invalid path returns HTTP/500](https://github.com/owncloud/ocis/issues/2768)
|
||||||
|
- [apiArchiver/downloadByPath.feature:69](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/apiArchiver/downloadByPath.feature#L69)
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
@api @skipOnOcV10
|
||||||
|
Feature: download multiple resources bundled into an archive
|
||||||
|
As a user
|
||||||
|
I want to be able to download multiple items at once
|
||||||
|
So that I don't have to execute repetitive tasks
|
||||||
|
|
||||||
|
As a developer
|
||||||
|
I want to be able to use the full path of the resource to download multiple items at once
|
||||||
|
So that I don't have to know the ID of the resource
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given user "Alice" has been created with default attributes and without skeleton files
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: download a single file
|
||||||
|
Given user "Alice" has uploaded file with content "some data" to "/textfile0.txt"
|
||||||
|
When user "Alice" downloads the archive of "/home/textfile0.txt" using the resource path and setting these headers
|
||||||
|
| header | value |
|
||||||
|
| User-Agent | <user-agent> |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the downloaded <archive-type> archive should contain these files:
|
||||||
|
| name | content |
|
||||||
|
| textfile0.txt | some data |
|
||||||
|
Examples:
|
||||||
|
| user-agent | archive-type |
|
||||||
|
| Linux | tar |
|
||||||
|
| Windows NT | zip |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: download a single folder
|
||||||
|
Given user "Alice" has created folder "my_data"
|
||||||
|
And user "Alice" has uploaded file with content "some data" to "/my_data/textfile0.txt"
|
||||||
|
And user "Alice" has uploaded file with content "more data" to "/my_data/an_other_file.txt"
|
||||||
|
When user "Alice" downloads the archive of "/home/my_data" using the resource path and setting these headers
|
||||||
|
| header | value |
|
||||||
|
| User-Agent | <user-agent> |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the downloaded <archive-type> archive should contain these files:
|
||||||
|
| name | content |
|
||||||
|
| my_data/textfile0.txt | some data |
|
||||||
|
| my_data/an_other_file.txt | more data |
|
||||||
|
Examples:
|
||||||
|
| user-agent | archive-type |
|
||||||
|
| Linux | tar |
|
||||||
|
| Windows NT | zip |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: download multiple files and folders
|
||||||
|
Given user "Alice" has uploaded file with content "some data" to "/textfile0.txt"
|
||||||
|
And user "Alice" has uploaded file with content "other data" to "/textfile1.txt"
|
||||||
|
And user "Alice" has created folder "my_data"
|
||||||
|
And user "Alice" has uploaded file with content "some data" to "/my_data/textfile2.txt"
|
||||||
|
And user "Alice" has created folder "more_data"
|
||||||
|
And user "Alice" has uploaded file with content "more data" to "/more_data/an_other_file.txt"
|
||||||
|
When user "Alice" downloads the archive of these items using the resource paths
|
||||||
|
| /home/textfile0.txt |
|
||||||
|
| /home/textfile1.txt |
|
||||||
|
| /home/my_data |
|
||||||
|
| /home/more_data |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the downloaded tar archive should contain these files:
|
||||||
|
| name | content |
|
||||||
|
| textfile0.txt | some data |
|
||||||
|
| textfile1.txt | other data |
|
||||||
|
| my_data/textfile2.txt | some data |
|
||||||
|
| more_data/an_other_file.txt | more data |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: download a not existing single file
|
||||||
|
When user "Alice" downloads the archive of "/doesnotexist.txt" of user "Alice" using the resource path
|
||||||
|
Then the HTTP status code should be "400"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: download multiple shared items as share receiver
|
||||||
|
Given user "Brian" 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 uploaded file with content "other data" to "/textfile1.txt"
|
||||||
|
And user "Alice" has created folder "my_data"
|
||||||
|
And user "Alice" has uploaded file with content "some data" to "/my_data/textfile2.txt"
|
||||||
|
And user "Alice" has created folder "more_data"
|
||||||
|
And user "Alice" has uploaded file with content "more data" to "/more_data/an_other_file.txt"
|
||||||
|
And user "Alice" has shared file "textfile0.txt" with user "Brian"
|
||||||
|
And user "Alice" has shared file "textfile1.txt" with user "Brian"
|
||||||
|
And user "Alice" has shared folder "my_data" with user "Brian"
|
||||||
|
And user "Alice" has shared folder "more_data" with user "Brian"
|
||||||
|
And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice"
|
||||||
|
And user "Brian" has accepted share "/textfile1.txt" offered by user "Alice"
|
||||||
|
And user "Brian" has accepted share "/my_data" offered by user "Alice"
|
||||||
|
And user "Brian" has accepted share "/more_data" offered by user "Alice"
|
||||||
|
When user "Brian" downloads the archive of these items using the resource path
|
||||||
|
| /home/Shares/textfile0.txt |
|
||||||
|
| /home/Shares/textfile1.txt |
|
||||||
|
| /home/Shares/my_data |
|
||||||
|
| /home/Shares/more_data |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the downloaded tar archive should contain these files:
|
||||||
|
| name | content |
|
||||||
|
| textfile0.txt | some data |
|
||||||
|
| textfile1.txt | other data |
|
||||||
|
| my_data/textfile2.txt | some data |
|
||||||
|
| more_data/an_other_file.txt | more data |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: download the Shares folder as share receiver
|
||||||
|
Given user "Brian" 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 uploaded file with content "other data" to "/textfile1.txt"
|
||||||
|
And user "Alice" has created folder "my_data"
|
||||||
|
And user "Alice" has uploaded file with content "some data" to "/my_data/textfile2.txt"
|
||||||
|
And user "Alice" has created folder "more_data"
|
||||||
|
And user "Alice" has uploaded file with content "more data" to "/more_data/an_other_file.txt"
|
||||||
|
And user "Alice" has shared file "textfile0.txt" with user "Brian"
|
||||||
|
And user "Alice" has shared file "textfile1.txt" with user "Brian"
|
||||||
|
And user "Alice" has shared folder "my_data" with user "Brian"
|
||||||
|
And user "Alice" has shared folder "more_data" with user "Brian"
|
||||||
|
And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice"
|
||||||
|
And user "Brian" has accepted share "/textfile1.txt" offered by user "Alice"
|
||||||
|
And user "Brian" has accepted share "/my_data" offered by user "Alice"
|
||||||
|
And user "Brian" has accepted share "/more_data" offered by user "Alice"
|
||||||
|
When user "Brian" downloads the archive of "/home/Shares" using the resource path and setting these headers
|
||||||
|
| header | value |
|
||||||
|
| User-Agent | <user-agent> |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the downloaded <archive-type> archive should contain these files:
|
||||||
|
| name | content |
|
||||||
|
| Shares/textfile0.txt | some data |
|
||||||
|
| Shares/textfile1.txt | other data |
|
||||||
|
| Shares/my_data/textfile2.txt | some data |
|
||||||
|
| Shares/more_data/an_other_file.txt | more data |
|
||||||
|
Examples:
|
||||||
|
| user-agent | archive-type |
|
||||||
|
| Linux | tar |
|
||||||
|
| Windows NT | zip |
|
||||||
@@ -63,19 +63,52 @@ class ArchiverContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When user :user downloads the archive of :resourceId using the resource id and setting these headers
|
* @param string $user
|
||||||
|
* @param string $resource
|
||||||
|
* @param string $addressType id|ids|path|paths
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private function getArchiverQueryString(
|
||||||
|
string $user,
|
||||||
|
string $resource,
|
||||||
|
string $addressType
|
||||||
|
): string {
|
||||||
|
switch ($addressType) {
|
||||||
|
case 'id':
|
||||||
|
case 'ids':
|
||||||
|
return 'id=' . $this->featureContext->getFileIdForPath($user, $resource);
|
||||||
|
break;
|
||||||
|
case 'path':
|
||||||
|
case 'paths':
|
||||||
|
return 'path=' . $resource;
|
||||||
|
default:
|
||||||
|
throw new Exception(
|
||||||
|
'"' . $addressType .
|
||||||
|
'" is not a legal value for $addressType, must be id|ids|path|paths'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When user :user downloads the archive of :resource using the resource :addressType and setting these headers
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $resource
|
* @param string $resource
|
||||||
|
* @param string $addressType id|path
|
||||||
* @param TableNode $headersTable
|
* @param TableNode $headersTable
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function userDownloadsTheArchiveOfUsingTheResourceId(
|
public function userDownloadsTheArchive(
|
||||||
string $user,
|
string $user,
|
||||||
string $resource,
|
string $resource,
|
||||||
|
string $addressType,
|
||||||
TableNode $headersTable
|
TableNode $headersTable
|
||||||
): void {
|
): void {
|
||||||
$this->featureContext->verifyTableNodeColumns(
|
$this->featureContext->verifyTableNodeColumns(
|
||||||
@@ -86,11 +119,12 @@ class ArchiverContext implements Context {
|
|||||||
foreach ($headersTable as $row) {
|
foreach ($headersTable as $row) {
|
||||||
$headers[$row['header']] = $row ['value'];
|
$headers[$row['header']] = $row ['value'];
|
||||||
}
|
}
|
||||||
$resourceId = $this->featureContext->getFileIdForPath($user, $resource);
|
|
||||||
$user = $this->featureContext->getActualUsername($user);
|
$user = $this->featureContext->getActualUsername($user);
|
||||||
|
$queryString = $this->getArchiverQueryString($user, $resource, $addressType);
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
HttpRequestHelper::get(
|
HttpRequestHelper::get(
|
||||||
$this->featureContext->getBaseUrl() . '/archiver?id=' . $resourceId,
|
$this->featureContext->getBaseUrl() . '/archiver?' . $queryString,
|
||||||
'',
|
'',
|
||||||
$user,
|
$user,
|
||||||
$this->featureContext->getPasswordForUser($user),
|
$this->featureContext->getPasswordForUser($user),
|
||||||
@@ -100,26 +134,29 @@ class ArchiverContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When user :downloader downloads the archive of :item of user :owner using the resource id
|
* @When user :downloader downloads the archive of :item of user :owner using the resource :addressType
|
||||||
*
|
*
|
||||||
* @param string $downloader Who sends the request
|
* @param string $downloader Who sends the request
|
||||||
* @param string $resource
|
* @param string $resource
|
||||||
* @param string $owner Who is the real owner of the file
|
* @param string $owner Who is the real owner of the file
|
||||||
|
* @param string $addressType id|path
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function userDownloadsTheArchiveOfItemOfUserUsingTheResourceId(
|
public function userDownloadsTheArchiveOfItemOfUser(
|
||||||
string $downloader,
|
string $downloader,
|
||||||
string $resource,
|
string $resource,
|
||||||
string $owner
|
string $owner,
|
||||||
|
string $addressType
|
||||||
): void {
|
): void {
|
||||||
$resourceId = $this->featureContext->getFileIdForPath($owner, $resource);
|
|
||||||
$downloader = $this->featureContext->getActualUsername($downloader);
|
$downloader = $this->featureContext->getActualUsername($downloader);
|
||||||
|
$queryString = $this->getArchiverQueryString($owner, $resource, $addressType);
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
HttpRequestHelper::get(
|
HttpRequestHelper::get(
|
||||||
$this->featureContext->getBaseUrl() . '/archiver?id=' . $resourceId,
|
$this->featureContext->getBaseUrl() . '/archiver?' . $queryString,
|
||||||
'',
|
'',
|
||||||
$downloader,
|
$downloader,
|
||||||
$this->featureContext->getPasswordForUser($downloader),
|
$this->featureContext->getPasswordForUser($downloader),
|
||||||
@@ -128,29 +165,31 @@ class ArchiverContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When user :arg1 downloads the archive of these items using the resource ids
|
* @When user :user downloads the archive of these items using the resource :addressType
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param TableNode $items
|
* @param TableNode $items
|
||||||
|
* @param string $addressType ids|paths
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||||
*/
|
*/
|
||||||
public function userDownloadsTheArchiveOfTheseItemsUsingTheResourceIds(
|
public function userDownloadsTheArchiveOfTheseItems(
|
||||||
string $user,
|
string $user,
|
||||||
TableNode $items
|
TableNode $items,
|
||||||
|
string $addressType
|
||||||
): void {
|
): void {
|
||||||
$user = $this->featureContext->getActualUsername($user);
|
$user = $this->featureContext->getActualUsername($user);
|
||||||
$resourceIdsString = '';
|
$queryString = '';
|
||||||
foreach ($items->getRows() as $item) {
|
foreach ($items->getRows() as $item) {
|
||||||
$fileId = $this->featureContext->getFileIdForPath($user, $item[0]);
|
$queryString .= $this->getArchiverQueryString($user, $item[0], $addressType) . '&';
|
||||||
$resourceIdsString .= 'id=' . $fileId . '&';
|
|
||||||
}
|
}
|
||||||
$resourceIdsString = \rtrim($resourceIdsString, '&');
|
|
||||||
|
$queryString = \rtrim($queryString, '&');
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
HttpRequestHelper::get(
|
HttpRequestHelper::get(
|
||||||
$this->featureContext->getBaseUrl() . '/archiver?' . $resourceIdsString,
|
$this->featureContext->getBaseUrl() . '/archiver?' . $queryString,
|
||||||
'',
|
'',
|
||||||
$user,
|
$user,
|
||||||
$this->featureContext->getPasswordForUser($user),
|
$this->featureContext->getPasswordForUser($user),
|
||||||
|
|||||||
Reference in new issue
Block a user