public function testRefreshUser() { $username = '******'; $user = new TestUser(); $user->setUsername($username); $this->ldapManager->expects($this->once())->method('findUserByUsername')->with($this->equalTo($username))->will($this->returnValue($user)); $this->assertEquals($user, $this->userProvider->refreshUser($user)); }
/** * @dataProvider provideTestBind */ public function testBind($bind_rdn, $password, $expect) { global $ldapServer; $user = new TestUser(); $user->setUsername($bind_rdn); $ldapServer->expects($this->once())->method('ldap_bind')->with($this->equalTo($bind_rdn), $this->equalTo($password))->will($this->returnValue($expect)); $this->assertEquals($expect, $this->zendLdapDriver->bind($user, $password)); }
public function testBindByUsernameBadUsername() { $username = '******'; $password = '******'; $user = new TestUser(); $user->setUsername($username); $this->zend->expects($this->once())->method('bind')->with($this->equalTo($username), $this->equalTo($password))->will($this->throwException(new ZendLdapException($this->zend))); $this->assertFalse($this->zendLdapDriver->bind($user, $password)); }
/** * @covers FR3D\LdapBundle\Ldap\LdapManager::findUserBy */ public function testFindUserBy() { $username = '******'; $user = new TestUser(); $user->setUsername($username); $entries = array('count' => 1, array('dn' => 'ou=group, dc=host, dc=foo', 'uid' => array('count' => 1, 0 => $username))); $this->connection->expects($this->once())->method('search')->with($this->equalTo('ou=Groups,dc=example,dc=com'), $this->equalTo('(&(attr0=value0)(uid=test_username))'), $this->equalTo(array('uid')))->will($this->returnValue($entries)); $criteria = array('uid' => 'test_username'); $resultUser = $this->ldapManager->findUserBy($criteria); $this->assertEquals($user->getUsername(), $resultUser->getUsername()); }
public function testBindByDnFromBadUsername() { global $ldapServer; $options = $this->getOptions(); $options['baseDn'] = 'ou=example,dc=org'; $options['accountFilterFormat'] = '(&(uid=%s))'; $options['bindRequiresDn'] = true; $this->legacyLdapDriver = new LegacyLdapDriver($options); $username = '******'; $password = '******'; $user = new TestUser(); $user->setUsername($username); $result = array('count' => 0); $ldapServer->expects($this->once())->method('ldap_search')->will($this->returnValue(2)); $ldapServer->expects($this->once())->method('ldap_get_entries')->will($this->returnValue($result)); $this->assertFalse($this->legacyLdapDriver->bind($user, $password)); }
public function testCheckAuthenticationUnknownUserPasswordIs0() { $method = $this->setMethodAccessible('checkAuthentication'); $username = '******'; $password = '******'; $user = new TestUser(); $user->setUsername($username); $token = new UsernamePasswordToken($username, $password, 'provider_key', array()); $this->ldapManager->expects($this->once())->method('bind')->with($this->equalTo($user), $this->equalTo($password))->will($this->returnValue(true)); $method->invoke($this->ldapAuthenticationProvider, $user, $token); $this->assertTrue(true); }