From bf7e2c756f8095b7946e5e82c0909b891d475389 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 23 Mar 2015 16:51:40 +0100 Subject: [PATCH] offset needs to be considered in computed limit --- apps/user_ldap/group_ldap.php | 2 +- apps/user_ldap/tests/group_ldap.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index e8d268d3df2..cba19f3791c 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -630,7 +630,7 @@ class GROUP_LDAP extends BackendUtility implements \OCP\GroupInterface { } $maxGroups = 100000; // limit max results (just for safety reasons) if ($limit > -1) { - $overallLimit = min($limit, $maxGroups); + $overallLimit = min($limit + $offset, $maxGroups); } else { $overallLimit = $maxGroups; } diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php index d1262e4f5b8..8066bce02e3 100644 --- a/apps/user_ldap/tests/group_ldap.php +++ b/apps/user_ldap/tests/group_ldap.php @@ -294,4 +294,18 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase { $groupBackend->inGroup($uid, $gid); } + public function testGetGroupsWithOffset() { + $access = $this->getAccessMock(); + $this->enableGroups($access); + + $access->expects($this->once()) + ->method('ownCloudGroupNames') + ->will($this->returnValue(array('group1', 'group2'))); + + $groupBackend = new GroupLDAP($access); + $groups = $groupBackend->getGroups('', 2, 2); + + $this->assertSame(2, count($groups)); + } + } -- 2.39.5