/**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     //     	phpCAS::setDebug(dirname(__FILE__).'/../test.log');
     // 		error_reporting(E_ALL);
     CAS_GracefullTerminationException::throwInsteadOfExiting();
     $_SERVER['SERVER_NAME'] = 'www.clientapp.com';
     $_SERVER['SERVER_PORT'] = '80';
     $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
     $_SERVER['SERVER_ADMIN'] = 'root@localhost';
     $_SERVER['REQUEST_URI'] = '/';
     $_SERVER['SCRIPT_NAME'] = '/index.php';
     $_SERVER['PHP_SELF'] = '/index.php';
     $_SESSION = array();
     $this->object = new CAS_Client(CAS_VERSION_2_0, true, 'cas.example.edu', 443, '/cas/', false);
     $this->object->setRequestImplementation('CAS_TestHarness_DummyRequest');
     $this->object->setCasServerCACert('/path/to/ca_cert.crt');
     /*********************************************************
      * Enumerate our responses
      *********************************************************/
     // Set up our response.
     $response = new CAS_TestHarness_BasicResponse('https', 'cas.example.edu', '/cas/serviceValidate');
     $response->setResponseHeaders(array('HTTP/1.1 200 OK', 'Date: Wed, 29 Sep 2010 19:20:57 GMT', 'Server: Apache-Coyote/1.1', 'Pragma: no-cache', 'Expires: Thu, 01 Jan 1970 00:00:00 GMT', 'Cache-Control: no-cache, no-store', 'Content-Type: text/html;charset=UTF-8', 'Content-Language: en-US', 'Via: 1.1 cas.example.edu', 'Connection: close', 'Transfer-Encoding: chunked'));
     $response->setResponseBody("<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>\n    <cas:authenticationSuccess>\n        <cas:user>jsmith</cas:user>\n    </cas:authenticationSuccess>\n</cas:serviceResponse>\n");
     CAS_TestHarness_DummyRequest::addResponse($response);
 }
 /**
  * Force phpcas to thow Exceptions instead of calling exit()
  * Needed for unit testing. Generally shouldn't be used in production
  * due to an increase in Apache error logging if CAS_GracefulTerminiationExceptions
  * are not caught and handled.
  */
 public static function throwInsteadOfExiting()
 {
     self::$exitWhenThrown = false;
 }
Example #3
0
         }
       }
     }
     $indice++;
     $str_traces .= '</li>'."\n";
   }
   return $str_traces;
 }
 try
 {
   // Pour la méthode error() de phpCAS qui comporte un echo
   ob_start();
   // Appeler getVersion() est juste une ruse pour charger l'autoload de phpCAS avant l'appel client()
   phpCAS::getVersion();
   // Maintenant que l'autoload est chargé on peut appeler cette méthode avant l'appel client()
   CAS_GracefullTerminationException::throwInsteadOfExiting();
   // Si besoin, cette méthode statique créé un fichier de log sur ce qui se passe avec CAS
   if(DEBUG_PHPCAS)
   {
     if( (HEBERGEUR_INSTALLATION=='mono-structure') || !PHPCAS_LOGS_ETABL_LISTING || (strpos(PHPCAS_LOGS_ETABL_LISTING,','.$BASE.',')!==FALSE) )
     {
       $fichier_nom_debut = 'debugcas_'.$BASE;
       $fichier_nom_fin   = fabriquer_fin_nom_fichier__pseudo_alea($fichier_nom_debut);
       phpCAS::setDebug(PHPCAS_LOGS_CHEMIN.$fichier_nom_debut.'_'.$fichier_nom_fin.'.txt');
     }
   }
   // Initialiser la connexion avec CAS ; le premier argument est la version du protocole CAS ; le dernier argument indique qu'on utilise la session existante
   phpCAS::client(CAS_VERSION_2_0, $cas_serveur_host, (int)$cas_serveur_port, $cas_serveur_root, FALSE);
   phpCAS::setLang(PHPCAS_LANG_FRENCH);
   // Surcharge éventuelle des URL
   if ($cas_serveur_url_login)    { phpCAS::setServerLoginURL($cas_serveur_url_login); }