Renamed AuthServer to Authorization, renamed ResourceServer to Resource. Updated all tests and other files

This commit is contained in:
Alex Bilbie 2013-05-08 11:42:23 -07:00
parent 1df524ae6e
commit 437833cd32
32 changed files with 273 additions and 273 deletions

View File

@ -9,19 +9,19 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2;
namespace League\OAuth2\Server;
use League\OAuth2\Util\Request;
use League\OAuth2\Util\SecureKey;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Grant\GrantTypeInterface;
use League\OAuth2\Server\Util\Request;
use League\OAuth2\Server\Util\SecureKey;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
use League\OAuth2\Server\Grant\GrantTypeInterface;
/**
* OAuth 2.0 authorization server class
*/
class AuthServer
class Authorization
{
/**
* The delimeter between scopes specified in the scope query string parameter

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Exception;
namespace League\OAuth2\Server\Exception;
/**
* ClientException Exception

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Exception;
namespace League\OAuth2\Server\Exception;
/**
* InvalidAccessToken Exception

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Exception;
namespace League\OAuth2\Server\Exception;
/**
* InvalidGrantTypeException Exception

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Exception;
namespace League\OAuth2\Server\Exception;
/**
* Exception class

View File

@ -9,15 +9,15 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Grant;
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Request;
use League\OAuth2\AuthServer;
use League\OAuth2\Exception;
use League\OAuth2\Util\SecureKey;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Server\Request;
use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\SecureKey;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
/**
* Auth code grant class
@ -59,7 +59,7 @@ class AuthCode implements GrantTypeInterface {
* @param AuthServer $authServer AuthServer instance
* @return void
*/
public function __construct(AuthServer $authServer)
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}

View File

@ -9,15 +9,15 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Grant;
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Request;
use League\OAuth2\AuthServer;
use League\OAuth2\Exception;
use League\OAuth2\Util\SecureKey;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Server\Request;
use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\SecureKey;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
/**
* Client credentials grant class
@ -53,7 +53,7 @@ class ClientCredentials implements GrantTypeInterface {
* @param AuthServer $authServer AuthServer instance
* @return void
*/
public function __construct(AuthServer $authServer)
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}
@ -97,18 +97,18 @@ class ClientCredentials implements GrantTypeInterface {
$authParams = $this->authServer->getParam(array('client_id', 'client_secret'), 'post', $inputParams);
if (is_null($authParams['client_id'])) {
throw new Exception\ClientException(sprintf(AuthServer::getExceptionMessage('invalid_request'), 'client_id'), 0);
throw new Exception\ClientException(sprintf(Authorization::getExceptionMessage('invalid_request'), 'client_id'), 0);
}
if (is_null($authParams['client_secret'])) {
throw new Exception\ClientException(sprintf(AuthServer::getExceptionMessage('invalid_request'), 'client_secret'), 0);
throw new Exception\ClientException(sprintf(Authorization::getExceptionMessage('invalid_request'), 'client_secret'), 0);
}
// Validate client ID and client secret
$clientDetails = $this->authServer->getStorage('client')->getClient($authParams['client_id'], $authParams['client_secret'], null, $this->identifier);
if ($clientDetails === false) {
throw new Exception\ClientException(AuthServer::getExceptionMessage('invalid_client'), 8);
throw new Exception\ClientException(Authorization::getExceptionMessage('invalid_client'), 8);
}
$authParams['client_details'] = $clientDetails;

View File

@ -9,15 +9,15 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Grant;
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Request;
use League\OAuth2\AuthServer;
use League\OAuth2\Exception;
use League\OAuth2\Util\SecureKey;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Server\Request;
use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\SecureKey;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
interface GrantTypeInterface
{
@ -26,7 +26,7 @@ interface GrantTypeInterface
* @param AuthServer $authServer AuthServer instance
* @return void
*/
public function __construct(AuthServer $authServer);
public function __construct(Authorization $authServer);
/**
* Returns the grant identifier (used to validate grant_type in OAuth2\AuthServer\issueAccessToken())

View File

@ -9,15 +9,15 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Grant;
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Request;
use League\OAuth2\AuthServer;
use League\OAuth2\Exception;
use League\OAuth2\Util\SecureKey;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Server\Request;
use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\SecureKey;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
/**
* Client credentials grant class
@ -47,7 +47,7 @@ class Implict implements GrantTypeInterface {
* @param AuthServer $authServer AuthServer instance
* @return void
*/
public function __construct(AuthServer $authServer)
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}

View File

@ -9,15 +9,15 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Grant;
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Request;
use League\OAuth2\AuthServer;
use League\OAuth2\Exception;
use League\OAuth2\Util\SecureKey;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Server\Request;
use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\SecureKey;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
/**
* Password grant class
@ -59,7 +59,7 @@ class Password implements GrantTypeInterface {
* @param AuthServer $authServer AuthServer instance
* @return void
*/
public function __construct(AuthServer $authServer)
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}

View File

@ -9,15 +9,15 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Grant;
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Request;
use League\OAuth2\AuthServer;
use League\OAuth2\Exception;
use League\OAuth2\Util\SecureKey;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Server\Request;
use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\SecureKey;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
/**
* Referesh token grant
@ -59,7 +59,7 @@ class RefreshToken implements GrantTypeInterface {
* @param AuthServer $authServer AuthServer instance
* @return void
*/
public function __construct(AuthServer $authServer)
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}

View File

@ -9,17 +9,17 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2;
namespace League\OAuth2\Server;
use OutOfBoundsException;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Util\RequestInterface;
use League\OAuth2\Util\Request;
use League\OAuth2\Server\Storage\SessionInterface;
use League\OAuth2\Server\Util\RequestInterface;
use League\OAuth2\Server\Util\Request;
/**
* OAuth 2.0 Resource Server
*/
class ResourceServer
class Resource
{
/**
* The access token

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Storage;
namespace League\OAuth2\Server\Storage;
interface ClientInterface
{

View File

@ -1,8 +1,8 @@
<?php
namespace League\OAuth2\Storage\PDO;
namespace League\OAuth2\Server\Storage\PDO;
use League\OAuth2\Storage\ClientInterface;
use League\OAuth2\Server\Storage\ClientInterface;
class Client implements ClientInterface
{

View File

@ -1,6 +1,6 @@
<?php
namespace League\OAuth2\Storage\PDO;
namespace League\OAuth2\Server\Storage\PDO;
class Db
{

View File

@ -1,8 +1,8 @@
<?php
namespace League\OAuth2\Storage\PDO;
namespace League\OAuth2\Server\Storage\PDO;
use League\OAuth2\Storage\ScopeInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
class Scope implements ScopeInterface
{

View File

@ -1,8 +1,8 @@
<?php
namespace League\OAuth2\Storage\PDO;
namespace League\OAuth2\Server\Storage\PDO;
use League\OAuth2\Storage\SessionInterface;
use League\OAuth2\Server\Storage\SessionInterface;
class Session implements SessionInterface
{

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Storage;
namespace League\OAuth2\Server\Storage;
interface ScopeInterface
{

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Storage;
namespace League\OAuth2\Server\Storage;
interface SessionInterface
{

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Util;
namespace League\OAuth2\Server\Util;
/**
* RedirectUri class

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Util;
namespace League\OAuth2\Server\Util;
use OutOfBoundsException;
use InvalidMethodCallException;

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Util;
namespace League\OAuth2\Server\Util;
interface RequestInterface
{

View File

@ -9,7 +9,7 @@
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Util;
namespace League\OAuth2\Server\Util;
/**
* SecureKey class

View File

@ -10,20 +10,20 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
public function setUp()
{
$this->client = M::mock('League\OAuth2\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Storage\ScopeInterface');
$this->client = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
}
private function returnDefault()
{
return new League\OAuth2\AuthServer($this->client, $this->session, $this->scope);
return new League\OAuth2\Server\Authorization($this->client, $this->session, $this->scope);
}
public function test_setAuthTokenTTL()
{
$a = $this->returnDefault();
$grant = new League\OAuth2\Grant\AuthCode($a);
$grant = new League\OAuth2\Server\Grant\AuthCode($a);
$grant->setAuthTokenTTL(30);
$reflector = new ReflectionClass($grant);
@ -35,25 +35,25 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_checkAuthoriseParams_noClientId()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$g->checkAuthoriseParams();
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_checkAuthoriseParams_noRedirectUri()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234
@ -61,13 +61,13 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_checkAuthoriseParams_noRequiredState()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$a->requireStateParam(true);
$g->checkAuthoriseParams(array(
@ -78,7 +78,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 8
*/
public function test_checkAuthoriseParams_badClient()
@ -86,7 +86,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -95,7 +95,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_checkAuthoriseParams_missingResponseType()
@ -108,7 +108,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -117,7 +117,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 3
*/
public function test_checkAuthoriseParams_badResponseType()
@ -130,7 +130,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -140,7 +140,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_checkAuthoriseParams_missingScopes()
@ -153,9 +153,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -182,9 +182,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->setDefaultScope('test.scope');
$a->requireScopeParam(false);
@ -199,7 +199,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 4
*/
public function test_checkAuthoriseParams_badScopes()
@ -214,9 +214,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$this->scope->shouldReceive('getScope')->andReturn(false);
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -229,9 +229,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
public function test_checkAuthoriseParams_passedInput()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$this->client->shouldReceive('getClient')->andReturn(array(
'client_id' => 1234,
@ -295,9 +295,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$_GET['client_id'] = 1234;
$_GET['redirect_uri'] = 'http://foo/redirect';
@ -305,7 +305,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$_GET['scope'] = 'foo';
$_GET['state'] = 'xyz';
$request = new League\OAuth2\Util\Request($_GET);
$request = new League\OAuth2\Server\Util\Request($_GET);
$a->setRequest($request);
$v = $g->checkAuthoriseParams();
@ -343,7 +343,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAuthCode')->andReturn(null);
$a = $this->returnDefault();
$g = new League\OAuth2\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g);
$params = array(

View File

@ -10,14 +10,14 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function setUp()
{
$this->client = M::mock('League\OAuth2\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Storage\ScopeInterface');
$this->client = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
}
private function returnDefault()
{
return new League\OAuth2\AuthServer($this->client, $this->session, $this->scope);
return new League\OAuth2\Server\Authorization($this->client, $this->session, $this->scope);
}
/**
@ -25,7 +25,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
*/
public function test__construct_NoStorage()
{
$a = new League\OAuth2\AuthServer;
$a = new League\OAuth2\Server\Authorization;
}
public function test__contruct_WithStorage()
@ -35,7 +35,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_getExceptionMessage()
{
$m = League\OAuth2\AuthServer::getExceptionMessage('access_denied');
$m = League\OAuth2\Server\Authorization::getExceptionMessage('access_denied');
$reflector = new ReflectionClass($this->returnDefault());
$exceptionMessages = $reflector->getProperty('exceptionMessages');
@ -47,15 +47,15 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_getExceptionCode()
{
$this->assertEquals('access_denied', League\OAuth2\AuthServer::getExceptionType(2));
$this->assertEquals('access_denied', League\OAuth2\Server\Authorization::getExceptionType(2));
}
public function test_getExceptionHttpHeaders()
{
$this->assertEquals(array('HTTP/1.1 401 Unauthorized'), League\OAuth2\AuthServer::getExceptionHttpHeaders('access_denied'));
$this->assertEquals(array('HTTP/1.1 500 Internal Server Error'), League\OAuth2\AuthServer::getExceptionHttpHeaders('server_error'));
$this->assertEquals(array('HTTP/1.1 501 Not Implemented'), League\OAuth2\AuthServer::getExceptionHttpHeaders('unsupported_grant_type'));
$this->assertEquals(array('HTTP/1.1 400 Bad Request'), League\OAuth2\AuthServer::getExceptionHttpHeaders('invalid_refresh'));
$this->assertEquals(array('HTTP/1.1 401 Unauthorized'), League\OAuth2\Server\Authorization::getExceptionHttpHeaders('access_denied'));
$this->assertEquals(array('HTTP/1.1 500 Internal Server Error'), League\OAuth2\Server\Authorization::getExceptionHttpHeaders('server_error'));
$this->assertEquals(array('HTTP/1.1 501 Not Implemented'), League\OAuth2\Server\Authorization::getExceptionHttpHeaders('unsupported_grant_type'));
$this->assertEquals(array('HTTP/1.1 400 Bad Request'), League\OAuth2\Server\Authorization::getExceptionHttpHeaders('invalid_refresh'));
}
public function test_hasGrantType()
@ -67,7 +67,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_addGrantType()
{
$a = $this->returnDefault();
$grant = M::mock('League\OAuth2\Grant\GrantTypeInterface');
$grant = M::mock('League\OAuth2\Server\Grant\GrantTypeInterface');
$grant->shouldReceive('getResponseType')->andReturn('test');
$a->addGrantType($grant, 'test');
@ -77,7 +77,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_addGrantType_noIdentifier()
{
$a = $this->returnDefault();
$grant = M::mock('League\OAuth2\Grant\GrantTypeInterface');
$grant = M::mock('League\OAuth2\Server\Grant\GrantTypeInterface');
$grant->shouldReceive('getIdentifier')->andReturn('test');
$grant->shouldReceive('getResponseType')->andReturn('test');
$a->addGrantType($grant);
@ -169,7 +169,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_setRequest()
{
$a = $this->returnDefault();
$request = new League\OAuth2\Util\Request();
$request = new League\OAuth2\Server\Util\Request();
$a->setRequest($request);
$reflector = new ReflectionClass($a);
@ -177,29 +177,29 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$requestProperty->setAccessible(true);
$v = $requestProperty->getValue($a);
$this->assertTrue($v instanceof League\OAuth2\Util\RequestInterface);
$this->assertTrue($v instanceof League\OAuth2\Server\Util\RequestInterface);
}
public function test_getRequest()
{
$a = $this->returnDefault();
$request = new League\OAuth2\Util\Request();
$request = new League\OAuth2\Server\Util\Request();
$a->setRequest($request);
$v = $a->getRequest();
$this->assertTrue($v instanceof League\OAuth2\Util\RequestInterface);
$this->assertTrue($v instanceof League\OAuth2\Server\Util\RequestInterface);
}
public function test_getStorage()
{
$a = $this->returnDefault();
$this->assertTrue($a->getStorage('session') instanceof League\OAuth2\Storage\SessionInterface);
$this->assertTrue($a->getStorage('session') instanceof League\OAuth2\Server\Storage\SessionInterface);
}
public function test_getGrantType()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$reflector = new ReflectionClass($a);
$method = $reflector->getMethod('getGrantType');
@ -207,11 +207,11 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$result = $method->invoke($a, 'authorization_code');
$this->assertTrue($result instanceof League\OAuth2\Grant\GrantTypeInterface);
$this->assertTrue($result instanceof League\OAuth2\Server\Grant\GrantTypeInterface);
}
/**
* @expectedException League\OAuth2\Exception\InvalidGrantTypeException
* @expectedException League\OAuth2\Server\Exception\InvalidGrantTypeException
* @expectedExceptionCode 9
*/
public function test_getGrantType_fail()
@ -221,37 +221,37 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_missingGrantType()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken();
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 7
*/
public function test_issueAccessToken_badGrantType()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array('grant_type' => 'foo'));
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code'
@ -259,13 +259,13 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_missingClientSecret()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -274,13 +274,13 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_missingRedirectUri()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -290,7 +290,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 8
*/
public function test_issueAccessToken_badClient()
@ -298,7 +298,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -309,7 +309,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_missingCode()
@ -317,7 +317,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(array());
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -328,7 +328,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 9
*/
public function test_issueAccessToken_badCode()
@ -337,7 +337,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('validateAuthCode')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -367,7 +367,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -401,7 +401,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$_POST['grant_type'] = 'authorization_code';
$_POST['client_id'] = 1234;
@ -409,7 +409,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$_POST['redirect_uri'] = 'http://foo/redirect';
$_POST['code'] = 'foobar';
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -438,7 +438,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$grant = new League\OAuth2\Grant\AuthCode($a);
$grant = new League\OAuth2\Server\Grant\AuthCode($a);
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
@ -448,7 +448,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$_POST['redirect_uri'] = 'http://foo/redirect';
$_POST['code'] = 'foobar';
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -479,7 +479,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$_POST['grant_type'] = 'authorization_code';
$_SERVER['PHP_AUTH_USER'] = 1234;
@ -487,7 +487,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$_POST['redirect_uri'] = 'http://foo/redirect';
$_POST['code'] = 'foobar';
$request = new League\OAuth2\Util\Request(array(), $_POST, array(), array(), $_SERVER);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST, array(), array(), $_SERVER);
$a->setRequest($request);
$v = $a->issueAccessToken();

View File

@ -10,26 +10,26 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
public function setUp()
{
$this->client = M::mock('League\OAuth2\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Storage\ScopeInterface');
$this->client = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
}
private function returnDefault()
{
return new League\OAuth2\AuthServer($this->client, $this->session, $this->scope);
return new League\OAuth2\Server\Authorization($this->client, $this->session, $this->scope);
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_clientCredentialsGrant_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -38,15 +38,15 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_clientCredentialsGrant_missingClientPassword()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -56,7 +56,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 8
*/
public function test_issueAccessToken_clientCredentialsGrant_badClient()
@ -64,9 +64,9 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -77,7 +77,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_clientCredentialsGrant_missingScopes()
@ -95,7 +95,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('deleteSession')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->requireScopeParam(true);
$v = $a->issueAccessToken(array(
@ -129,7 +129,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->requireScopeParam(false);
$a->setDefaultScope('foobar');
@ -142,7 +142,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 4
*/
public function test_issueAccessToken_clientCredentialsGrant_badScope()
@ -163,7 +163,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'client_credentials',
@ -197,7 +197,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'client_credentials',
@ -224,7 +224,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->requireScopeParam(false);
$v = $a->issueAccessToken(array(
@ -259,14 +259,14 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->requireScopeParam(false);
$_POST['grant_type'] = 'client_credentials';
$_POST['client_id'] = 1234;
$_POST['client_secret'] = 5678;
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -297,7 +297,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$grant = new League\OAuth2\Grant\ClientCredentials($a);
$grant = new League\OAuth2\Server\Grant\ClientCredentials($a);
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
$a->requireScopeParam(false);
@ -306,7 +306,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$_POST['client_id'] = 1234;
$_POST['client_secret'] = 5678;
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -339,14 +339,14 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->requireScopeParam(false);
$_POST['grant_type'] = 'client_credentials';
$_POST['client_id'] = 1234;
$_POST['client_secret'] = 5678;
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();

View File

@ -10,26 +10,26 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
public function setUp()
{
$this->client = M::mock('League\OAuth2\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Storage\ScopeInterface');
$this->client = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
}
private function returnDefault()
{
return new League\OAuth2\AuthServer($this->client, $this->session, $this->scope);
return new League\OAuth2\Server\Authorization($this->client, $this->session, $this->scope);
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_passwordGrant_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\Password($a));
$a->addGrantType(new League\OAuth2\Server\Grant\Password($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -38,15 +38,15 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_passwordGrant_missingClientPassword()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\Password($a));
$a->addGrantType(new League\OAuth2\Server\Grant\Password($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -56,7 +56,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 8
*/
public function test_issueAccessToken_passwordGrant_badClient()
@ -64,9 +64,9 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\Password($a));
$a->addGrantType(new League\OAuth2\Server\Grant\Password($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -77,7 +77,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\InvalidGrantTypeException
* @expectedException League\OAuth2\Server\Exception\InvalidGrantTypeException
*/
function test_issueAccessToken_passwordGrant_invalidCallback()
{
@ -98,7 +98,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = null;
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -112,7 +112,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
function test_issueAccessToken_passwordGrant_missingUsername()
@ -134,7 +134,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return false; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -146,7 +146,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
function test_issueAccessToken_passwordGrant_missingPassword()
@ -168,7 +168,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return false; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -181,7 +181,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
function test_issueAccessToken_passwordGrant_badCredentials()
@ -203,7 +203,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return false; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -217,7 +217,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 4
*/
public function test_issueAccessToken_passwordGrant_badScopes()
@ -240,7 +240,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -255,7 +255,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_passwordGrant_missingScopes()
@ -276,7 +276,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(true);
@ -317,7 +317,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@ -360,7 +360,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -394,7 +394,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@ -436,7 +436,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@ -447,7 +447,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$_POST['username'] = 'foo';
$_POST['password'] = 'bar';
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -481,7 +481,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$pgrant->setAccessTokenTTL(30);
$a->addGrantType($pgrant);
@ -493,7 +493,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$_POST['username'] = 'foo';
$_POST['password'] = 'bar';
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -529,10 +529,10 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function($u, $p) { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->requireScopeParam(false);
$_POST['grant_type'] = 'password';
@ -541,7 +541,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$_POST['username'] = 'foo';
$_POST['password'] = 'bar';
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();

View File

@ -10,20 +10,20 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
public function setUp()
{
$this->client = M::mock('League\OAuth2\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Storage\ScopeInterface');
$this->client = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$this->session = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$this->scope = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
}
private function returnDefault()
{
return new League\OAuth2\AuthServer($this->client, $this->session, $this->scope);
return new League\OAuth2\Server\Authorization($this->client, $this->session, $this->scope);
}
public function test_setRefreshTokenTTL()
{
$a = $this->returnDefault();
$rt = new League\OAuth2\Grant\RefreshToken($a);
$rt = new League\OAuth2\Server\Grant\RefreshToken($a);
$rt->setRefreshTokenTTL(30);
$this->assertEquals(30, $rt->getRefreshTokenTTL());
}
@ -44,8 +44,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateRefreshToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$_POST['grant_type'] = 'authorization_code';
$_POST['client_id'] = 1234;
@ -53,7 +53,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$_POST['redirect_uri'] = 'http://foo/redirect';
$_POST['code'] = 'foobar';
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -69,15 +69,15 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_refreshTokenGrant_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -86,15 +86,15 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_refreshTokenGrant_missingClientSecret()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -104,7 +104,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 8
*/
public function test_issueAccessToken_refreshTokenGrant_badClient()
@ -112,9 +112,9 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -125,7 +125,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_refreshTokenGrant_missingRefreshToken()
@ -133,9 +133,9 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(array());
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -147,7 +147,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\ClientException
* @expectedException League\OAuth2\Server\Exception\ClientException
* @expectedExceptionCode 0
*/
public function test_issueAccessToken_refreshTokenGrant_badRefreshToken()
@ -156,9 +156,9 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('validateRefreshToken')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken(array(
@ -188,14 +188,14 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('getScopes')->andReturn(array());
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$_POST['grant_type'] = 'refresh_token';
$_POST['client_id'] = 1234;
$_POST['client_secret'] = 5678;
$_POST['refresh_token'] = 'abcdef';
$request = new League\OAuth2\Util\Request(array(), $_POST);
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
$v = $a->issueAccessToken();
@ -230,7 +230,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$v = $a->issueAccessToken(array(
'grant_type' => 'refresh_token',
@ -269,7 +269,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$grant = new League\OAuth2\Grant\RefreshToken($a);
$grant = new League\OAuth2\Server\Grant\RefreshToken($a);
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);

View File

@ -8,18 +8,18 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
public function setUp()
{
$this->session = M::mock('League\OAuth2\Storage\SessionInterface');
$this->session = M::mock('League\OAuth2\Server\Storage\SessionInterface');
}
private function returnDefault()
{
return new League\OAuth2\ResourceServer($this->session);
return new League\OAuth2\Server\Resource($this->session);
}
public function test_setRequest()
{
$s = $this->returnDefault();
$request = new League\OAuth2\Util\Request();
$request = new League\OAuth2\Server\Util\Request();
$s->setRequest($request);
$reflector = new ReflectionClass($s);
@ -27,17 +27,17 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
$requestProperty->setAccessible(true);
$v = $requestProperty->getValue($s);
$this->assertTrue($v instanceof League\OAuth2\Util\RequestInterface);
$this->assertTrue($v instanceof League\OAuth2\Server\Util\RequestInterface);
}
public function test_getRequest()
{
$s = $this->returnDefault();
$request = new League\OAuth2\Util\Request();
$request = new League\OAuth2\Server\Util\Request();
$s->setRequest($request);
$v = $s->getRequest();
$this->assertTrue($v instanceof League\OAuth2\Util\RequestInterface);
$this->assertTrue($v instanceof League\OAuth2\Server\Util\RequestInterface);
}
public function test_getTokenKey()
@ -66,12 +66,12 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\InvalidAccessTokenException
* @expectedException League\OAuth2\Server\Exception\InvalidAccessTokenException
*/
public function test_determineAccessToken_missingToken()
{
$_SERVER['HTTP_AUTHORIZATION'] = 'Bearer';
$request = new League\OAuth2\Util\Request(array(), array(), array(), array(), $_SERVER);
$request = new League\OAuth2\Server\Util\Request(array(), array(), array(), array(), $_SERVER);
$s = $this->returnDefault();
$s->setRequest($request);
@ -85,7 +85,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
public function test_determineAccessToken_fromHeader()
{
$request = new League\OAuth2\Util\Request();
$request = new League\OAuth2\Server\Util\Request();
$requestReflector = new ReflectionClass($request);
$param = $requestReflector->getProperty('headers');
@ -113,7 +113,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
$_GET[$s->getTokenKey()] = 'abcdef';
$_SERVER['REQUEST_METHOD'] = 'get';
$request = new League\OAuth2\Util\Request($_GET, array(), array(), array(), $_SERVER);
$request = new League\OAuth2\Server\Util\Request($_GET, array(), array(), array(), $_SERVER);
$s->setRequest($request);
$reflector = new ReflectionClass($s);
@ -126,13 +126,13 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
}
/**
* @expectedException League\OAuth2\Exception\InvalidAccessTokenException
* @expectedException League\OAuth2\Server\Exception\InvalidAccessTokenException
*/
public function test_isValid_notValid()
{
$this->session->shouldReceive('validateAccessToken')->andReturn(false);
$request = new League\OAuth2\Util\Request();
$request = new League\OAuth2\Server\Util\Request();
$requestReflector = new ReflectionClass($request);
$param = $requestReflector->getProperty('headers');
$param->setAccessible(true);
@ -159,7 +159,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
array('key' => 'bar')
));
$request = new League\OAuth2\Util\Request();
$request = new League\OAuth2\Server\Util\Request();
$requestReflector = new ReflectionClass($request);
$param = $requestReflector->getProperty('headers');
$param->setAccessible(true);

View File

@ -4,9 +4,9 @@ class RedirectUri_test extends PHPUnit_Framework_TestCase
{
function test_make()
{
$v1 = League\OAuth2\Util\RedirectUri::make('https://foobar/', array('foo'=>'bar'));
$v2 = League\OAuth2\Util\RedirectUri::make('https://foobar/', array('foo'=>'bar'), '#');
$v3 = League\OAuth2\Util\RedirectUri::make('https://foobar/', array('foo'=>'bar', 'bar' => 'foo'));
$v1 = League\OAuth2\Server\Util\RedirectUri::make('https://foobar/', array('foo'=>'bar'));
$v2 = League\OAuth2\Server\Util\RedirectUri::make('https://foobar/', array('foo'=>'bar'), '#');
$v3 = League\OAuth2\Server\Util\RedirectUri::make('https://foobar/', array('foo'=>'bar', 'bar' => 'foo'));
$this->assertEquals('https://foobar/?foo=bar', $v1);
$this->assertEquals('https://foobar/#foo=bar', $v2);

View File

@ -6,7 +6,7 @@ class Request_test extends PHPUnit_Framework_TestCase
function setUp()
{
$this->request = new League\OAuth2\Util\Request(
$this->request = new League\OAuth2\Server\Util\Request(
array('foo' => 'bar'),
array('foo' => 'bar'),
array('foo' => 'bar'),
@ -17,10 +17,10 @@ class Request_test extends PHPUnit_Framework_TestCase
function test_buildFromIndex()
{
$r = new League\OAuth2\Util\Request();
$r = new League\OAuth2\Server\Util\Request();
$r->buildFromGlobals();
$this->assertTrue($r instanceof League\OAuth2\Util\Request);
$this->assertTrue($r instanceof League\OAuth2\Server\Util\Request);
}
function test_get()

View File

@ -4,9 +4,9 @@ class Secure_Key_test extends PHPUnit_Framework_TestCase
{
function test_make()
{
$v1 = League\OAuth2\Util\SecureKey::make();
$v2 = League\OAuth2\Util\SecureKey::make();
$v3 = League\OAuth2\Util\SecureKey::make(50);
$v1 = League\OAuth2\Server\Util\SecureKey::make();
$v2 = League\OAuth2\Server\Util\SecureKey::make();
$v3 = League\OAuth2\Server\Util\SecureKey::make(50);
$this->assertEquals(40, strlen($v1));
$this->assertTrue($v1 !== $v2);