Esempio n. 1
0
 function testRequireLogin()
 {
     $response = new Response();
     $bearer = new Bearer('Dagger', new Request(), $response);
     $bearer->requireLogin();
     $this->assertEquals('Bearer realm="Dagger"', $response->getHeader('WWW-Authenticate'));
     $this->assertEquals(401, $response->getStatus());
 }
Esempio n. 2
0
 private function getServerTokens($qop = Digest::QOP_AUTH)
 {
     $this->auth->requireLogin();
     switch ($qop) {
         case Digest::QOP_AUTH:
             $qopstr = 'auth';
             break;
         case Digest::QOP_AUTHINT:
             $qopstr = 'auth-int';
             break;
         default:
             $qopstr = 'auth,auth-int';
             break;
     }
     $test = preg_match('/Digest realm="' . self::REALM . '",qop="' . $qopstr . '",nonce="([0-9a-f]*)",opaque="([0-9a-f]*)"/', $this->response->getHeader('WWW-Authenticate'), $matches);
     $this->assertTrue($test == true, 'The WWW-Authenticate response didn\'t match our pattern. We received: ' . $this->response->getHeader('WWW-Authenticate'));
     $nonce = $matches[1];
     $opaque = $matches[2];
     // Reset our environment
     $this->setUp();
     $this->auth->setQOP($qop);
     return array($nonce, $opaque);
 }
Esempio n. 3
0
 function test401()
 {
     $this->auth->requireLogin();
     $test = preg_match('/^AWS$/', $this->response->getHeader('WWW-Authenticate'), $matches);
     $this->assertTrue($test == true, 'The WWW-Authenticate response didn\'t match our pattern');
 }