diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 4f80b8fc96..1358663ea2 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -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')); } - $this->shareManager->deleteShare($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(); } diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index cdb1fc3fdf..69962a7282 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -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]); + } } diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature index 9b19690d6d..4d913876cc 100644 --- a/build/integration/features/sharing-v1.feature +++ b/build/integration/features/sharing-v1.feature @@ -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