Example #1
0
 /**
  * Checks whether user is authenticated before running any tests
  *
  * @return boolean
  * @see bootstrap.php
  */
 public function isAuthenticated()
 {
     if (!is_null($this->_authResult)) {
         return $this->_authResult->isValid();
     }
     // this is CLI environment, not web -- we don't require any
     // authentication
     if ($this->_runner->isCliEnvironment()) {
         return $this->_validated(true)->isValid();
     }
     // there are a number of possible authentication scenarios
     switch (true) {
         case $result = $this->_tryHttpPost():
             break;
         case $result = $this->_tryHttpGet():
             break;
         case $result = $this->_tryHttpCookie():
             break;
         case $result = $this->_tryPlainAuth():
             break;
         default:
             // no authinfo, chances are that site is not protected
             $result = array('login' => false, 'hash' => false);
     }
     $this->_authResult = $this->authenticate($result['login'], $result['hash'], true);
     return $this->_authResult->isValid();
 }
Example #2
0
     define('PHPRACK_AJAX_TOKEN', 'token');
 }
 if (!defined('PHPRACK_PATH')) {
     define('PHPRACK_PATH', dirname(__FILE__));
 }
 /**
  * @see phpRack_Runner
  */
 require_once PHPRACK_PATH . '/Runner.php';
 $runner = new phpRack_Runner($phpRackConfig);
 /**
  * @see phpRack_View
  */
 require_once PHPRACK_PATH . '/View.php';
 // if it's CLI environment - just show a full test report
 if ($runner->isCliEnvironment()) {
     throw new Exception($runner->runSuite());
 }
 // check whether SSL connection is mandatory?
 if (!$runner->isEnoughSecurityLevel()) {
     throw new Exception('You must use SSL protocol to run integration tests');
 }
 /**
  * Using this tag in GET URL we can get a summary report
  * in plain text format.
  */
 if (array_key_exists('suite', $_GET)) {
     header('Content-Type: text/plain');
     if (!$runner->getAuth()->isAuthenticated()) {
         throw new Exception('Access denied');
     }