Updated tests for new namespace

This commit is contained in:
Alex Bilbie 2013-05-08 11:06:21 -07:00
parent 850473ce40
commit f4b955ccff
9 changed files with 185 additions and 185 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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