diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-25 20:22:35 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-25 20:40:30 +0100 |
commit | 8213d5df4f40410f851da31082bbb1fb8d84dd1e (patch) | |
tree | 5cb4c2bf7612ca317abc02b73512170624a5b2e6 /tests/lib/share20 | |
parent | 3772a8acdb611b441bf2ea4fa3e0a37110a9d69f (diff) | |
download | nextcloud-server-8213d5df4f40410f851da31082bbb1fb8d84dd1e.tar.gz nextcloud-server-8213d5df4f40410f851da31082bbb1fb8d84dd1e.zip |
Do not allow sharing of the root folder
Sharing of the users root folder should not be allowed as it is very
weird UX. Also many of our clients have no proper way of displaying
this.
Added unit test
Also added intergration tests to make sure we won't allow it in the
future.
Diffstat (limited to 'tests/lib/share20')
-rw-r--r-- | tests/lib/share20/managertest.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index c41f0754396..df688f782c4 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -677,6 +677,9 @@ class ManagerTest extends \Test\TestCase { ['group0', true], ])); + $userFolder = $this->getMock('\OCP\Files\Folder'); + $this->rootFolder->method('getUserFolder')->willReturn($userFolder); + try { $this->invokePrivate($this->manager, 'generalCreateChecks', [$share]); $thrown = false; @@ -692,6 +695,32 @@ class ManagerTest extends \Test\TestCase { } /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage You can't share your root folder + */ + public function testGeneralCheckShareRoot() { + $thrown = null; + + $this->userManager->method('userExists')->will($this->returnValueMap([ + ['user0', true], + ['user1', true], + ])); + + $userFolder = $this->getMock('\OCP\Files\Folder'); + $userFolder->method('isSubNode')->with($userFolder)->willReturn(false); + $this->rootFolder->method('getUserFolder')->willReturn($userFolder); + + $share = $this->manager->newShare(); + + $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedWith('user0') + ->setSharedBy('user1') + ->setNode($userFolder); + + $this->invokePrivate($this->manager, 'generalCreateChecks', [$share]); + } + + /** * @expectedException \OCP\Share\Exceptions\GenericShareException * @expectedExceptionMessage Expiration date is in the past */ |