Example #1
0
 public function testResultInitializeProperly()
 {
     $auth1 = new phpRack_Runner_Auth_Result(true);
     $auth2 = new phpRack_Runner_Auth_Result(false);
     $this->assertTrue($auth1->isValid(), "AuthResult initializes with wrong values");
     $this->assertFalse($auth2->isValid(), "AuthResult initializes with wrong values");
 }
Example #2
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();
 }