diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-05-11 13:39:22 +0300 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-05-20 18:56:02 +0300 |
commit | b5eb3d9e5a7edf61bfc3f4243533de9ca4afa8d4 (patch) | |
tree | a203c5b863b77a4de2c3db1f2b099268a8ffc712 /tests | |
parent | 3cd65fe25dc6f213dd7e4a1687616dc5e0960d4d (diff) |
Add system tag assignability check with groups
Whenever a user is not an admin, a tag is visible but not
user-assignable, check whether the user is a member of the allowed
groups.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/SystemTag/SystemTagManagerTest.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php index 408134a8757..04f49eff963 100644 --- a/tests/lib/SystemTag/SystemTagManagerTest.php +++ b/tests/lib/SystemTag/SystemTagManagerTest.php @@ -449,31 +449,51 @@ class SystemTagManagerTest extends TestCase { public function assignabilityCheckProvider() { return [ + // no groups [false, false, false, false], [true, false, false, false], [true, true, false, true], [false, true, false, false], + // admin rulez [false, false, true, true], [false, true, true, true], [true, false, true, true], [true, true, true, true], + // ignored groups + [false, false, false, false, ['group1'], ['group1']], + [true, true, false, true, ['group1'], ['group1']], + [true, true, false, true, ['group1'], ['anothergroup']], + [false, true, false, false, ['group1'], ['group1']], + // admin has precedence over groups + [false, false, true, true, ['group1'], ['anothergroup']], + [false, true, true, true, ['group1'], ['anothergroup']], + [true, false, true, true, ['group1'], ['anothergroup']], + [true, true, true, true, ['group1'], ['anothergroup']], + // groups only checked when visible and user non-assignable and non-admin + [true, false, false, false, ['group1'], ['anothergroup1']], + [true, false, false, true, ['group1'], ['group1']], + [true, false, false, true, ['group1', 'group2'], ['group2', 'group3']], ]; } /** * @dataProvider assignabilityCheckProvider */ - public function testAssignabilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult) { + public function testAssignabilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult, $userGroupIds = [], $tagGroupIds = []) { $user = $this->getMockBuilder('\OCP\IUser')->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('test')); $tag1 = $this->tagManager->createTag('one', $userVisible, $userAssignable); + $this->tagManager->setTagGroups($tag1, $tagGroupIds); $this->groupManager->expects($this->any()) ->method('isAdmin') ->with('test') ->will($this->returnValue($isAdmin)); + $this->groupManager->expects($this->any()) + ->method('getUserGroupIds') + ->will($this->returnValue($userGroupIds)); $this->assertEquals($expectedResult, $this->tagManager->canUserAssignTag($tag1, $user)); } |