summaryrefslogtreecommitdiffstats
path: root/tests/lib/Share20/ManagerTest.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-20 12:27:38 +0100
committerGitHub <noreply@github.com>2017-03-20 12:27:38 +0100
commit35f6b8716e0f4f851e6c5df19b24a1fa76cca5c0 (patch)
tree5cffd99f112f9b3a949e1a4aafd611f1060d2530 /tests/lib/Share20/ManagerTest.php
parent25f772d592172c40ecbb97db71e9590678eab2a4 (diff)
parent80d2717e5cb80615c2e75885398c26289fad463c (diff)
downloadnextcloud-server-35f6b8716e0f4f851e6c5df19b24a1fa76cca5c0.tar.gz
nextcloud-server-35f6b8716e0f4f851e6c5df19b24a1fa76cca5c0.zip
Merge pull request #3884 from nextcloud/downstream-26956
Skip null groups in group manager
Diffstat (limited to 'tests/lib/Share20/ManagerTest.php')
-rw-r--r--tests/lib/Share20/ManagerTest.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 448373a8368..2a7df0df50f 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -1139,6 +1139,39 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
}
+ public function testUserCreateChecksIdenticalPathSharedViaDeletedGroup() {
+ $share = $this->manager->newShare();
+
+ $sharedWith = $this->getMock('\OCP\IUser');
+ $sharedWith->method('getUID')->willReturn('sharedWith');
+
+ $this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
+
+ $path = $this->getMock('\OCP\Files\Node');
+
+ $share->setSharedWith('sharedWith')
+ ->setNode($path)
+ ->setShareOwner('shareOwner')
+ ->setProviderId('foo')
+ ->setId('bar');
+
+ $share2 = $this->manager->newShare();
+ $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareOwner('shareOwner2')
+ ->setProviderId('foo')
+ ->setId('baz')
+ ->setSharedWith('group');
+
+ $this->groupManager->method('get')->with('group')->willReturn(null);
+
+ $this->defaultProvider
+ ->method('getSharesByPath')
+ ->with($path)
+ ->willReturn([$share2]);
+
+ $this->assertNull($this->invokePrivate($this->manager, 'userCreateChecks', [$share]));
+ }
+
public function testUserCreateChecksIdenticalPathNotSharedWithUser() {
$share = $this->manager->newShare();
$sharedWith = $this->createMock(IUser::class);
@@ -1216,6 +1249,29 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
}
+ /**
+ * @expectedException Exception
+ * @expectedExceptionMessage Only sharing within your own groups is allowed
+ */
+ public function testGroupCreateChecksShareWithGroupMembersOnlyNullGroup() {
+ $share = $this->manager->newShare();
+
+ $user = $this->getMock('\OCP\IUser');
+ $share->setSharedBy('user')->setSharedWith('group');
+
+ $this->groupManager->method('get')->with('group')->willReturn(null);
+ $this->userManager->method('get')->with('user')->willReturn($user);
+
+ $this->config
+ ->method('getAppValue')
+ ->will($this->returnValueMap([
+ ['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
+ ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
+ ]));
+
+ $this->assertNull($this->invokePrivate($this->manager, 'groupCreateChecks', [$share]));
+ }
+
public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() {
$share = $this->manager->newShare();
@@ -2666,6 +2722,23 @@ class ManagerTest extends \Test\TestCase {
$this->manager->moveShare($share, 'recipient');
}
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Group "shareWith" does not exist
+ */
+ public function testMoveShareGroupNull() {
+ $share = $this->manager->newShare();
+ $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->setSharedWith('shareWith');
+
+ $recipient = $this->getMock('\OCP\IUser');
+
+ $this->groupManager->method('get')->with('shareWith')->willReturn(null);
+ $this->userManager->method('get')->with('recipient')->willReturn($recipient);
+
+ $this->manager->moveShare($share, 'recipient');
+ }
+
public function testMoveShareGroup() {
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP)