Skip to content

Commit

Permalink
Add more tests coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed Jul 20, 2023
1 parent 88fd279 commit 35acb8a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
48 changes: 43 additions & 5 deletions tests/acceptance/features/apiSpaces/spaceDownload.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,59 @@ Feature: Download space
So that I can store it locally


Scenario: user downloads a space
Given user "Alice" has been created with default attributes and without skeleton files
Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Bob |
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 uploaded a file inside space "Project-space" with content "other data" to "file2.txt"
And user "Alice" has uploaded a file inside space "Project-space" with content "more data" to "file3.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 |
| file3.txt | more 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 and space admin tries to downloads other user space
Given the administrator has assigned the role "<userRole>" to user "Bob" using the Graph API
When user "Bob" 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 can't 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"
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 !== '') ? $owner : $user, $spaceName);
$url = $this->featureContext->getBaseUrl() . '/archiver?id=' . $space['id'];
$this->featureContext->setResponse(
HttpRequestHelper::get(
$url,
Expand Down

0 comments on commit 35acb8a

Please sign in to comment.