summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-04-14 14:40:37 +0200
committerArthur Schiwon <blizzz@owncloud.com>2015-04-14 14:56:36 +0200
commit07988cf77cd8d6a52c5b99ffc4ca1b8a40fa6ea4 (patch)
tree9e19f962027d017d5297fb2cc7395c20b4b65add /apps/user_ldap/tests
parentf3bd2667877b50c6e08d796a70f4bf4687fab05c (diff)
downloadnextcloud-server-07988cf77cd8d6a52c5b99ffc4ca1b8a40fa6ea4.tar.gz
nextcloud-server-07988cf77cd8d6a52c5b99ffc4ca1b8a40fa6ea4.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')
-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 b29449d286e..b18ebb50efa 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 \PHPUnit_Framework_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);
+ }
+
}