From a3c3ec9dd7e6d0145fac195a4338c11592589450 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Thu, 13 Oct 2016 13:16:30 +0000 Subject: [PATCH 1/5] Added functions to check etag of elements --- .../integration/features/bootstrap/WebDav.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index cdb1fc3fdf..c59d035d1e 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 array */ + 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]); + } } From 7d9e031abe5f9a864d38adfb114756ac1fcf4608 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Fri, 14 Oct 2016 07:33:46 +0000 Subject: [PATCH 2/5] Changed description of variable --- build/integration/features/bootstrap/WebDav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index c59d035d1e..69962a7282 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -42,7 +42,7 @@ trait WebDav { private $davPath = "remote.php/webdav"; /** @var ResponseInterface */ private $response; - /** @var array */ + /** @var map with user as key and another map as value, which has path as key and etag as value */ private $storedETAG = NULL; /** From 3135d3a7b2be8eb73704ee3b1d75a8c8a81209f0 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Fri, 14 Oct 2016 08:58:44 +0000 Subject: [PATCH 3/5] Added test case about issue 26346 --- build/integration/features/sharing-v1.feature | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature index 9b19690d6d..07a59fd72b 100644 --- a/build/integration/features/sharing-v1.feature +++ b/build/integration/features/sharing-v1.feature @@ -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 From e5bc45c34934ea16af622d5cafe5c4946f688c20 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 25 Oct 2016 10:18:42 +0200 Subject: [PATCH 4/5] Fix OCS API to be able to remove group shares from self as recipient Signed-off-by: Roeland Jago Douma --- .../lib/Controller/ShareAPIController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index ad9ac6c085..0d62ba48ed 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -245,11 +245,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(); } From ea786a35a63fcc85d8487901eeec1f88b6fda078 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 27 Oct 2016 20:40:03 +0200 Subject: [PATCH 5/5] Fix intergration tests Signed-off-by: Roeland Jago Douma --- build/integration/features/sharing-v1.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature index 07a59fd72b..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