summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/group_ldap.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-04-14 14:40:37 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-05-19 12:56:07 +0200
commit6b218039ba4a49cd2af4a3dbceb9c41139a5848f (patch)
treee4e55d23b8afddc0f0ba91b9ef61629ed5d17c4f /apps/user_ldap/tests/group_ldap.php
parentd90b83725f87825a68b51a32228270d9e9a82ac6 (diff)
downloadnextcloud-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.php70
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);
+ }
+
}