diff options
author | Joas Schilling <coding@schilljs.com> | 2019-07-03 16:32:45 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-07-03 16:34:00 +0200 |
commit | 85a80b05acbb6e13d8b49d1ee7f79e9a8c708066 (patch) | |
tree | e340955eb97afc58ebb6358d4d938ae736b0cf7d /tests/lib/Share20/ManagerTest.php | |
parent | e4addbae3e564b6009dc09c6c5e36c018cd8d5d0 (diff) | |
download | nextcloud-server-85a80b05acbb6e13d8b49d1ee7f79e9a8c708066.tar.gz nextcloud-server-85a80b05acbb6e13d8b49d1ee7f79e9a8c708066.zip |
Unify the permission checking in one place only
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/Share20/ManagerTest.php')
-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 417ba2ebc93..10db23b2d98 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -545,6 +545,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); @@ -579,6 +582,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]; @@ -588,10 +593,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); @@ -610,6 +611,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]; @@ -626,6 +629,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]; |