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

API test for createShare #31436

Merged
merged 1 commit into from
May 15, 2018
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
42 changes: 24 additions & 18 deletions tests/acceptance/features/apiSharing-v1/createShare.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ Feature: sharing
Scenario: Creating a new share with user
Given user "user0" has been created
And user "user1" has been created
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
When user "user0" shares file "welcome.txt" with user "user1" using the API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| share_with | user1 |
| file_target | /welcome.txt |
| path | /welcome.txt |
| permissions | 19 |
| uid_owner | user0 |

Scenario: Creating a share with a group
Given user "user0" has been created
Expand All @@ -24,6 +27,12 @@ Feature: sharing
| shareType | 1 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| share_with | sharing-group |
| file_target | /welcome.txt |
| path | /welcome.txt |
| permissions | 19 |
| uid_owner | user0 |

Scenario: Creating a new share with user who already received a share through their group
Given user "user0" has been created
Expand All @@ -37,6 +46,12 @@ Feature: sharing
| shareType | 0 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| share_with | user1 |
| file_target | /welcome.txt |
| path | /welcome.txt |
| permissions | 19 |
| uid_owner | user0 |

Scenario: Creating a new public share
Given user "user0" has been created
Expand All @@ -60,21 +75,12 @@ Feature: sharing
Scenario: Creating a new public share of a folder
Given user "user0" has been created
When user "user0" creates a share using the API with settings
| path | FOLDER |
| shareType | 3 |
| password | publicpw |
| expireDate | +3 days |
| publicUpload | true |
| permissions | 7 |
| path | PARENT |
| shareType | 3 |
| password | publicpw |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| id | A_NUMBER |
| permissions | 15 |
| expiration | +3 days |
| url | AN_URL |
| token | A_TOKEN |
| mimetype | httpd/unix-directory |
Then the public should be able to download the range "bytes=1-7" of file "/parent.txt" from inside the last public shared folder with password "publicpw" and the content should be "wnCloud"

Scenario: Creating a new share with a disabled user
Given user "user0" has been created
Expand Down Expand Up @@ -275,4 +281,4 @@ Feature: sharing
| shareWith | user1 |
| shareType | 0 |
| permissions | 0 |
Then the OCS status code should be "400"
Then the OCS status code should be "400"
45 changes: 44 additions & 1 deletion tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ public function downloadPublicFileWithRange($range) {
public function downloadPublicFileInsideAFolderWithRange($path, $range) {
$token = $this->lastShareData->data->token;
$fullUrl = $this->getBaseUrl() . "/public.php/webdav" . "$path";

$client = new GClient();
$options = [];
$options['auth'] = [$token, ""];
Expand All @@ -343,6 +342,50 @@ public function downloadPublicFileInsideAFolderWithRange($path, $range) {
$this->response = $client->send($request);
}

/**
* @When /^the public downloads file "([^"]*)" from inside the last public shared folder with password "([^"]*)" with range "([^"]*)" using the API$/
*
* @param string $path
* @param string $password
* @param string $range
*
* @return void
*/
public function publicDownloadsTheFileInsideThePublicSharedFolderWithPassword(
$path, $password, $range
) {
$token = $this->lastShareData->data->token;
$fullUrl = $this->getBaseUrl() . "/public.php/webdav" . "$path";
$client = new GClient();
$options = [];
$options['auth'] = [$token, $password];
$options['headers']['X-Requested-With'] = 'XMLHttpRequest';

$request = $client->createRequest("GET", $fullUrl, $options);
$request->addHeader('Range', $range);

$this->response = $client->send($request);
}

/**
* @Then /^the public should be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public shared folder with password "([^"]*)" and the content should be "([^"]*)"$/
*
* @param string $range
* @param string $path
* @param string $password
* @param string $content
*
* @return void
*/
public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPassword(
$range, $path, $password, $content
) {
$this->publicDownloadsTheFileInsideThePublicSharedFolderWithPassword(
$path, $password, $range
);
$this->downloadedContentShouldBe($content);
}

/**
* @Then /^the downloaded content should be "([^"]*)"$/
*
Expand Down