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 testBindByDnBadPassword() { $dn = 'uid=test_username,ou=example,dc=com'; $password = '******'; $user = new TestUser(); $user->setDn($dn); $this->zend->expects($this->once())->method('bind')->with($this->equalTo($dn), $this->equalTo($password))->will($this->throwException(new ZendLdapException($this->zend))); $this->assertFalse($this->zendLdapDriver->bind($user, $password)); }
public function testNoViolationsOnUniqueUserProperty() { $this->ldapManagerMock->expects($this->once())->method('findUserByUsername')->will($this->returnValue(null))->with($this->equalTo($this->user->getUsername())); $this->validatorContext->expects($this->never())->method('addViolation'); $this->validator->validate($this->user, $this->constraint); }
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 testTrueOnUniqueUserProperty() { $this->ldapManagerMock->expects($this->once())->method('findUserByUsername')->will($this->returnValue(null))->with($this->equalTo($this->user->getUsername())); $this->assertTrue($this->validator->isValid($this->user, $this->constraint)); }
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); }
/** * @covers FR3D\LdapBundle\Ldap\LdapManager::bind */ public function testBind() { $dn = 'dn=test_username'; $password = '******'; $user = new TestUser(); $user->setDn($dn); $this->connection->expects($this->once())->method('bind')->with($this->equalTo($dn), $this->equalTo($password))->will($this->returnValue(true)); $this->assertTrue($this->ldapManager->bind($user, $password)); }