Merge branch 'feature/no-inject-server' into develop

This commit is contained in:
Alex Bilbie 2013-12-05 20:26:22 +00:00
commit 9a224bd847
13 changed files with 121 additions and 128 deletions

View File

@ -244,6 +244,10 @@ class Authorization
if (is_null($identifier)) {
$identifier = $grantType->getIdentifier();
}
// Inject server into grant
$grantType->setAuthorizationServer($this);
$this->grantTypes[$identifier] = $grantType;
if ( ! is_null($grantType->getResponseType())) {

View File

@ -56,16 +56,6 @@ class AuthCode implements GrantTypeInterface {
*/
protected $authTokenTTL = 600;
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}
/**
* Override the default access token expire time
* @param int $authTokenTTL

View File

@ -50,16 +50,6 @@ class ClientCredentials implements GrantTypeInterface {
*/
protected $accessTokenTTL = null;
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}
/**
* Return the identifier
* @return string

View File

@ -11,8 +11,26 @@
namespace League\OAuth2\Server\Grant;
use League\OAuth2\Server\Authorization;
trait GrantTrait {
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer = null)
{
// @codeCoverageIgnoreStart
if ($authServer instanceof Authorization) {
trigger_error(
'Server is now automatically injected into grant as of v3.1 of this library',
E_USER_DEPRECATED
);
} // @codeCoverageIgnoreEnd
}
/**
* Return the identifier
* @return string
@ -42,4 +60,15 @@ trait GrantTrait {
return $this;
}
/**
* Inject the authorization server into the grant
* @param Authorization $authServer The authorization server instance
* @return self
*/
public function setAuthorizationServer(Authorization $authServer)
{
$this->authServer = $authServer;
return $this;
}
}

View File

@ -23,10 +23,9 @@ interface GrantTypeInterface
{
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer);
public function __construct(Authorization $authServer = null);
/**
* Complete the grant flow

View File

@ -50,16 +50,6 @@ class Implicit implements GrantTypeInterface {
*/
protected $accessTokenTTL = null;
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}
/**
* Complete the client credentials grant
* @param null|array $inputParams

View File

@ -56,16 +56,6 @@ class Password implements GrantTypeInterface {
*/
protected $accessTokenTTL = null;
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}
/**
* Set the callback to verify a user's username and password
* @param callable $callback The callback function

View File

@ -62,16 +62,6 @@ class RefreshToken implements GrantTypeInterface {
*/
protected $rotateRefreshTokens = false;
/**
* Constructor
* @param Authorization $authServer Authorization server instance
* @return void
*/
public function __construct(Authorization $authServer)
{
$this->authServer = $authServer;
}
/**
* Set the TTL of the refresh token
* @param int $refreshTokenTTL

View File

@ -20,10 +20,19 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
return new League\OAuth2\Server\Authorization($this->client, $this->session, $this->scope);
}
public function test_setAuthTokenTTL()
/**
* @expectedException PHPUnit_Framework_Error
*/
public function test__construct()
{
$a = $this->returnDefault();
$grant = new League\OAuth2\Server\Grant\AuthCode($a);
}
public function test_setAuthTokenTTL()
{
$a = $this->returnDefault();
$grant = new League\OAuth2\Server\Grant\AuthCode();
$grant->setAuthTokenTTL(30);
$reflector = new ReflectionClass($grant);
@ -41,7 +50,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
public function test_checkAuthoriseParams_noClientId()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$g->checkAuthoriseParams();
}
@ -53,7 +62,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
public function test_checkAuthoriseParams_noRedirectUri()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234
@ -67,7 +76,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
public function test_checkAuthoriseParams_noRequiredState()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$a->requireStateParam(true);
$g->checkAuthoriseParams(array(
@ -86,7 +95,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -108,7 +117,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -130,7 +139,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -153,9 +162,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->requireScopeParam(true);
$g->checkAuthoriseParams(array(
@ -183,9 +192,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->setDefaultScope('test.scope');
$a->requireScopeParam(false);
@ -217,9 +226,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->setDefaultScope(array('test.scope', 'test.scope2'));
$a->requireScopeParam(false);
@ -250,9 +259,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$this->scope->shouldReceive('getScope')->andReturn(false);
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$g->checkAuthoriseParams(array(
'client_id' => 1234,
@ -265,9 +274,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
public function test_checkAuthoriseParams_passedInput()
{
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$this->client->shouldReceive('getClient')->andReturn(array(
'client_id' => 1234,
@ -331,9 +340,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
));
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$_GET['client_id'] = 1234;
$_GET['redirect_uri'] = 'http://foo/redirect';
@ -380,7 +389,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAuthCodeScope')->andReturn(null);
$a = $this->returnDefault();
$g = new League\OAuth2\Server\Grant\AuthCode($a);
$g = new League\OAuth2\Server\Grant\AuthCode();
$a->addGrantType($g);
$params = array(

View File

@ -69,6 +69,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault();
$grant = M::mock('League\OAuth2\Server\Grant\GrantTypeInterface');
$grant->shouldReceive('getResponseType')->andReturn('test');
$grant->shouldReceive('setAuthorizationServer')->andReturn($grant);
$a->addGrantType($grant, 'test');
$this->assertTrue($a->hasGrantType('test'));
@ -80,6 +81,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$grant = M::mock('League\OAuth2\Server\Grant\GrantTypeInterface');
$grant->shouldReceive('getIdentifier')->andReturn('test');
$grant->shouldReceive('getResponseType')->andReturn('test');
$grant->shouldReceive('setAuthorizationServer')->andReturn($grant);
$a->addGrantType($grant);
$this->assertTrue($a->hasGrantType('test'));
@ -199,7 +201,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_getGrantType()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$reflector = new ReflectionClass($a);
$method = $reflector->getMethod('getGrantType');
@ -227,7 +229,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_missingGrantType()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken();
}
@ -239,7 +241,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_badGrantType()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken(array('grant_type' => 'foo'));
}
@ -251,7 +253,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken(array(
'grant_type' => 'authorization_code'
@ -265,7 +267,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_missingClientSecret()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -280,7 +282,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_missingRedirectUri()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -298,7 +300,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -317,7 +319,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(array());
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -337,7 +339,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('validateAuthCode')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -368,7 +370,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('getAuthCodeScopes')->andReturn(array('scope_id' => 1));
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$v = $a->issueAccessToken(array(
'grant_type' => 'authorization_code',
@ -404,7 +406,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$_POST['grant_type'] = 'authorization_code';
$_POST['client_id'] = 1234;
@ -443,7 +445,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$grant = new League\OAuth2\Server\Grant\AuthCode($a);
$grant = new League\OAuth2\Server\Grant\AuthCode();
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
@ -486,7 +488,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$_POST['grant_type'] = 'authorization_code';
$_SERVER['PHP_AUTH_USER'] = 1234;

View File

@ -27,7 +27,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_clientCredentialsGrant_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -44,7 +44,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_clientCredentialsGrant_missingClientPassword()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -64,7 +64,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -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\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$a->requireScopeParam(true);
$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\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$a->requireScopeParam(false);
$a->setDefaultScope('foobar');
@ -170,7 +170,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$a->requireScopeParam(false);
$a->setDefaultScope(array('foobar', 'barfoo'));
@ -209,7 +209,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$a->issueAccessToken(array(
'grant_type' => 'client_credentials',
@ -243,7 +243,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$v = $a->issueAccessToken(array(
'grant_type' => 'client_credentials',
@ -275,7 +275,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$a->requireScopeParam(false);
$v = $a->issueAccessToken(array(
@ -310,7 +310,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$a->requireScopeParam(false);
$_POST['grant_type'] = 'client_credentials';
@ -348,7 +348,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$grant = new League\OAuth2\Server\Grant\ClientCredentials($a);
$grant = new League\OAuth2\Server\Grant\ClientCredentials();
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
$a->requireScopeParam(false);
@ -390,7 +390,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateAccessToken')->andReturn(1);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials($a));
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
$a->requireScopeParam(false);
$_POST['grant_type'] = 'client_credentials';

View File

@ -27,7 +27,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_passwordGrant_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\Password($a));
$a->addGrantType(new League\OAuth2\Server\Grant\Password());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -44,7 +44,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_passwordGrant_missingClientPassword()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\Password($a));
$a->addGrantType(new League\OAuth2\Server\Grant\Password());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -64,7 +64,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\Password($a));
$a->addGrantType(new League\OAuth2\Server\Grant\Password());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -98,7 +98,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = null;
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -134,7 +134,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return false; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -168,7 +168,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return false; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -203,7 +203,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return false; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -240,7 +240,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -276,7 +276,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(true);
@ -317,7 +317,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@ -365,7 +365,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@ -413,7 +413,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
@ -452,7 +452,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@ -494,7 +494,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->requireScopeParam(false);
@ -539,7 +539,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$pgrant->setAccessTokenTTL(30);
$a->addGrantType($pgrant);
@ -587,10 +587,10 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
$testCredentials = function() { return 1; };
$a = $this->returnDefault();
$pgrant = new League\OAuth2\Server\Grant\Password($a);
$pgrant = new League\OAuth2\Server\Grant\Password();
$pgrant->setVerifyCredentialsCallback($testCredentials);
$a->addGrantType($pgrant);
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$a->requireScopeParam(false);
$_POST['grant_type'] = 'password';

View File

@ -23,7 +23,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
public function test_setRefreshTokenTTL()
{
$a = $this->returnDefault();
$rt = new League\OAuth2\Server\Grant\RefreshToken($a);
$rt = new League\OAuth2\Server\Grant\RefreshToken();
$rt->setRefreshTokenTTL(30);
$this->assertEquals(30, $rt->getRefreshTokenTTL());
}
@ -46,8 +46,8 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('getAuthCodeScopes')->andReturn(array('scope_id' => 1));
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$_POST['grant_type'] = 'authorization_code';
$_POST['client_id'] = 1234;
@ -77,7 +77,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_refreshTokenGrant_missingClientId()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -94,7 +94,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
public function test_issueAccessToken_refreshTokenGrant_missingClientSecret()
{
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -114,7 +114,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -135,7 +135,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->client->shouldReceive('getClient')->andReturn(array());
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -157,7 +157,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('validateRefreshToken')->andReturn(false);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
$a->setRequest($request);
@ -190,7 +190,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('getScopes')->andReturn(array());
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$_POST['grant_type'] = 'refresh_token';
$_POST['client_id'] = 1234;
@ -232,7 +232,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
$v = $a->issueAccessToken(array(
'grant_type' => 'refresh_token',
@ -272,7 +272,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$a = $this->returnDefault();
$rt = new League\OAuth2\Server\Grant\RefreshToken($a);
$rt = new League\OAuth2\Server\Grant\RefreshToken();
$rt->rotateRefreshTokens(true);
$a->addGrantType($rt);
@ -314,7 +314,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->session->shouldReceive('associateScope')->andReturn(null);
$a = $this->returnDefault();
$grant = new League\OAuth2\Server\Grant\RefreshToken($a);
$grant = new League\OAuth2\Server\Grant\RefreshToken();
$grant->setAccessTokenTTL(30);
$a->addGrantType($grant);
@ -358,7 +358,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->scope->shouldReceive('getScope')->andReturn(array('id' => 1, 'scope' => 'foo'));
$a = $this->returnDefault();
$grant = new League\OAuth2\Server\Grant\RefreshToken($a);
$grant = new League\OAuth2\Server\Grant\RefreshToken();
$grant->setAccessTokenTTL(30);
$grant->rotateRefreshTokens(true);
$a->addGrantType($grant);
@ -409,7 +409,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
$this->scope->shouldReceive('getScope')->andReturn(array('id' => 1, 'scope' => 'foo'));
$a = $this->returnDefault();
$grant = new League\OAuth2\Server\Grant\RefreshToken($a);
$grant = new League\OAuth2\Server\Grant\RefreshToken();
$grant->setAccessTokenTTL(30);
$grant->rotateRefreshTokens(true);
$a->addGrantType($grant);