diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-09-09 12:53:17 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-13 12:58:48 +0200 |
commit | d84df155900bfdb58a8826802cde5a096065a078 (patch) | |
tree | 32271ae27883407fd0123902b779ad8125d100a4 /tests | |
parent | 5505faa3d7b6f5a95f18fe5027355d700d69f396 (diff) | |
download | nextcloud-server-d84df155900bfdb58a8826802cde5a096065a078.tar.gz nextcloud-server-d84df155900bfdb58a8826802cde5a096065a078.zip |
Add getAccessList to ShareManager
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Share20/ManagerTest.php | 83 |
1 files changed, 82 insertions, 1 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 5436b188350..20ba62fa225 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -2639,7 +2639,6 @@ class ManagerTest extends \Test\TestCase { $this->manager->moveShare($share, 'recipient'); } - /** * @dataProvider dataTestShareProviderExists */ @@ -2737,6 +2736,88 @@ class ManagerTest extends \Test\TestCase { $this->assertSame($expects, $result); } + + public function testGetAccessList() { + $owner = $this->createMock(IUser::class); + $owner->expects($this->once()) + ->method('getUID') + ->willReturn('owner'); + + $node = $this->createMock(Node::class); + $node->expects($this->once()) + ->method('getOwner') + ->willReturn($owner); + $node->expects($this->once()) + ->method('getId') + ->willReturn(42); + + $userFolder = $this->createMock(Folder::class); + $file = $this->createMock(File::class); + $folder = $this->createMock(Folder::class); + + $file->method('getParent') + ->willReturn($folder); + $folder->method('getParent') + ->willReturn($userFolder); + $userFolder->method('getById') + ->with($this->equalTo(42)) + ->willReturn([$file]); + + $userShare = $this->createMock(IShare::class); + $userShare->method('getShareType') + ->willReturn(\OCP\Share::SHARE_TYPE_USER); + $userShare->method('getSharedWith') + ->willReturn('user1'); + $groupShare = $this->createMock(IShare::class); + $groupShare->method('getShareType') + ->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $groupShare->method('getSharedWith') + ->willReturn('group1'); + $publicShare = $this->createMock(IShare::class); + $publicShare->method('getShareType') + ->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $remoteShare = $this->createMock(IShare::class); + $remoteShare->method('getShareType') + ->willReturn(\OCP\Share::SHARE_TYPE_REMOTE); + + $this->userManager->method('userExists') + ->with($this->equalTo('user1')) + ->willReturn(true); + + $user2 = $this->createMock(IUser::class); + $user2->method('getUID') + ->willReturn('user2'); + $group1 = $this->createMock(IGroup::class); + $this->groupManager->method('get') + ->with($this->equalTo('group1')) + ->willReturn($group1); + $group1->method('getUsers') + ->willReturn([$user2]); + + $this->defaultProvider->expects($this->any()) + ->method('getSharesByPath') + ->will($this->returnCallback(function(Node $path) use ($file, $folder, $userShare, $groupShare, $publicShare, $remoteShare) { + if ($path === $file) { + return [$userShare, $publicShare]; + } else if ($path === $folder) { + return [$groupShare, $remoteShare]; + } else { + return []; + } + })); + + $this->rootFolder->method('getUserFolder') + ->with($this->equalTo('owner')) + ->willReturn($userFolder); + + $expected = [ + 'users' => ['user1', 'user2'], + 'public' => true, + 'remote' => true, + ]; + + $this->assertEquals($expected, $this->manager->getAccessList($node)); + } } class DummyFactory implements IProviderFactory { |