Merge pull request #1887 from nextcloud/downstream-26370

Added functions to check etag of elements - integration tests
This commit is contained in:
Morris Jobke 2016-11-02 14:57:45 +01:00 committed by GitHub
commit ffebc050d0
3 changed files with 55 additions and 3 deletions

View File

@ -270,11 +270,17 @@ class ShareAPIController extends OCSController {
throw new OCSNotFoundException($this->l->t('could not delete share'));
}
if (!$this->canAccessShare($share, false)) {
if (!$this->canAccessShare($share)) {
throw new OCSNotFoundException($this->l->t('Could not delete share'));
}
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP &&
$share->getShareOwner() !== $this->currentUser &&
$share->getSharedBy() !== $this->currentUser) {
$this->shareManager->deleteFromSelf($share, $this->currentUser);
} else {
$this->shareManager->deleteShare($share);
}
return new DataResponse();
}

View File

@ -42,6 +42,8 @@ trait WebDav {
private $davPath = "remote.php/webdav";
/** @var ResponseInterface */
private $response;
/** @var map with user as key and another map as value, which has path as key and etag as value */
private $storedETAG = NULL;
/**
* @Given /^using dav path "([^"]*)"$/
@ -599,4 +601,33 @@ trait WebDav {
public function asGetsPropertiesOfFileWith($user, $path, $propertiesTable) {
$this->asGetsPropertiesOfFolderWith($user, $path, $propertiesTable);
}
/**
* @Given user :user stores etag of element :path
*/
public function userStoresEtagOfElement($user, $path){
$propertiesTable = new \Behat\Gherkin\Node\TableNode([['{DAV:}getetag']]);
$this->asGetsPropertiesOfFolderWith($user, $path, $propertiesTable);
$pathETAG[$path] = $this->response['{DAV:}getetag'];
$this->storedETAG[$user]= $pathETAG;
print_r($this->storedETAG[$user][$path]);
}
/**
* @Then etag of element :path of user :user has not changed
*/
public function checkIfETAGHasNotChanged($path, $user){
$propertiesTable = new \Behat\Gherkin\Node\TableNode([['{DAV:}getetag']]);
$this->asGetsPropertiesOfFolderWith($user, $path, $propertiesTable);
PHPUnit_Framework_Assert::assertEquals($this->response['{DAV:}getetag'], $this->storedETAG[$user][$path]);
}
/**
* @Then etag of element :path of user :user has changed
*/
public function checkIfETAGHasChanged($path, $user){
$propertiesTable = new \Behat\Gherkin\Node\TableNode([['{DAV:}getetag']]);
$this->asGetsPropertiesOfFolderWith($user, $path, $propertiesTable);
PHPUnit_Framework_Assert::assertNotEquals($this->response['{DAV:}getetag'], $this->storedETAG[$user][$path]);
}
}

View File

@ -775,7 +775,7 @@ Feature: sharing
| shareWith | group1 |
When As an "user1"
And Deleting last share
Then the OCS status code should be "404"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
Scenario: Merging shares for recipient when shared from outside with group and member
@ -952,3 +952,18 @@ Feature: sharing
| shareType | 1 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
Scenario: unshare from self
Given As an "admin"
And user "user0" exists
And user "user1" exists
And group "sharing-group" exists
And user "user0" belongs to group "sharing-group"
And user "user1" belongs to group "sharing-group"
And file "/PARENT/parent.txt" of user "user0" is shared with group "sharing-group"
And user "user0" stores etag of element "/PARENT"
And user "user1" stores etag of element "/"
And As an "user1"
When Deleting last share
Then etag of element "/" of user "user1" has changed
And etag of element "/PARENT" of user "user0" has not changed