diff options
author | Joas Schilling <coding@schilljs.com> | 2019-07-03 16:32:45 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2019-07-03 21:31:40 +0200 |
commit | 132902337e7eee582034d4a1bc0552cd6e0cffb6 (patch) | |
tree | 77cb4a60674b2c5e36759e26dc39954a638832a8 /tests/lib | |
parent | 029ecb7966a5b38ca98cf770fca88c243684f8ad (diff) | |
download | nextcloud-server-132902337e7eee582034d4a1bc0552cd6e0cffb6.tar.gz nextcloud-server-132902337e7eee582034d4a1bc0552cd6e0cffb6.zip |
Unify the permission checking in one place only
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Share20/ManagerTest.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index c1dbf1cdcb5..14444039aba 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -546,6 +546,9 @@ class ManagerTest extends \Test\TestCase { $user0 = 'user0'; $user2 = 'user1'; $group0 = 'group0'; + $owner = $this->createMock(IUser::class); + $owner->method('getUID') + ->willReturn($user0); $file = $this->createMock(File::class); $node = $this->createMock(Node::class); @@ -580,6 +583,8 @@ class ManagerTest extends \Test\TestCase { $nonShareAble = $this->createMock(Folder::class); $nonShareAble->method('isShareable')->willReturn(false); $nonShareAble->method('getPath')->willReturn('path'); + $nonShareAble->method('getOwner') + ->willReturn($owner); $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true]; @@ -589,10 +594,6 @@ class ManagerTest extends \Test\TestCase { $limitedPermssions->method('isShareable')->willReturn(true); $limitedPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ); $limitedPermssions->method('getPath')->willReturn('path'); - - $owner = $this->createMock(IUser::class); - $owner->method('getUID') - ->willReturn($user0); $limitedPermssions->method('getOwner') ->willReturn($owner); @@ -611,6 +612,8 @@ class ManagerTest extends \Test\TestCase { $nonMoveableMountPermssions->method('isShareable')->willReturn(true); $nonMoveableMountPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ); $nonMoveableMountPermssions->method('getPath')->willReturn('path'); + $nonMoveableMountPermssions->method('getOwner') + ->willReturn($owner); $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false]; @@ -627,6 +630,8 @@ class ManagerTest extends \Test\TestCase { $allPermssions = $this->createMock(Folder::class); $allPermssions->method('isShareable')->willReturn(true); $allPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL); + $allPermssions->method('getOwner') + ->willReturn($owner); $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true]; $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true]; |