Changeset 756

Show
Ignore:
Timestamp:
07/09/07 23:45:34 (1 year ago)
Author:
mikey
Message:

added unit tests for net.stubbles.auth (fixes enhancement #46)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/auth/storage/stubAuthAbstractStorage.php

    r755 r756  
    2222     * @var  int 
    2323     */ 
    24     protected $timeout   = 3600; 
     24    protected $timeout = 3600; 
    2525 
    2626    /** 
     
    7171    public function setResult(stubAuthResult $result) 
    7272    { 
    73         $this->doSetResult($result, $this->storetime); 
     73        $this->doSetResult($result, time()); 
    7474    } 
    7575 
  • trunk/src/main/php/net/stubbles/auth/storage/stubAuthSessionStorage.php

    r755 r756  
    77 * @subpackage  auth_storage 
    88 */ 
    9 stubClassLoader::load('net.stubbles.auth.storage.stubAuthStorage'); 
     9stubClassLoader::load('net.stubbles.auth.storage.stubAuthAbstractStorage', 
     10                      'net.stubbles.ipo.session.stubSession' 
     11); 
    1012/** 
    1113 * Storage that stores the authentication result within the session. 
     
    6466    public function getResult() 
    6567    { 
    66         $this->session->getValue('net.stubbles.auth.result'); 
     68        return $this->session->getValue('net.stubbles.auth.result'); 
    6769    } 
    6870 
  • trunk/src/main/php/net/stubbles/auth/strategy/stubAuthFailOverStrategy.php

    r754 r756  
    1010/** 
    1111 * Authentication strategy that uses the first authenticator and the other only if the first fails. 
     12 *  
     13 * The first result which status is not stubAuthResult::STATUS_AUTHENTICATOR_FAILURE 
     14 * will be returned. This means even if the first authenticator says the  
     15 * credentials are invalid and the second authenticator would say the attempt 
     16 * is successfull the authentication will fail because the first result will be 
     17 * returned. 
     18 * Only if all authenticators fail the result will be of status 
     19 * stubAuthResult::STATUS_AUTHENTICATOR_FAILURE. 
    1220 * 
    1321 * @package     stubbles 
  • trunk/src/main/php/net/stubbles/auth/strategy/stubAuthOrStrategy.php

    r754 r756  
    1010/** 
    1111 * Authentication strategy that tries all authenticators until one was successful or all have been used. 
     12 *  
     13 * If the authentication fails because none of the authenticator succeeds 
     14 * (independend of internal failure or invalid credentials) only the result 
     15 * of the last authenticator will be returned. 
    1216 * 
    1317 * @package     stubbles 
  • trunk/src/main/php/net/stubbles/auth/stubAuth.php

    r755 r756  
    103103 
    104104    /** 
     105     * destroys the instance if it exists 
     106     * 
     107     * @param  string  $id  id of the auth instance to destroy 
     108     */ 
     109    public static function destroyInstance($id = self::ID_DEFAULT) 
     110    { 
     111        if (isset(self::$instances[$id]) == true) { 
     112            unset(self::$instances[$id]); 
     113        } 
     114    } 
     115     
     116    /** 
    105117     * checks if the specified auth instances contains a valid authentification 
    106118     *  
     
    162174     * authenticate the credentials 
    163175     * 
    164      * @param   mixed            $credentials 
     176     * @param   mixed              $credentials 
    165177     * @return  stubAuthStorage 
     178     * @throws  stubAuthException  in case no authenticators have been added 
    166179     */ 
    167180    public function authenticate($credentials) 
    168181    { 
    169         $this->storage->setResult($this->authentificationStrategy->authenticate($this->authenticators, $credentials)); 
     182        if (count($this->authenticators) == 0) { 
     183            throw new stubAuthException('Please add at least one authenticator before trying to authenticate some credentials.'); 
     184        } 
     185         
     186        $this->storage->setResult($this->strategy->authenticate($this->authenticators, $credentials)); 
    170187        return $this->storage; 
    171188    } 
  • trunk/src/test/run.php

    r740 r756  
    3232 
    3333        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/stubTestSuite.php'); 
     34        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/auth/AuthTestSuite.php'); 
    3435        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/events/EventTestSuite.php'); 
    3536        $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/ioc/IOCTestSuite.php');