Bonjour à tous,

voici mon cas :
- je développe actuellement une appli avec ZF 1.11 et ça se passe très bien
- j'ai 2 plugins pour l'authentification, authentification qui est faite avec un CAS :
* un plugin qui gère la redirection vers le server CAS quand on accède à la ressource /user/login pour se logger
* un plugin qui gère l'autologin si un ticket CAS existe déjà
- ces 2 plugins fonctionnent à merveille ( re- )

Mes problèmes commencent quand je veux utiliser Zend_Test avec PHPUnit.

Pour l'instant j'ai un testCase des plus simples

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
public function testIndexAction()
    {
        $this->dispatch('/');
        $this->assertAction('index');
        $this->assertModule('default');
        $this->assertController('index');
        $this->assertResponseCode(200);
    }
si j'exécute la suite, j'obtiens ceci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
RuntimeException: <html><head><title>CAS Authentication wanted!</title></head><body><h1>CAS Authentication wanted!</h1><p>You should already have been redirected to the CAS server. Click <a href="https://xxx/cas/login?service=http%3A%2F%2Fyyy%2Ftests%2Ftestlauncher.php&gateway=true">here</a> to continue.</p><hr><address>phpCAS 1.2.1 using server <a href="https://xxx/cas/">https://xxx/cas/</a> (CAS 2.0)</a></address></body></html
si je désactive le plugin d'autologin, ça a l'air de fonctionner

voici le plugin autologin

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
class App_Auth_Adapter_ECASGateway implements Zend_Auth_Adapter_Interface 
{
    public function authenticate()
    {
        $conf = Zend_Registry::get('Zend_Config');
 
        require_once($conf->ecas->path);
 
        global $PHPCAS_CLIENT;
 
        if(!is_object($PHPCAS_CLIENT))phpCAS::client(CAS_VERSION_2_0,(string) $conf->ecas->server,(integer) $conf->ecas->port,(string) $conf->ecas->uri,false);
        if( $conf->ecas->proxyUrl !== false) phpCAS::setServerProxyValidateURL('https://' . $conf->ecas->server . ':' . $conf->ecas->port . $conf->ecas->uri .  $conf->ecas->proxyUrl);
 
        phpCAS::setNoCasServerValidation();
 
        if (!phpCAS::checkAuthentication()) return new Zend_Auth_Result(Zend_Auth_Result::FAILURE,'anonymous');
 
        $user = phpCAS::getUser();
 
        $userInfo = App_Auth_Helper_Ldap::getLdapUserInfo( $user );
 
        if (!empty($userInfo))  
        {
            $identity = new App_Identity( $userInfo );
            return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS , $identity );
        }
        else return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND , 'anonymous' );  
    }
et ce plugin est activé dans mon controller, partie 'predispatch'

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
$auth = Zend_Auth::getInstance();
$auth->authenticate( new App_Auth_Adapter_ECASGateway );
donc ma question est : comment faire fonctionner mes tests avec un autologin comme celui-là.

Par avance merci !