Example #1
0
 public function testGetUserGroupsMemberOfDisabled()
 {
     $access = $this->getAccessMock();
     $access->connection->expects($this->any())->method('__get')->will($this->returnCallback(function ($name) {
         if ($name === 'useMemberOfToDetectMembership') {
             return 0;
         }
         return 1;
     }));
     $dn = 'cn=userX,dc=foobar';
     $access->connection->hasPrimaryGroups = false;
     $access->expects($this->once())->method('username2dn')->will($this->returnValue($dn));
     $access->expects($this->never())->method('readAttribute')->with($dn, 'memberOf');
     $access->expects($this->once())->method('ownCloudGroupNames')->will($this->returnValue([]));
     $groupBackend = new GroupLDAP($access);
     $groupBackend->getUserGroups('userX');
 }
 /**
  * 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);
 }
Example #3
0
 public function testGetEntryGroupIDNoValue()
 {
     //tests getEntryGroupID via getGroupPrimaryGroupID
     //which is basically identical to getUserPrimaryGroupIDs
     $access = $this->getAccessMock();
     $this->enableGroups($access);
     $dn = 'cn=foobar,cn=foo,dc=barfoo,dc=bar';
     $attr = 'primaryGroupToken';
     $access->expects($this->once())->method('readAttribute')->with($dn, $attr)->will($this->returnValue(false));
     $groupBackend = new GroupLDAP($access);
     $gid = $groupBackend->getGroupPrimaryGroupID($dn);
     $this->assertSame(false, $gid);
 }
 /**
  * tests whether Group Backend behaves correctly when cache with uid and gid
  * is hit
  */
 public function testInGroupHitsUidGidCache()
 {
     $access = $this->getAccessMock();
     $this->enableGroups($access);
     $uid = 'someUser';
     $gid = 'someGroup';
     $cacheKey = 'inGroup' . $uid . ':' . $gid;
     $access->connection->expects($this->once())->method('isCached')->with($cacheKey)->will($this->returnValue(true));
     $access->connection->expects($this->once())->method('getFromCache')->with($cacheKey)->will($this->returnValue(true));
     $access->expects($this->never())->method('username2dn');
     $groupBackend = new GroupLDAP($access);
     $groupBackend->inGroup($uid, $gid);
 }
Example #5
0
 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));
 }