Example #1
0
 public function __construct(Connection $connection, $requestMethod, $routeId, Closure $appCallback)
 {
     parent::__construct(function ($token) {
         return $this->isValidToken($token);
     });
     $this->connection = $connection;
     $this->requestMethod = $requestMethod;
     $this->routeId = $routeId;
     $this->appCallback = $appCallback;
 }
Example #2
0
 public function testMissingWrongType()
 {
     $handle = new Oauth2Authentication(function ($accessToken) {
         return $accessToken == self::ACCESS_TOKEN;
     });
     $oauth = new Oauth2();
     $value = $oauth->getAuthorizationHeader($this->getAccessToken());
     $request = new Request(new Url('http://localhost/index.php'), 'GET', array('Authorization' => 'Foo'));
     $response = new Response();
     $filterChain = $this->getMockFilterChain();
     $filterChain->expects($this->never())->method('handle');
     try {
         $handle->handle($request, $response, $filterChain);
         $this->fail('Must throw an Exception');
     } catch (UnauthorizedException $e) {
         $this->assertEquals(401, $e->getStatusCode());
         $this->assertEquals('Bearer', $e->getType());
         $this->assertEquals(array('realm' => 'psx'), $e->getParameters());
     }
 }