Rename class Credentials to Credential

refs #4641
This commit is contained in:
Marius Hein 2013-08-30 10:24:05 +02:00
parent 83d20a6175
commit 7c8252a983
11 changed files with 80 additions and 79 deletions

View File

@ -27,7 +27,7 @@
# namespace Icinga\Application\Controllers; # namespace Icinga\Application\Controllers;
use \Icinga\Web\Controller\ActionController; use \Icinga\Web\Controller\ActionController;
use \Icinga\Authentication\Credentials; use \Icinga\Authentication\Credential;
use \Icinga\Authentication\Manager as AuthManager; use \Icinga\Authentication\Manager as AuthManager;
use \Icinga\Form\Authentication\LoginForm; use \Icinga\Form\Authentication\LoginForm;
use \Icinga\Exception\ConfigurationError; use \Icinga\Exception\ConfigurationError;
@ -60,7 +60,7 @@ class AuthenticationController extends ActionController
public function loginAction() public function loginAction()
{ {
$this->replaceLayout = true; $this->replaceLayout = true;
$credentials = new Credentials(); $credentials = new Credential();
$this->view->form = new LoginForm(); $this->view->form = new LoginForm();
$this->view->form->setRequest($this->_request); $this->view->form->setRequest($this->_request);
$this->view->title = "Icinga Web Login"; $this->view->title = "Icinga Web Login";

View File

@ -37,7 +37,7 @@ use \Icinga\Application\DbAdapterFactory;
use \Icinga\Exception\ProgrammingError; use \Icinga\Exception\ProgrammingError;
use \Icinga\User; use \Icinga\User;
use \Icinga\Authentication\UserBackend; use \Icinga\Authentication\UserBackend;
use \Icinga\Authentication\Credentials; use \Icinga\Authentication\Credential;
use \Icinga\Authentication; use \Icinga\Authentication;
use \Icinga\Application\Logger; use \Icinga\Application\Logger;
use \Icinga\Exception\ConfigurationError; use \Icinga\Exception\ConfigurationError;
@ -135,11 +135,11 @@ class DbUserBackend implements UserBackend
/** /**
* Check if the user identified by the given credentials is available * Check if the user identified by the given credentials is available
* *
* @param Credentials $credential * @param Credential $credential
* *
* @return boolean True when the username is known and currently active. * @return boolean True when the username is known and currently active.
*/ */
public function hasUsername(Credentials $credential) public function hasUsername(Credential $credential)
{ {
if ($this->db === null) { if ($this->db === null) {
Logger::warn('Ignoring hasUsername in database as no connection is available'); Logger::warn('Ignoring hasUsername in database as no connection is available');
@ -152,11 +152,11 @@ class DbUserBackend implements UserBackend
/** /**
* Authenticate a user with the given credentials * Authenticate a user with the given credentials
* *
* @param Credentials $credential * @param Credential $credential
* *
* @return User|null The authenticated user or Null. * @return User|null The authenticated user or Null.
*/ */
public function authenticate(Credentials $credential) public function authenticate(Credential $credential)
{ {
if ($this->db === null) { if ($this->db === null) {
Logger::warn('Ignoring database authentication as no connection is available'); Logger::warn('Ignoring database authentication as no connection is available');

View File

@ -32,7 +32,7 @@ use \stdClass;
use \Zend_Config; use \Zend_Config;
use \Icinga\User; use \Icinga\User;
use \Icinga\Authentication\UserBackend; use \Icinga\Authentication\UserBackend;
use \Icinga\Authentication\Credentials; use \Icinga\Authentication\Credential;
use \Icinga\Protocol\Ldap; use \Icinga\Protocol\Ldap;
use Icinga\Protocol\Ldap\Connection; use Icinga\Protocol\Ldap\Connection;
use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Config as IcingaConfig;
@ -88,11 +88,11 @@ class LdapUserBackend implements UserBackend
/** /**
* Test if the username exists * Test if the username exists
* *
* @param Credentials $credential * @param Credential $credential
* *
* @return bool * @return bool
*/ */
public function hasUsername(Credentials $credential) public function hasUsername(Credential $credential)
{ {
return $this->connection->fetchOne( return $this->connection->fetchOne(
$this->selectUsername($credential->getUsername()) $this->selectUsername($credential->getUsername())
@ -136,11 +136,11 @@ class LdapUserBackend implements UserBackend
/** /**
* Authenticate * Authenticate
* *
* @param Credentials $credentials * @param Credential $credentials
* *
* @return User * @return User
*/ */
public function authenticate(Credentials $credentials) public function authenticate(Credential $credentials)
{ {
if (!$this->connection->testCredentials( if (!$this->connection->testCredentials(
$this->connection->fetchDN($this->selectUsername($credentials->getUsername())), $this->connection->fetchDN($this->selectUsername($credentials->getUsername())),

View File

@ -35,7 +35,7 @@ namespace Icinga\Authentication;
* passwords as primitives in order to allow additional information * passwords as primitives in order to allow additional information
* to be provided (like the domain) when needed. * to be provided (like the domain) when needed.
*/ */
class Credentials class Credential
{ {
/** /**
* Username * Username

View File

@ -269,12 +269,12 @@ class Manager
/** /**
* Find a backend for a credential * Find a backend for a credential
* *
* @param Credentials $credentials * @param Credential $credentials
* *
* @return UserBackend|null * @return UserBackend|null
* @throws ConfigurationError * @throws ConfigurationError
*/ */
private function getBackendForCredentials(Credentials $credentials) private function getBackendForCredential(Credential $credentials)
{ {
$authErrors = 0; $authErrors = 0;
@ -324,16 +324,16 @@ class Manager
} }
/** /**
* Try to authenticate the current user with the Credentials (@see Credentials). * Try to authenticate the current user with the Credential (@see Credential).
* *
* @param Credentials $credentials The credentials to use for authentication * @param Credential $credentials The credentials to use for authentication
* @param Boolean $persist Whether to persist the authentication result * @param Boolean $persist Whether to persist the authentication result
* in the current session * in the current session
* *
* @return Boolean true on success, otherwise false * @return Boolean true on success, otherwise false
* @throws ConfigError * @throws ConfigError
*/ */
public function authenticate(Credentials $credentials, $persist = true) public function authenticate(Credential $credentials, $persist = true)
{ {
if (count($this->userBackends) === 0) { if (count($this->userBackends) === 0) {
Logger::error('AuthManager: No authentication backend provided, your users will never be able to login.'); Logger::error('AuthManager: No authentication backend provided, your users will never be able to login.');
@ -344,7 +344,7 @@ class Manager
); );
} }
$userBackend = $this->getBackendForCredentials($credentials); $userBackend = $this->getBackendForCredential($credentials);
if ($userBackend === null) { if ($userBackend === null) {
Logger::info('AuthManager: Unknown user %s tried to log in', $credentials->getUsername()); Logger::info('AuthManager: Unknown user %s tried to log in', $credentials->getUsername());

View File

@ -30,6 +30,7 @@ namespace Icinga\Authentication;
use \Zend_Config; use \Zend_Config;
use \Icinga\User; use \Icinga\User;
use Icinga\Authentication\Credential;
/** /**
* Public api for an user backend object * Public api for an user backend object
@ -46,20 +47,20 @@ interface UserBackend
/** /**
* Test if the username exists * Test if the username exists
* *
* @param Credentials $credentials * @param Credential $credentials
* *
* @return bool * @return bool
*/ */
public function hasUsername(Credentials $credentials); public function hasUsername(Credential $credentials);
/** /**
* Authenticate * Authenticate
* *
* @param Credentials $credentials * @param Credential $credentials
* *
* @return User * @return User
*/ */
public function authenticate(Credentials $credentials); public function authenticate(Credential $credentials);
/** /**
* Name of the backend * Name of the backend

View File

@ -12,20 +12,20 @@ use Icinga\Test\BaseTestCase;
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart
require_once 'Zend/Config.php'; require_once 'Zend/Config.php';
require_once BaseTestCase::$libDir . '/Authentication/Credentials.php'; require_once BaseTestCase::$libDir . '/Authentication/Credential.php';
require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php'; require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php';
require_once BaseTestCase::$libDir . '/User.php'; require_once BaseTestCase::$libDir . '/User.php';
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
use \Zend_Config; use \Zend_Config;
use \Icinga\Authentication\Credentials as Credentials; use \Icinga\Authentication\Credential;
use \Icinga\Authentication\UserBackend as UserBackend; use \Icinga\Authentication\UserBackend as UserBackend;
use \Icinga\User; use \Icinga\User;
/** /**
* Simple backend mock that takes an config object * Simple backend mock that takes an config object
* with the property "credentials", which is an array * with the property "credentials", which is an array
* of Credentials this backend authenticates * of Credential this backend authenticates
**/ **/
class BackendMock implements UserBackend class BackendMock implements UserBackend
{ {
@ -49,7 +49,7 @@ class BackendMock implements UserBackend
} }
} }
public function hasUsername(Credentials $userCredentials) public function hasUsername(Credential $userCredentials)
{ {
foreach ($this->allowedCredentials as $credential) { foreach ($this->allowedCredentials as $credential) {
if ($credential->getUsername() == $userCredentials->getUsername()) { if ($credential->getUsername() == $userCredentials->getUsername()) {
@ -79,12 +79,12 @@ class BackendMock implements UserBackend
'user@test.local' 'user@test.local'
); );
} }
public function getUserCount() { public function getUserCount() {
return count($this->allowedCredentials); return count($this->allowedCredentials);
} }
public function authenticate(Credentials $credentials) public function authenticate(Credential $credentials)
{ {
if (!in_array($credentials, $this->allowedCredentials)) { if (!in_array($credentials, $this->allowedCredentials)) {
return false; return false;

View File

@ -45,7 +45,7 @@ require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php';
require_once BaseTestCase::$libDir . '/Protocol/Ldap/Exception.php'; require_once BaseTestCase::$libDir . '/Protocol/Ldap/Exception.php';
require_once BaseTestCase::$libDir . '/Application/DbAdapterFactory.php'; require_once BaseTestCase::$libDir . '/Application/DbAdapterFactory.php';
require_once BaseTestCase::$libDir . '/Application/Config.php'; require_once BaseTestCase::$libDir . '/Application/Config.php';
require_once BaseTestCase::$libDir . '/Authentication/Credentials.php'; require_once BaseTestCase::$libDir . '/Authentication/Credential.php';
require_once BaseTestCase::$libDir . '/Authentication/Backend/DbUserBackend.php'; require_once BaseTestCase::$libDir . '/Authentication/Backend/DbUserBackend.php';
require_once BaseTestCase::$libDir . '/User.php'; require_once BaseTestCase::$libDir . '/User.php';
require_once BaseTestCase::$libDir . '/Application/Logger.php'; require_once BaseTestCase::$libDir . '/Application/Logger.php';
@ -56,7 +56,7 @@ use \Zend_Db_Adapter_Pdo_Abstract;
use \Zend_Config; use \Zend_Config;
use \Icinga\Authentication\Backend\DbUserBackend; use \Icinga\Authentication\Backend\DbUserBackend;
use \Icinga\Application\DbAdapterFactory; use \Icinga\Application\DbAdapterFactory;
use \Icinga\Authentication\Credentials; use \Icinga\Authentication\Credential;
use \Icinga\User; use \Icinga\User;
use \Icinga\Application\Config; use \Icinga\Application\Config;
@ -189,7 +189,7 @@ class DbUserBackendTest extends BaseTestCase
// Known user // Known user
$this->assertTrue( $this->assertTrue(
$backend->hasUsername( $backend->hasUsername(
new Credentials( new Credential(
$this->userData[0][self::USER_NAME_COLUMN], $this->userData[0][self::USER_NAME_COLUMN],
$this->userData[0][self::PASSWORD_COLUMN] $this->userData[0][self::PASSWORD_COLUMN]
) )
@ -200,7 +200,7 @@ class DbUserBackendTest extends BaseTestCase
// Unknown user // Unknown user
$this->assertFalse( $this->assertFalse(
$backend->hasUsername( $backend->hasUsername(
new Credentials( new Credential(
'unknown user', 'unknown user',
'secret' 'secret'
) )
@ -211,7 +211,7 @@ class DbUserBackendTest extends BaseTestCase
// Inactive user // Inactive user
$this->assertFalse( $this->assertFalse(
$backend->hasUsername( $backend->hasUsername(
new Credentials( new Credential(
$this->userData[2][self::USER_NAME_COLUMN], $this->userData[2][self::USER_NAME_COLUMN],
$this->userData[2][self::PASSWORD_COLUMN] $this->userData[2][self::PASSWORD_COLUMN]
) )
@ -230,7 +230,7 @@ class DbUserBackendTest extends BaseTestCase
// Known user // Known user
$this->assertNotNull( $this->assertNotNull(
$backend->authenticate( $backend->authenticate(
new Credentials( new Credential(
$this->userData[0][self::USER_NAME_COLUMN], $this->userData[0][self::USER_NAME_COLUMN],
$this->userData[0][self::PASSWORD_COLUMN] $this->userData[0][self::PASSWORD_COLUMN]
) )
@ -241,7 +241,7 @@ class DbUserBackendTest extends BaseTestCase
// Wrong password // Wrong password
$this->assertNull( $this->assertNull(
$backend->authenticate( $backend->authenticate(
new Credentials( new Credential(
$this->userData[1][self::USER_NAME_COLUMN], $this->userData[1][self::USER_NAME_COLUMN],
'wrongpassword' 'wrongpassword'
) )
@ -252,7 +252,7 @@ class DbUserBackendTest extends BaseTestCase
// Nonexisting user // Nonexisting user
$this->assertNull( $this->assertNull(
$backend->authenticate( $backend->authenticate(
new Credentials( new Credential(
'nonexisting user', 'nonexisting user',
$this->userData[1][self::PASSWORD_COLUMN] $this->userData[1][self::PASSWORD_COLUMN]
) )
@ -263,7 +263,7 @@ class DbUserBackendTest extends BaseTestCase
// Inactive user // Inactive user
$this->assertNull( $this->assertNull(
$backend->authenticate( $backend->authenticate(
new Credentials( new Credential(
$this->userData[2][self::USER_NAME_COLUMN], $this->userData[2][self::USER_NAME_COLUMN],
$this->userData[2][self::PASSWORD_COLUMN] $this->userData[2][self::PASSWORD_COLUMN]
) )

View File

@ -12,21 +12,21 @@ use Icinga\Test\BaseTestCase;
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart
require_once 'Zend/Config.php'; require_once 'Zend/Config.php';
require_once BaseTestCase::$libDir . '/Authentication/Credentials.php'; require_once BaseTestCase::$libDir . '/Authentication/Credential.php';
require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php'; require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php';
require_once BaseTestCase::$libDir . '/User.php'; require_once BaseTestCase::$libDir . '/User.php';
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
use \Exception; use \Exception;
use \Zend_Config; use \Zend_Config;
use \Icinga\Authentication\Credentials as Credentials; use \Icinga\Authentication\Credential;
use \Icinga\Authentication\UserBackend as UserBackend; use \Icinga\Authentication\UserBackend as UserBackend;
use \Icinga\User; use \Icinga\User;
/** /**
* Simple backend mock that takes an config object * Simple backend mock that takes an config object
* with the property "credentials", which is an array * with the property "credentials", which is an array
* of Credentials this backend authenticates * of Credential this backend authenticates
**/ **/
class ErrorProneBackendMock implements UserBackend class ErrorProneBackendMock implements UserBackend
{ {
@ -56,12 +56,12 @@ class ErrorProneBackendMock implements UserBackend
/** /**
* Test if the username exists * Test if the username exists
* *
* @param Credentials $credentials * @param Credential $credentials
* *
* @return bool * @return bool
* @throws Exception * @throws Exception
*/ */
public function hasUsername(Credentials $credentials) public function hasUsername(Credential $credentials)
{ {
throw new Exception('hasUsername error: ' . $credentials->getUsername()); throw new Exception('hasUsername error: ' . $credentials->getUsername());
} }
@ -69,12 +69,12 @@ class ErrorProneBackendMock implements UserBackend
/** /**
* Authenticate * Authenticate
* *
* @param Credentials $credentials * @param Credential $credentials
* *
* @return User * @return User
* @throws Exception * @throws Exception
*/ */
public function authenticate(Credentials $credentials) public function authenticate(Credential $credentials)
{ {
throw new Exception('authenticate error: ' . $credentials->getUsername()); throw new Exception('authenticate error: ' . $credentials->getUsername());
} }

View File

@ -32,14 +32,14 @@ namespace Tests\Icinga\Authentication;
require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php'); require_once realpath(__DIR__ . '/../../../../../library/Icinga/Test/BaseTestCase.php');
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
use Icinga\Authentication\Credentials; use Icinga\Authentication\Credential;
use \Icinga\Test\BaseTestCase; use \Icinga\Test\BaseTestCase;
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart
require_once 'Zend/Config.php'; require_once 'Zend/Config.php';
require_once BaseTestCase::$libDir . '/Protocol/Ldap/Connection.php'; require_once BaseTestCase::$libDir . '/Protocol/Ldap/Connection.php';
require_once BaseTestCase::$libDir . '/Protocol/Ldap/Query.php'; require_once BaseTestCase::$libDir . '/Protocol/Ldap/Query.php';
require_once BaseTestCase::$libDir . '/Authentication/Credentials.php'; require_once BaseTestCase::$libDir . '/Authentication/Credential.php';
require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php'; require_once BaseTestCase::$libDir . '/Authentication/UserBackend.php';
require_once BaseTestCase::$libDir . '/Authentication/Backend/LdapUserBackend.php'; require_once BaseTestCase::$libDir . '/Authentication/Backend/LdapUserBackend.php';
// @codingStandardsIgnoreEnd // @codingStandardsIgnoreEnd
@ -183,9 +183,9 @@ class LdapUserBackendTest extends BaseTestCase
public function testHasUsername() public function testHasUsername()
{ {
$backend = new LdapUserBackend($this->createBackendConfig()); $backend = new LdapUserBackend($this->createBackendConfig());
$this->assertTrue($backend->hasUsername(new Credentials('jwoe'))); $this->assertTrue($backend->hasUsername(new Credential('jwoe')));
$this->assertTrue($backend->hasUsername(new Credentials('rmiles'))); $this->assertTrue($backend->hasUsername(new Credential('rmiles')));
$this->assertFalse($backend->hasUsername(new Credentials('DoesNotExist'))); $this->assertFalse($backend->hasUsername(new Credential('DoesNotExist')));
} }
/** /**
@ -197,17 +197,17 @@ class LdapUserBackendTest extends BaseTestCase
$this->assertInstanceOf( $this->assertInstanceOf(
'\Icinga\User', '\Icinga\User',
$backend->authenticate(new Credentials('jwoe', 'passjwoe')) $backend->authenticate(new Credential('jwoe', 'passjwoe'))
); );
$this->assertFalse($backend->authenticate(new Credentials('jwoe', 'passjwoe22'))); $this->assertFalse($backend->authenticate(new Credential('jwoe', 'passjwoe22')));
$this->assertInstanceOf( $this->assertInstanceOf(
'\Icinga\User', '\Icinga\User',
$backend->authenticate(new Credentials('rmiles', 'passrmiles')) $backend->authenticate(new Credential('rmiles', 'passrmiles'))
); );
$this->assertFalse($backend->authenticate(new Credentials('rmiles', 'passrmiles33'))); $this->assertFalse($backend->authenticate(new Credential('rmiles', 'passrmiles33')));
} }
/** /**
@ -217,6 +217,6 @@ class LdapUserBackendTest extends BaseTestCase
public function testAuthenticateUnknownUser() public function testAuthenticateUnknownUser()
{ {
$backend = new LdapUserBackend($this->createBackendConfig()); $backend = new LdapUserBackend($this->createBackendConfig());
$this->assertFalse($backend->authenticate(new Credentials('unknown123', 'passunknown123'))); $this->assertFalse($backend->authenticate(new Credential('unknown123', 'passunknown123')));
} }
} }

View File

@ -40,7 +40,7 @@ require_once 'Zend/Log.php';
require_once 'Zend/Config.php'; require_once 'Zend/Config.php';
require_once BaseTestCase::$libDir . '/Application/Logger.php'; require_once BaseTestCase::$libDir . '/Application/Logger.php';
require_once BaseTestCase::$libDir . '/Authentication/Manager.php'; require_once BaseTestCase::$libDir . '/Authentication/Manager.php';
require_once BaseTestCase::$libDir . '/Authentication/Credentials.php'; require_once BaseTestCase::$libDir . '/Authentication/Credential.php';
require_once BaseTestCase::$libDir . '/Exception/ConfigurationError.php'; require_once BaseTestCase::$libDir . '/Exception/ConfigurationError.php';
require_once 'BackendMock.php'; require_once 'BackendMock.php';
require_once 'ErrorProneBackendMock.php'; require_once 'ErrorProneBackendMock.php';
@ -49,7 +49,7 @@ require_once 'SessionMock.php';
use \Zend_Config; use \Zend_Config;
use \Icinga\Authentication\Manager as AuthManager; use \Icinga\Authentication\Manager as AuthManager;
use \Icinga\Authentication\Credentials; use \Icinga\Authentication\Credential;
use \Icinga\Exception\ConfigurationError; use \Icinga\Exception\ConfigurationError;
/** /**
@ -60,9 +60,9 @@ class ManagerTest extends BaseTestCase
public function getTestCredentials() public function getTestCredentials()
{ {
return array( return array(
new Credentials("jdoe", "passjdoe"), new Credential("jdoe", "passjdoe"),
new Credentials("root", "passroot"), new Credential("root", "passroot"),
new Credentials("test", "passtest") new Credential("test", "passtest")
); );
} }
@ -115,7 +115,7 @@ class ManagerTest extends BaseTestCase
$this->assertTrue( $this->assertTrue(
$authMgr->authenticate( $authMgr->authenticate(
new Credentials('jdoe', 'passjdoe') new Credential('jdoe', 'passjdoe')
) )
); );
@ -138,19 +138,19 @@ class ManagerTest extends BaseTestCase
$auth = $this->getManagerInstance(); $auth = $this->getManagerInstance();
$this->assertFalse( $this->assertFalse(
$auth->authenticate( $auth->authenticate(
new Credentials("jhoe", "passjdoe"), new Credential("jhoe", "passjdoe"),
false false
) )
); );
$this->assertFalse( $this->assertFalse(
$auth->authenticate( $auth->authenticate(
new Credentials("joe", "passjhoe"), new Credential("joe", "passjhoe"),
false false
) )
); );
$this->assertTrue( $this->assertTrue(
$auth->authenticate( $auth->authenticate(
new Credentials("jdoe", "passjdoe"), new Credential("jdoe", "passjdoe"),
false false
) )
); );
@ -161,7 +161,7 @@ class ManagerTest extends BaseTestCase
$session = new SessionMock(); $session = new SessionMock();
$auth = $this->getManagerInstance($session, true); $auth = $this->getManagerInstance($session, true);
$this->assertFalse($auth->isAuthenticated(true)); $this->assertFalse($auth->isAuthenticated(true));
$auth->authenticate(new Credentials("jdoe", "passjdoe")); $auth->authenticate(new Credential("jdoe", "passjdoe"));
$this->assertNotEquals(null, $session->get("user")); $this->assertNotEquals(null, $session->get("user"));
$user = $session->get("user"); $user = $session->get("user");
$this->assertEquals("Username", $user->getUsername()); $this->assertEquals("Username", $user->getUsername());
@ -186,7 +186,7 @@ class ManagerTest extends BaseTestCase
{ {
$auth = $this->getManagerInstance($session, false); $auth = $this->getManagerInstance($session, false);
$this->assertFalse($auth->isAuthenticated(true)); $this->assertFalse($auth->isAuthenticated(true));
$auth->authenticate(new Credentials("jdoe", "passjdoe")); $auth->authenticate(new Credential("jdoe", "passjdoe"));
} }
/** /**
@ -213,7 +213,7 @@ class ManagerTest extends BaseTestCase
); );
$authManager->authenticate( $authManager->authenticate(
new Credentials('jdoe', 'passjdoe') new Credential('jdoe', 'passjdoe')
); );
} }
@ -250,7 +250,7 @@ class ManagerTest extends BaseTestCase
); );
$authManager->authenticate( $authManager->authenticate(
new Credentials('jdoe', 'passjdoe') new Credential('jdoe', 'passjdoe')
); );
} }
@ -272,20 +272,20 @@ class ManagerTest extends BaseTestCase
$authManager->getUserBackend('provider1')->setCredentials( $authManager->getUserBackend('provider1')->setCredentials(
array( array(
new Credentials('p1-user1', 'p1-passwd1'), new Credential('p1-user1', 'p1-passwd1'),
new Credentials('p1-user2', 'p1-passwd2') new Credential('p1-user2', 'p1-passwd2')
) )
); );
$authManager->getUserBackend('provider2')->setCredentials( $authManager->getUserBackend('provider2')->setCredentials(
array( array(
new Credentials('p2-user1', 'p2-passwd1'), new Credential('p2-user1', 'p2-passwd1'),
new Credentials('p2-user2', 'p2-passwd2') new Credential('p2-user2', 'p2-passwd2')
) )
); );
$this->assertTrue( $this->assertTrue(
$authManager->authenticate(new Credentials('p2-user2', 'p2-passwd2')) $authManager->authenticate(new Credential('p2-user2', 'p2-passwd2'))
); );
} }
@ -323,27 +323,27 @@ class ManagerTest extends BaseTestCase
$authManager->getUserBackend('provider4')->setCredentials( $authManager->getUserBackend('provider4')->setCredentials(
array( array(
new Credentials('p4-user1', 'p4-passwd1'), new Credential('p4-user1', 'p4-passwd1'),
new Credentials('p4-user2', 'p4-passwd2') new Credential('p4-user2', 'p4-passwd2')
) )
); );
$session->isOpen = true; $session->isOpen = true;
$this->assertTrue( $this->assertTrue(
$authManager->authenticate(new Credentials('p4-user2', 'p4-passwd2')) $authManager->authenticate(new Credential('p4-user2', 'p4-passwd2'))
); );
$session->isOpen = true; $session->isOpen = true;
$this->assertTrue( $this->assertTrue(
$authManager->authenticate(new Credentials('p4-user1', 'p4-passwd1')) $authManager->authenticate(new Credential('p4-user1', 'p4-passwd1'))
); );
$session->isOpen = true; $session->isOpen = true;
$this->assertFalse( $this->assertFalse(
$authManager->authenticate(new Credentials('p4-user2', 'p4-passwd1-WRONG123123')) $authManager->authenticate(new Credential('p4-user2', 'p4-passwd1-WRONG123123'))
); );
} }