Commit 6936f45f authored by Sergio Bertolin's avatar Sergio Bertolin

Added test scenario for multiple link shares

parent 31d09676
......@@ -174,7 +174,8 @@ trait Sharing {
$shareWith = null,
$publicUpload = null,
$password = null,
$permissions = null){
$permissions = null,
$linkName = null) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares";
$client = new Client();
$options = [];
......@@ -203,6 +204,9 @@ trait Sharing {
if (!is_null($permissions)){
$fd['permissions'] = $permissions;
}
if (!is_null($linkName)){
$fd['name'] = $linkName;
}
$options['body'] = $fd;
......@@ -507,5 +511,47 @@ trait Sharing {
throw new \Exception('Expected the same link share to be returned');
}
}
/**
* @When /^user "([^"]*)" gets shares of (file|folder) "([^"]*)"$/
* @param string $user
* @param string $type
* @param string $path
* @param \Behat\Gherkin\Node\TableNode|null $body
*/
public function getShares($user, $type, $path, $TableNode){
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares";
$fullUrl = $fullUrl . '?path=' . $path;
$client = new Client();
$options = [];
if ($user === 'admin') {
$options['auth'] = $this->adminUser;
} else {
$options['auth'] = [$user, $this->regularUser];
}
$this->response = $client->send($client->createRequest("GET", $fullUrl, $options));
$dataResponded = $this->response->xml()->data->element;
if ($TableNode instanceof \Behat\Gherkin\Node\TableNode) {
$elementRows = $TableNode->getRows();
foreach($elementRows as $expectedElementsArray) {
//0 path, 1 permissions, 2 name
$nameFound = false;
foreach ($dataResponded as $elementResponded) {
if ((string)$elementResponded->name[0] === $expectedElementsArray[2]) {
PHPUnit_Framework_Assert::assertEquals($expectedElementsArray[0], (string)$elementResponded->path[0]);
PHPUnit_Framework_Assert::assertEquals($expectedElementsArray[1], (string)$elementResponded->permissions[0]);
$nameFound = true;
break;
}
}
PHPUnit_Framework_Assert::assertTrue($nameFound, "Shared link name " . $expectedElementsArray[2] . " not found");
}
}
}
}
......@@ -1161,3 +1161,44 @@ Feature: sharing
And as "user0" the folder "/sub" exists in trash
And as "user0" the file "/sub/shared_file.txt" exists in trash
Scenario: Creating three public shares of a folder
Given user "user0" exists
And As an "user0"
And creating a share with
| path | FOLDER |
| shareType | 3 |
| password | publicpw |
| expireDate | +3 days |
| publicUpload | true |
| permissions | 15 |
| name | sharedlink1 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And creating a share with
| path | FOLDER |
| shareType | 3 |
| password | publicpw |
| expireDate | +3 days |
| publicUpload | true |
| permissions | 15 |
| name | sharedlink2 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And creating a share with
| path | FOLDER |
| shareType | 3 |
| password | publicpw |
| expireDate | +3 days |
| publicUpload | true |
| permissions | 15 |
| name | sharedlink3 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
When Updating last share with
| permissions | 1 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "user0" gets shares of folder "/FOLDER"
| /FOLDER | 15 | sharedlink2 |
| /FOLDER | 15 | sharedlink1 |
| /FOLDER | 1 | sharedlink3 |
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment