From d7c1c5026982d2a103d89854a08e6661f23946ff Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Sat, 31 May 2014 15:34:12 -0500 Subject: [PATCH] Throw MissingAccessTokenException in the Resource server when no token exists --- .../Exception/MissingAccessTokenException.php | 20 +++++++++++++++++++ src/League/OAuth2/Server/Resource.php | 5 +++-- tests/resource/ResourceServerTest.php | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/League/OAuth2/Server/Exception/MissingAccessTokenException.php diff --git a/src/League/OAuth2/Server/Exception/MissingAccessTokenException.php b/src/League/OAuth2/Server/Exception/MissingAccessTokenException.php new file mode 100644 index 00000000..7bc3fe83 --- /dev/null +++ b/src/League/OAuth2/Server/Exception/MissingAccessTokenException.php @@ -0,0 +1,20 @@ + + * @copyright Copyright (c) 2014 PHP League of Extraordinary Packages + * @license http://mit-license.org/ + * @link http://github.com/php-loep/oauth2-server + */ + +namespace League\OAuth2\Server\Exception; + +/** + * MissingAccessToken Exception + */ +class MissingAccessTokenException extends OAuth2Exception +{ + +} diff --git a/src/League/OAuth2/Server/Resource.php b/src/League/OAuth2/Server/Resource.php index 3485315a..eb48ac5e 100644 --- a/src/League/OAuth2/Server/Resource.php +++ b/src/League/OAuth2/Server/Resource.php @@ -4,7 +4,8 @@ * * @package php-loep/oauth2-server * @author Alex Bilbie - * @copyright Copyright (c) 2013 PHP League of Extraordinary Packages + * @author Woody Gilk + * @copyright Copyright (c) 2013-2014 PHP League of Extraordinary Packages * @license http://mit-license.org/ * @link http://github.com/php-loep/oauth2-server */ @@ -274,7 +275,7 @@ class Resource } if (empty($accessToken)) { - throw new Exception\InvalidAccessTokenException('Access token is missing'); + throw new Exception\MissingAccessTokenException('Access token is missing'); } return $accessToken; diff --git a/tests/resource/ResourceServerTest.php b/tests/resource/ResourceServerTest.php index aee81b52..b25b89be 100644 --- a/tests/resource/ResourceServerTest.php +++ b/tests/resource/ResourceServerTest.php @@ -66,7 +66,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException League\OAuth2\Server\Exception\InvalidAccessTokenException + * @expectedException League\OAuth2\Server\Exception\MissingAccessTokenException */ public function test_determineAccessToken_missingToken() { @@ -84,7 +84,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase } /** - * @expectedException League\OAuth2\Server\Exception\InvalidAccessTokenException + * @expectedException League\OAuth2\Server\Exception\MissingAccessTokenException */ public function test_determineAccessToken_brokenCurlRequest() {