aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:49:12 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-26 10:49:12 +0100
commit62d7885c3b13d7d2acf33f80e91016a82cc8a7c0 (patch)
treead5a60fea2bc3db8ed813f8b1e149d5a35b27009 /tests
parente9237dd83ce50091274a52335846eb03f1694bb0 (diff)
parent8213d5df4f40410f851da31082bbb1fb8d84dd1e (diff)
downloadnextcloud-server-62d7885c3b13d7d2acf33f80e91016a82cc8a7c0.tar.gz
nextcloud-server-62d7885c3b13d7d2acf33f80e91016a82cc8a7c0.zip
Merge pull request #22660 from owncloud/fix_22656
Do not allow sharing of the users root folder
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share20/managertest.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php
index 22ca41cb501..2c40bf65c2c 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
*/