diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-01-22 10:40:29 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-01-22 10:40:29 +0100 |
commit | b5b491d1bb12a869ddae7878e8aa441109419a00 (patch) | |
tree | 5e5c8eb7e023fdc1c0131b88f91611079815be96 /tests | |
parent | 5f3c6a97b2e41fc6255cc602a863805e3dfa3671 (diff) | |
parent | 9f137ac25991da89425f6140dc5e078bd0f7d21d (diff) | |
download | nextcloud-server-b5b491d1bb12a869ddae7878e8aa441109419a00.tar.gz nextcloud-server-b5b491d1bb12a869ddae7878e8aa441109419a00.zip |
Merge pull request #13509 from owncloud/share-deletechildrenwhenunsharefromgroup
Fix reshare permission change to not impair other deletion code
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share/share.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index b1261b0afbd..4b42036fc22 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -44,11 +44,13 @@ class Test_Share extends \Test\TestCase { $this->user2 = $this->getUniqueID('user2_'); $this->user3 = $this->getUniqueID('user3_'); $this->user4 = $this->getUniqueID('user4_'); + $this->user5 = $this->getUniqueID('user5_'); $this->groupAndUser = $this->getUniqueID('groupAndUser_'); OC_User::createUser($this->user1, 'pass'); OC_User::createUser($this->user2, 'pass'); OC_User::createUser($this->user3, 'pass'); OC_User::createUser($this->user4, 'pass'); + OC_User::createUser($this->user5, 'pass'); OC_User::createUser($this->groupAndUser, 'pass'); OC_User::setUserId($this->user1); OC_Group::clearBackends(); @@ -610,6 +612,51 @@ class Test_Share extends \Test\TestCase { $this->assertEquals(array(), OCP\Share::getItemsShared('test')); } + /** + * Test that unsharing from group will also delete all + * child entries + */ + public function testShareWithGroupThenUnshare() { + OC_User::setUserId($this->user5); + OCP\Share::shareItem( + 'test', + 'test.txt', + OCP\Share::SHARE_TYPE_GROUP, + $this->group1, + \OCP\Constants::PERMISSION_ALL + ); + + $targetUsers = array($this->user1, $this->user2, $this->user3); + + foreach($targetUsers as $targetUser) { + OC_User::setUserId($targetUser); + $items = OCP\Share::getItemsSharedWithUser( + 'test', + $targetUser, + Test_Share_Backend::FORMAT_TARGET + ); + $this->assertEquals(1, count($items)); + } + + OC_User::setUserId($this->user5); + OCP\Share::unshare( + 'test', + 'test.txt', + OCP\Share::SHARE_TYPE_GROUP, + $this->group1 + ); + + // verify that all were deleted + foreach($targetUsers as $targetUser) { + OC_User::setUserId($targetUser); + $items = OCP\Share::getItemsSharedWithUser( + 'test', + $targetUser, + Test_Share_Backend::FORMAT_TARGET + ); + $this->assertEquals(0, count($items)); + } + } public function testShareWithGroupAndUserBothHaveTheSameId() { |