diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-28 15:57:16 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-28 15:57:16 +0200 |
commit | aacfe93fa2e78f8dc9cf2998465d492cf91ae4af (patch) | |
tree | c9e34e57c8038e0146336ac728e14f5ba459217e /tests | |
parent | f87d492118b7c9cc4c76b725042df396a989a218 (diff) | |
parent | 823f2d205deac080693f2dbdbfad686de48ed3ee (diff) | |
download | nextcloud-server-aacfe93fa2e78f8dc9cf2998465d492cf91ae4af.tar.gz nextcloud-server-aacfe93fa2e78f8dc9cf2998465d492cf91ae4af.zip |
Merge pull request #15609 from owncloud/stable8-share-donotreturntrashedfiles
[stable8] Do not return shares for files outside "files"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share/share.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 42bb82968af..43539866508 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -101,6 +101,7 @@ class Test_Share extends \Test\TestCase { OC_Group::deleteGroup($this->group2); OC_Group::deleteGroup($this->groupAndUser); + $this->logout(); parent::tearDown(); } @@ -388,6 +389,45 @@ class Test_Share extends \Test\TestCase { $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share['share_type']); } + public function testGetShareFromOutsideFilesFolder() { + OC_User::setUserId($this->user1); + $view = new \OC\Files\View('/' . $this->user1 . '/'); + $view->mkdir('files/test'); + $view->mkdir('files/test/sub'); + + $view->mkdir('files_trashbin'); + $view->mkdir('files_trashbin/files'); + + $fileInfo = $view->getFileInfo('files/test/sub'); + $fileId = $fileInfo->getId(); + + $this->assertTrue( + OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ), + 'Failed asserting that user 1 successfully shared "test/sub" with user 2.' + ); + + $result = OCP\Share::getItemShared('folder', $fileId, Test_Share_Backend::FORMAT_SOURCE); + $this->assertNotEmpty($result); + + $result = OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2); + $this->assertNotEmpty($result); + + $result = OCP\Share::getItemsSharedWithUser('folder', $this->user2); + $this->assertNotEmpty($result); + + // move to trash (keeps file id) + $view->rename('files/test', 'files_trashbin/files/test'); + + $result = OCP\Share::getItemShared('folder', $fileId, Test_Share_Backend::FORMAT_SOURCE); + $this->assertEmpty($result, 'Share must not be returned for files outside of "files"'); + + $result = OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2); + $this->assertEmpty($result, 'Share must not be returned for files outside of "files"'); + + $result = OCP\Share::getItemsSharedWithUser('folder', $this->user2); + $this->assertEmpty($result, 'Share must not be returned for files outside of "files"'); + } + public function testSetExpireDateInPast() { OC_User::setUserId($this->user1); $this->shareUserOneTestFileWithUserTwo(); |