diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-04-14 14:40:37 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-05-19 12:56:07 +0200 |
commit | 6b218039ba4a49cd2af4a3dbceb9c41139a5848f (patch) | |
tree | e4e55d23b8afddc0f0ba91b9ef61629ed5d17c4f /apps/user_ldap/tests/group_ldap.php | |
parent | d90b83725f87825a68b51a32228270d9e9a82ac6 (diff) | |
download | nextcloud-server-6b218039ba4a49cd2af4a3dbceb9c41139a5848f.tar.gz nextcloud-server-6b218039ba4a49cd2af4a3dbceb9c41139a5848f.zip |
Fixes returns of group memberships and counting if all members have the specific groups as primary set.
Diffstat (limited to 'apps/user_ldap/tests/group_ldap.php')
-rw-r--r-- | apps/user_ldap/tests/group_ldap.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php index 5bcd5953075..d91f1503abd 100644 --- a/apps/user_ldap/tests/group_ldap.php +++ b/apps/user_ldap/tests/group_ldap.php @@ -313,4 +313,74 @@ class Test_Group_Ldap extends \Test\TestCase { $this->assertSame(2, count($groups)); } + /** + * tests that a user listing is complete, if all it's members have the group + * as their primary. + */ + public function testUsersInGroupPrimaryMembersOnly() { + $access = $this->getAccessMock(); + $this->enableGroups($access); + + $access->connection->expects($this->any()) + ->method('getFromCache') + ->will($this->returnValue(null)); + + $access->expects($this->any()) + ->method('readAttribute') + ->will($this->returnCallback(function($dn, $attr) { + if($attr === 'primaryGroupToken') { + return array(1337); + } + return array(); + })); + + $access->expects($this->any()) + ->method('groupname2dn') + ->will($this->returnValue('cn=foobar,dc=foo,dc=bar')); + + $access->expects($this->once()) + ->method('ownCloudUserNames') + ->will($this->returnValue(array('lisa', 'bart', 'kira', 'brad'))); + + $groupBackend = new GroupLDAP($access); + $users = $groupBackend->usersInGroup('foobar'); + + $this->assertSame(4, count($users)); + } + + /** + * tests that a user counting is complete, if all it's members have the group + * as their primary. + */ + public function testCountUsersInGroupPrimaryMembersOnly() { + $access = $this->getAccessMock(); + $this->enableGroups($access); + + $access->connection->expects($this->any()) + ->method('getFromCache') + ->will($this->returnValue(null)); + + $access->expects($this->any()) + ->method('readAttribute') + ->will($this->returnCallback(function($dn, $attr) { + if($attr === 'primaryGroupToken') { + return array(1337); + } + return array(); + })); + + $access->expects($this->any()) + ->method('groupname2dn') + ->will($this->returnValue('cn=foobar,dc=foo,dc=bar')); + + $access->expects($this->once()) + ->method('countUsers') + ->will($this->returnValue(4)); + + $groupBackend = new GroupLDAP($access); + $users = $groupBackend->countUsersInGroup('foobar'); + + $this->assertSame(4, $users); + } + } |