diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-13 10:05:49 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-10-13 10:05:49 +0200 |
commit | 06aaa059d177e42d6bf674a22588ccc98f91b3e1 (patch) | |
tree | ac517bc26236e1fedfeb82ef0e907ec922e69e28 /tests | |
parent | 1f146d678c115ba9e6894e5ee6f8f5f3978f0dd9 (diff) | |
download | nextcloud-server-06aaa059d177e42d6bf674a22588ccc98f91b3e1.tar.gz nextcloud-server-06aaa059d177e42d6bf674a22588ccc98f91b3e1.zip |
Squash collection shares
If folder1 is shared to user2 and user3. And folder1/folder2 is shared
to user4 and user5 then getting all the users with access to
folder1/folder2 should only list user2 and user 3 once.
Previously this was done twice since we request the info two times.
This fix makes sure that we only append unique results to the array.
* Added test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share/share.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 4cb0577cc8c..fc1357fe6e7 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -1679,6 +1679,62 @@ class Test_Share extends \Test\TestCase { $config->deleteAppValue('core', 'shareapi_default_expire_date'); $config->deleteAppValue('core', 'shareapi_expire_after_n_days'); } + + /** + * Test case for #17560 + */ + public function testAccesToSharedSubFolder() { + OC_User::setUserId($this->user1); + $view = new \OC\Files\View('/' . $this->user1 . '/'); + $view->mkdir('files/folder1'); + + $fileInfo = $view->getFileInfo('files/folder1'); + $this->assertInstanceOf('\OC\Files\FileInfo', $fileInfo); + $fileId = $fileInfo->getId(); + + $this->assertTrue( + OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL), + 'Failed asserting that user 1 successfully shared "test" with user 2.' + ); + $this->assertTrue( + OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_ALL), + 'Failed asserting that user 1 successfully shared "test" with user 3.' + ); + + $view->mkdir('files/folder1/folder2'); + + $fileInfo = $view->getFileInfo('files/folder1/folder2'); + $this->assertInstanceOf('\OC\Files\FileInfo', $fileInfo); + $fileId = $fileInfo->getId(); + + $this->assertTrue( + OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user4, \OCP\Constants::PERMISSION_ALL), + 'Failed asserting that user 1 successfully shared "test" with user 4.' + ); + + $res = OCP\Share::getItemShared( + 'folder', + $fileId, + OCP\Share::FORMAT_NONE, + null, + true + ); + $this->assertCount(3, $res); + + $this->assertTrue( + OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user5, \OCP\Constants::PERMISSION_ALL), + 'Failed asserting that user 1 successfully shared "test" with user 5.' + ); + + $res = OCP\Share::getItemShared( + 'folder', + $fileId, + OCP\Share::FORMAT_NONE, + null, + true + ); + $this->assertCount(4, $res); + } } class DummyShareClass extends \OC\Share\Share { |