Renamed Authorization to AuthorizationServer

This commit is contained in:
Alex Bilbie 2014-02-24 14:43:00 +00:00
parent 5254c9d225
commit 013b1b53b4
2 changed files with 17 additions and 17 deletions

View File

@ -11,7 +11,7 @@
namespace League\OAuth2\Server\Grant; namespace League\OAuth2\Server\Grant;
use League\OAuth2\Server\Authorization; use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Entity\AccessToken; use League\OAuth2\Server\Entity\AccessToken;
use League\OAuth2\Server\Entity\Client; use League\OAuth2\Server\Entity\Client;
use League\OAuth2\Server\Entity\Session; use League\OAuth2\Server\Entity\Session;
@ -62,7 +62,7 @@ class ClientCredentials extends AbstractGrant
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', null);
if (is_null($clientId)) { if (is_null($clientId)) {
throw new ClientException( throw new ClientException(
sprintf(Authorization::getExceptionMessage('invalid_request'), 'client_id'), sprintf(AuthorizationServer::getExceptionMessage('invalid_request'), 'client_id'),
0 0
); );
} }
@ -70,7 +70,7 @@ class ClientCredentials extends AbstractGrant
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret', null);
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
throw new ClientException( throw new ClientException(
sprintf(Authorization::getExceptionMessage('invalid_request'), 'client_secret'), sprintf(AuthorizationServer::getExceptionMessage('invalid_request'), 'client_secret'),
0 0
); );
} }
@ -84,7 +84,7 @@ class ClientCredentials extends AbstractGrant
); );
if (($client instanceof Client) === false) { if (($client instanceof Client) === false) {
throw new ClientException(Authorization::getExceptionMessage('invalid_client'), 8); throw new ClientException(AuthorizationServer::getExceptionMessage('invalid_client'), 8);
} }
// Validate any scopes that are in the request // Validate any scopes that are in the request

View File

@ -2,7 +2,7 @@
namespace LeagueTests; namespace LeagueTests;
use League\OAuth2\Server\Authorization; use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Grant\GrantTypeInterface; use League\OAuth2\Server\Grant\GrantTypeInterface;
use League\OAuth2\Server\Storage\ScopeInterface; use League\OAuth2\Server\Storage\ScopeInterface;
use \Mockery as M; use \Mockery as M;
@ -11,9 +11,9 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase
{ {
public function testGetExceptionMessage() public function testGetExceptionMessage()
{ {
$m = Authorization::getExceptionMessage('access_denied'); $m = AuthorizationServer::getExceptionMessage('access_denied');
$reflector = new \ReflectionClass('League\OAuth2\Server\Authorization'); $reflector = new \ReflectionClass('League\OAuth2\Server\AuthorizationServer');
$exceptionMessages = $reflector->getProperty('exceptionMessages'); $exceptionMessages = $reflector->getProperty('exceptionMessages');
$exceptionMessages->setAccessible(true); $exceptionMessages->setAccessible(true);
$v = $exceptionMessages->getValue(); $v = $exceptionMessages->getValue();
@ -23,20 +23,20 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase
public function testGetExceptionCode() public function testGetExceptionCode()
{ {
$this->assertEquals('access_denied', Authorization::getExceptionType(2)); $this->assertEquals('access_denied', AuthorizationServer::getExceptionType(2));
} }
public function testGetExceptionHttpHeaders() public function testGetExceptionHttpHeaders()
{ {
$this->assertEquals(array('HTTP/1.1 401 Unauthorized'), Authorization::getExceptionHttpHeaders('access_denied')); $this->assertEquals(array('HTTP/1.1 401 Unauthorized'), AuthorizationServer::getExceptionHttpHeaders('access_denied'));
$this->assertEquals(array('HTTP/1.1 500 Internal Server Error'), Authorization::getExceptionHttpHeaders('server_error')); $this->assertEquals(array('HTTP/1.1 500 Internal Server Error'), AuthorizationServer::getExceptionHttpHeaders('server_error'));
$this->assertEquals(array('HTTP/1.1 501 Not Implemented'), Authorization::getExceptionHttpHeaders('unsupported_grant_type')); $this->assertEquals(array('HTTP/1.1 501 Not Implemented'), AuthorizationServer::getExceptionHttpHeaders('unsupported_grant_type'));
$this->assertEquals(array('HTTP/1.1 400 Bad Request'), Authorization::getExceptionHttpHeaders('invalid_refresh')); $this->assertEquals(array('HTTP/1.1 400 Bad Request'), AuthorizationServer::getExceptionHttpHeaders('invalid_refresh'));
} }
public function testSetGet() public function testSetGet()
{ {
$server = new Authorization; $server = new AuthorizationServer;
$server->requireScopeParam(true); $server->requireScopeParam(true);
$server->requireStateParam(true); $server->requireStateParam(true);
$server->setDefaultScope('foobar'); $server->setDefaultScope('foobar');
@ -68,7 +68,7 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase
public function testInvalidGrantType() public function testInvalidGrantType()
{ {
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidGrantTypeException'); $this->setExpectedException('League\OAuth2\Server\Exception\InvalidGrantTypeException');
$server = new Authorization; $server = new AuthorizationServer;
$server->getGrantType('foobar'); $server->getGrantType('foobar');
} }
@ -82,7 +82,7 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'foobar'; $_POST['grant_type'] = 'foobar';
$server = new Authorization; $server = new AuthorizationServer;
$server->addGrantType($grant); $server->addGrantType($grant);
$this->assertTrue($server->issueAccessToken()); $this->assertTrue($server->issueAccessToken());
@ -91,7 +91,7 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase
public function testIssueAccessTokenEmptyGrantType() public function testIssueAccessTokenEmptyGrantType()
{ {
$this->setExpectedException('League\OAuth2\Server\Exception\ClientException'); $this->setExpectedException('League\OAuth2\Server\Exception\ClientException');
$server = new Authorization; $server = new AuthorizationServer;
$this->assertTrue($server->issueAccessToken()); $this->assertTrue($server->issueAccessToken());
} }
@ -101,7 +101,7 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'foobar'; $_POST['grant_type'] = 'foobar';
$server = new Authorization; $server = new AuthorizationServer;
$this->assertTrue($server->issueAccessToken()); $this->assertTrue($server->issueAccessToken());
} }
} }