From e76111c2b7a1f1b7c78824fbd917a5f0aab5d502 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Fri, 8 Feb 2013 11:45:51 +0000 Subject: [PATCH] Fixed silliness with access token verification --- src/OAuth2/Exception/InvalidAccessTokenException.php | 8 ++++++++ src/OAuth2/Exception/MissingAccessTokenException.php | 8 -------- src/OAuth2/ResourceServer.php | 2 +- tests/resource/ResourceServerTest.php | 7 +++++-- 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 src/OAuth2/Exception/InvalidAccessTokenException.php delete mode 100644 src/OAuth2/Exception/MissingAccessTokenException.php diff --git a/src/OAuth2/Exception/InvalidAccessTokenException.php b/src/OAuth2/Exception/InvalidAccessTokenException.php new file mode 100644 index 00000000..a7240992 --- /dev/null +++ b/src/OAuth2/Exception/InvalidAccessTokenException.php @@ -0,0 +1,8 @@ +storages['session']->validateAccessToken($access_token); if ( ! $result) { - return false; + throw new Exception\InvalidAccessTokenException('Access token is not valid'); } $this->accessToken = $access_token; diff --git a/tests/resource/ResourceServerTest.php b/tests/resource/ResourceServerTest.php index 3da9a991..b8fed73e 100644 --- a/tests/resource/ResourceServerTest.php +++ b/tests/resource/ResourceServerTest.php @@ -60,7 +60,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException OAuth2\Exception\InvalidAccessTokenException + * @expectedException OAuth2\Exception\InvalidAccessTokenException */ public function test_determineAccessToken_missingToken() { @@ -119,6 +119,9 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase $this->assertEquals('abcdef', $result); } + /** + * @expectedException OAuth2\Exception\InvalidAccessTokenException + */ public function test_isValid_notValid() { $this->session->shouldReceive('validateAccessToken')->andReturn(false); @@ -133,7 +136,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase $s = $this->returnDefault(); $s->setRequest($request); - $this->assertFalse($s->isValid()); + $s->isValid(); } public function test_isValid_valid()