Merge pull request #20828 from owncloud/sharing_integration_test_20645_morris
Sharing integration test 20645, added sabre dav and propfind check.
This commit is contained in:
commit
b0491bf930
|
@ -3,6 +3,7 @@
|
||||||
"phpunit/phpunit": "~4.6",
|
"phpunit/phpunit": "~4.6",
|
||||||
"behat/behat": "^3.0",
|
"behat/behat": "^3.0",
|
||||||
"guzzlehttp/guzzle": "~5.0",
|
"guzzlehttp/guzzle": "~5.0",
|
||||||
"jarnaiz/behat-junit-formatter": "^1.3"
|
"jarnaiz/behat-junit-formatter": "^1.3",
|
||||||
|
"sabre/dav": "3.0.x-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,14 @@ trait BasicStructure{
|
||||||
if (!file_exists("../../core/skeleton/FOLDER")) {
|
if (!file_exists("../../core/skeleton/FOLDER")) {
|
||||||
mkdir("../../core/skeleton/FOLDER", 0777, true);
|
mkdir("../../core/skeleton/FOLDER", 0777, true);
|
||||||
}
|
}
|
||||||
|
if (!file_exists("../../core/skeleton/PARENT")) {
|
||||||
|
mkdir("../../core/skeleton/PARENT", 0777, true);
|
||||||
|
}
|
||||||
|
file_put_contents("../../core/skeleton/PARENT/" . "parent.txt", "ownCloud test text file\n");
|
||||||
|
if (!file_exists("../../core/skeleton/PARENT/CHILD")) {
|
||||||
|
mkdir("../../core/skeleton/PARENT/CHILD", 0777, true);
|
||||||
|
}
|
||||||
|
file_put_contents("../../core/skeleton/PARENT/CHILD/" . "child.txt", "ownCloud test text file\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +173,16 @@ trait BasicStructure{
|
||||||
if (is_dir("../../core/skeleton/FOLDER")) {
|
if (is_dir("../../core/skeleton/FOLDER")) {
|
||||||
rmdir("../../core/skeleton/FOLDER");
|
rmdir("../../core/skeleton/FOLDER");
|
||||||
}
|
}
|
||||||
|
self::removeFile("../../core/skeleton/PARENT/CHILD/", "child.txt");
|
||||||
|
if (is_dir("../../core/skeleton/PARENT/CHILD")) {
|
||||||
|
rmdir("../../core/skeleton/PARENT/CHILD");
|
||||||
|
}
|
||||||
|
self::removeFile("../../core/skeleton/PARENT/", "parent.txt");
|
||||||
|
if (is_dir("../../core/skeleton/PARENT")) {
|
||||||
|
rmdir("../../core/skeleton/PARENT");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ trait Sharing{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^file "([^"]*)" from user "([^"]*)" is shared with user "([^"]*)"$/
|
* @Given /^file "([^"]*)" of user "([^"]*)" is shared with user "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function assureFileIsShared($filepath, $user1, $user2){
|
public function assureFileIsShared($filepath, $user1, $user2){
|
||||||
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath";
|
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath";
|
||||||
|
@ -295,7 +295,7 @@ trait Sharing{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^file "([^"]*)" from user "([^"]*)" is shared with group "([^"]*)"$/
|
* @Given /^file "([^"]*)" of user "([^"]*)" is shared with group "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function assureFileIsSharedWithGroup($filepath, $user, $group){
|
public function assureFileIsSharedWithGroup($filepath, $user, $group){
|
||||||
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath";
|
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares" . "?path=$filepath";
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Behat\Behat\Context\SnippetAcceptingContext;
|
use Behat\Behat\Context\SnippetAcceptingContext;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client as GClient;
|
||||||
use GuzzleHttp\Message\ResponseInterface;
|
use GuzzleHttp\Message\ResponseInterface;
|
||||||
|
use Sabre\DAV\Client as SClient;
|
||||||
|
|
||||||
require __DIR__ . '/../../vendor/autoload.php';
|
require __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ trait WebDav{
|
||||||
|
|
||||||
public function makeDavRequest($user, $method, $path, $headers){
|
public function makeDavRequest($user, $method, $path, $headers){
|
||||||
$fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path";
|
$fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path";
|
||||||
$client = new Client();
|
$client = new GClient();
|
||||||
$options = [];
|
$options = [];
|
||||||
if ($user === 'admin') {
|
if ($user === 'admin') {
|
||||||
$options['auth'] = $this->adminUser;
|
$options['auth'] = $this->adminUser;
|
||||||
|
@ -30,10 +31,11 @@ trait WebDav{
|
||||||
$options['auth'] = [$user, $this->regularUser];
|
$options['auth'] = [$user, $this->regularUser];
|
||||||
}
|
}
|
||||||
$request = $client->createRequest($method, $fullUrl, $options);
|
$request = $client->createRequest($method, $fullUrl, $options);
|
||||||
|
if (!is_null($headers)){
|
||||||
foreach ($headers as $key => $value) {
|
foreach ($headers as $key => $value) {
|
||||||
$request->addHeader($key, $value);
|
$request->addHeader($key, $value);
|
||||||
}
|
}
|
||||||
//$this->response = $client->send($request);
|
}
|
||||||
return $client->send($request);
|
return $client->send($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,5 +58,64 @@ trait WebDav{
|
||||||
$this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers);
|
$this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When /^Downloading file "([^"]*)" with range "([^"]*)"$/
|
||||||
|
*/
|
||||||
|
public function downloadFileWithRange($fileSource, $range){
|
||||||
|
$fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath;
|
||||||
|
$headers['Range'] = $range;
|
||||||
|
$this->response = $this->makeDavRequest($this->currentUser, "GET", $fileSource, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^Downloaded content should be "([^"]*)"$/
|
||||||
|
*/
|
||||||
|
public function downloadedContentShouldBe($content){
|
||||||
|
PHPUnit_Framework_Assert::assertEquals($content, (string)$this->response->getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Returns the elements of a propfind, $folderDepth requires 1 to see elements without children*/
|
||||||
|
public function listFolder($user, $path, $folderDepth){
|
||||||
|
$fullUrl = substr($this->baseUrl, 0, -4);
|
||||||
|
|
||||||
|
$settings = array(
|
||||||
|
'baseUri' => $fullUrl,
|
||||||
|
'userName' => $user,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($user === 'admin') {
|
||||||
|
$settings['password'] = $this->adminUser[1];
|
||||||
|
} else {
|
||||||
|
$settings['password'] = $this->regularUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
$client = new SClient($settings);
|
||||||
|
|
||||||
|
$response = $client->propfind($this->davPath . "/", array(
|
||||||
|
'{DAV:}getetag'
|
||||||
|
), $folderDepth);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^user "([^"]*)" should see following elements$/
|
||||||
|
* @param \Behat\Gherkin\Node\TableNode|null $expectedElements
|
||||||
|
*/
|
||||||
|
public function checkElementList($user, $expectedElements){
|
||||||
|
$elementList = $this->listFolder($user, '/', 2);
|
||||||
|
if ($expectedElements instanceof \Behat\Gherkin\Node\TableNode) {
|
||||||
|
$elementRows = $expectedElements->getRows();
|
||||||
|
$elementsSimplified = $this->simplifyArray($elementRows);
|
||||||
|
foreach($elementsSimplified as $expectedElement) {
|
||||||
|
$webdavPath = "/" . $this->davPath . $expectedElement;
|
||||||
|
if (!array_key_exists($webdavPath,$elementList)){
|
||||||
|
PHPUnit_Framework_Assert::fail("$webdavPath" . " is not in propfind answer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ Feature: sharing
|
||||||
Scenario: getting all shares of a user using that user
|
Scenario: getting all shares of a user using that user
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And As an "user0"
|
And As an "user0"
|
||||||
When sending "GET" to "/apps/files_sharing/api/v1/shares"
|
When sending "GET" to "/apps/files_sharing/api/v1/shares"
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
|
@ -209,7 +209,7 @@ Feature: sharing
|
||||||
Scenario: getting all shares of a user using another user
|
Scenario: getting all shares of a user using another user
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And As an "admin"
|
And As an "admin"
|
||||||
When sending "GET" to "/apps/files_sharing/api/v1/shares"
|
When sending "GET" to "/apps/files_sharing/api/v1/shares"
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
|
@ -221,8 +221,8 @@ Feature: sharing
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And user "user2" exists
|
And user "user2" exists
|
||||||
And user "user3" exists
|
And user "user3" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user2"
|
And file "textfile0.txt" of user "user0" is shared with user "user2"
|
||||||
And As an "user0"
|
And As an "user0"
|
||||||
When sending "GET" to "/apps/files_sharing/api/v1/shares?path=textfile0.txt"
|
When sending "GET" to "/apps/files_sharing/api/v1/shares?path=textfile0.txt"
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
|
@ -236,8 +236,8 @@ Feature: sharing
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And user "user2" exists
|
And user "user2" exists
|
||||||
And user "user3" exists
|
And user "user3" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And file "textfile0.txt" from user "user1" is shared with user "user2"
|
And file "textfile0.txt" of user "user1" is shared with user "user2"
|
||||||
And As an "user0"
|
And As an "user0"
|
||||||
When sending "GET" to "/apps/files_sharing/api/v1/shares?reshares=true&path=textfile0.txt"
|
When sending "GET" to "/apps/files_sharing/api/v1/shares?reshares=true&path=textfile0.txt"
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
|
@ -249,7 +249,7 @@ Feature: sharing
|
||||||
Scenario: getting share info of a share
|
Scenario: getting share info of a share
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And As an "user0"
|
And As an "user0"
|
||||||
When Getting info of last share
|
When Getting info of last share
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
|
@ -279,7 +279,7 @@ Feature: sharing
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And group "group1" exists
|
And group "group1" exists
|
||||||
And user "user1" belongs to group "group1"
|
And user "user1" belongs to group "group1"
|
||||||
And file "textfile0.txt" from user "user0" is shared with group "group1"
|
And file "textfile0.txt" of user "user0" is shared with group "group1"
|
||||||
And User "user1" moved file "/textfile0.txt" to "/FOLDER/textfile0.txt"
|
And User "user1" moved file "/textfile0.txt" to "/FOLDER/textfile0.txt"
|
||||||
And As an "user0"
|
And As an "user0"
|
||||||
When Updating last share with
|
When Updating last share with
|
||||||
|
@ -306,7 +306,7 @@ Feature: sharing
|
||||||
Scenario: Sharee can see the share
|
Scenario: Sharee can see the share
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And As an "user1"
|
And As an "user1"
|
||||||
When sending "GET" to "/apps/files_sharing/api/v1/shares?shared_with_me=true"
|
When sending "GET" to "/apps/files_sharing/api/v1/shares?shared_with_me=true"
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
|
@ -357,19 +357,35 @@ Feature: sharing
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And user "user2" exists
|
And user "user2" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And As an "user2"
|
And As an "user2"
|
||||||
When Getting info of last share
|
When Getting info of last share
|
||||||
Then the OCS status code should be "404"
|
Then the OCS status code should be "404"
|
||||||
And the HTTP status code should be "200"
|
And the HTTP status code should be "200"
|
||||||
|
|
||||||
|
Scenario: Share of folder and sub-folder to same user - core#20645
|
||||||
|
Given As an "admin"
|
||||||
|
And user "user0" exists
|
||||||
|
And user "user1" exists
|
||||||
|
And group "group0" exists
|
||||||
|
And user "user1" belongs to group "group0"
|
||||||
|
And file "/PARENT" of user "user0" is shared with user "user1"
|
||||||
|
When file "/PARENT/CHILD" of user "user0" is shared with group "group0"
|
||||||
|
Then user "user1" should see following elements
|
||||||
|
| /FOLDER/ |
|
||||||
|
| /PARENT/ |
|
||||||
|
| /CHILD/ |
|
||||||
|
| /PARENT/parent.txt |
|
||||||
|
| /CHILD/child.txt |
|
||||||
|
And the HTTP status code should be "200"
|
||||||
|
|
||||||
Scenario: Delete all group shares
|
Scenario: Delete all group shares
|
||||||
Given As an "admin"
|
Given As an "admin"
|
||||||
And user "user0" exists
|
And user "user0" exists
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And group "group1" exists
|
And group "group1" exists
|
||||||
And user "user1" belongs to group "group1"
|
And user "user1" belongs to group "group1"
|
||||||
And file "textfile0.txt" from user "user0" is shared with group "group1"
|
And file "textfile0.txt" of user "user0" is shared with group "group1"
|
||||||
And User "user1" moved file "/textfile0.txt" to "/FOLDER/textfile0.txt"
|
And User "user1" moved file "/textfile0.txt" to "/FOLDER/textfile0.txt"
|
||||||
And As an "user0"
|
And As an "user0"
|
||||||
And Deleting last share
|
And Deleting last share
|
||||||
|
@ -382,7 +398,7 @@ Feature: sharing
|
||||||
Scenario: delete a share
|
Scenario: delete a share
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
And user "user1" exists
|
And user "user1" exists
|
||||||
And file "textfile0.txt" from user "user0" is shared with user "user1"
|
And file "textfile0.txt" of user "user0" is shared with user "user1"
|
||||||
And As an "user0"
|
And As an "user0"
|
||||||
When Deleting last share
|
When Deleting last share
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
|
|
|
@ -9,6 +9,12 @@ Feature: sharing
|
||||||
When User "user0" moves file "/textfile0.txt" to "/FOLDER/textfile0.txt"
|
When User "user0" moves file "/textfile0.txt" to "/FOLDER/textfile0.txt"
|
||||||
Then the HTTP status code should be "201"
|
Then the HTTP status code should be "201"
|
||||||
|
|
||||||
|
Scenario: download a file with range
|
||||||
|
Given using dav path "remote.php/webdav"
|
||||||
|
And As an "admin"
|
||||||
|
When Downloading file "/welcome.txt" with range "bytes=51-77"
|
||||||
|
Then Downloaded content should be "example file for developers"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue