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][full-ci] Extend space download tests coverage #6854

Merged
merged 1 commit into from
Jul 24, 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
1 change: 1 addition & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ config = {
"apiSpacesShares",
"apiCors",
"apiAsyncUpload",
"apiDownloads",
],
"skip": False,
},
Expand Down
21 changes: 20 additions & 1 deletion tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ default:
- SpacesTUSContext:
- GraphContext:
- OcisConfigContext:
- ArchiverContext:

apiSpacesShares:
paths:
Expand Down Expand Up @@ -211,6 +210,26 @@ default:
- OcisConfigContext:
- PublicWebDavContext:

apiDownloads:
paths:
- '%paths.base%/../features/apiDownloads'
context: *common_ldap_suite_context
contexts:
- NotificationContext:
- SpacesContext:
- FeatureContext: *common_feature_context_params
- WebDavPropertiesContext:
- OCSContext:
- GraphContext:
- TrashbinContext:
- FavoritesContext:
- ChecksumContext:
- FilesVersionsContext:
- SettingsContext:
- OcisConfigContext:
- PublicWebDavContext:
- ArchiverContext:

extensions:
rdx\behatvars\BehatVariablesExtension: ~

Expand Down
62 changes: 62 additions & 0 deletions tests/acceptance/features/apiDownloads/spaceDownload.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@api
Feature: Download space
As a user
I want to download space
So that I can store it locally


Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
And using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "Project-space" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "Project-space" with content "some data" to "file1.txt"
And user "Alice" has created a folder ".space" in space "Project-space"
And user "Alice" has uploaded a file inside space "Project-space" with content "space description" to ".space/readme.md"


Scenario: user downloads a space
Given user "Alice" has uploaded a file inside space "Project-space" with content "other data" to "file2.txt"
When user "Alice" downloads the space "Project-space" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded "tar" archive should contain these files:
| name | content |
| file1.txt | some data |
| file2.txt | other data |
| .space/readme.md | space description |


Scenario Outline: user downloads a shared space (shared by others)
Given user "Alice" has shared a space "Project-space" with settings:
| shareWith | Brian |
| role | <role> |
When user "Brian" downloads the space "Project-space" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded "tar" archive should contain these files:
| name | content |
| file1.txt | some data |
| .space/readme.md | space description |
Examples:
| role |
| manager |
| editor |
| viewer |


Scenario Outline: admin/space-admin tries to download a space that they do not have access to
Given the administrator has assigned the role "<userRole>" to user "Brian" using the Graph API
When user "Brian" tries to download the space "Project-space" owned by user "Alice" using the WebDAV API
Then the HTTP status code should be "404"
Examples:
| userRole |
| Admin |
| Space Admin |


Scenario: user tries to download disabled space
Given user "Alice" has disabled a space "Project-space"
When user "Alice" tries to download the space "Project-space" using the WebDAV API
Then the HTTP status code should be "404"
25 changes: 0 additions & 25 deletions tests/acceptance/features/apiSpaces/spaceDownload.feature

This file was deleted.

10 changes: 6 additions & 4 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3242,18 +3242,20 @@ public function theUserShouldHaveSpaceWithRecipient(
}

/**
* @When user :user downloads the space :spaceName using the WebDAV API
* @When user :user tries to download the space :spaceName owned by user :owner using the WebDAV API
* @When /^user "([^"]*)" (?:downloads|tries to download) the space "([^"]*)" using the WebDAV API$/
*
* @param string $user
* @param string $spaceName
* @param string $owner
*
* @return void
*
* @throws GuzzleException
*/
public function userDownloadsTheSpaceUsingTheWebdavApi(string $user, string $spaceName):void {
$space = $this->getSpaceByName($user, $spaceName);
$url = $this->featureContext->getBaseUrl() . '/archiver?id=' . $space["id"];
public function userDownloadsTheSpaceUsingTheWebdavApi(string $user, string $spaceName, string $owner = ''):void {
$space = $this->getSpaceByName($owner ?: $user, $spaceName);
$url = $this->featureContext->getBaseUrl() . '/archiver?id=' . $space['id'];
$this->featureContext->setResponse(
HttpRequestHelper::get(
$url,
Expand Down