mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-16 02:08:56 +05:30
Merge branch 'release/3.1'
This commit is contained in:
commit
9099173db2
@ -1,10 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 3.1 (released 2013-12-05)
|
||||||
|
|
||||||
|
* No longer necessary to inject the authorisation server into a grant, the server will inject itself
|
||||||
|
* Added test for 1419ba8cdcf18dd034c8db9f7de86a2594b68605
|
||||||
|
|
||||||
## 3.0.1 (released 2013-12-02)
|
## 3.0.1 (released 2013-12-02)
|
||||||
|
|
||||||
* Forgot to tell TravisCI from testing PHP 5.3
|
* Forgot to tell TravisCI from testing PHP 5.3
|
||||||
|
|
||||||
|
|
||||||
## 3.0 (released 2013-12-02)
|
## 3.0 (released 2013-12-02)
|
||||||
|
|
||||||
* Fixed spelling of Implicit grant class (Issue #84)
|
* Fixed spelling of Implicit grant class (Issue #84)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "league/oauth2-server",
|
"name": "league/oauth2-server",
|
||||||
"description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.",
|
"description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.",
|
||||||
"version": "3.0.1",
|
"version": "3.1",
|
||||||
"homepage": "https://github.com/php-loep/oauth2-server",
|
"homepage": "https://github.com/php-loep/oauth2-server",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -244,6 +244,10 @@ class Authorization
|
|||||||
if (is_null($identifier)) {
|
if (is_null($identifier)) {
|
||||||
$identifier = $grantType->getIdentifier();
|
$identifier = $grantType->getIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inject server into grant
|
||||||
|
$grantType->setAuthorizationServer($this);
|
||||||
|
|
||||||
$this->grantTypes[$identifier] = $grantType;
|
$this->grantTypes[$identifier] = $grantType;
|
||||||
|
|
||||||
if ( ! is_null($grantType->getResponseType())) {
|
if ( ! is_null($grantType->getResponseType())) {
|
||||||
|
@ -56,16 +56,6 @@ class AuthCode implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $authTokenTTL = 600;
|
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
|
* Override the default access token expire time
|
||||||
* @param int $authTokenTTL
|
* @param int $authTokenTTL
|
||||||
|
@ -50,16 +50,6 @@ class ClientCredentials implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $accessTokenTTL = null;
|
protected $accessTokenTTL = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(Authorization $authServer)
|
|
||||||
{
|
|
||||||
$this->authServer = $authServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the identifier
|
* Return the identifier
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -11,8 +11,26 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\Authorization;
|
||||||
|
|
||||||
trait GrantTrait {
|
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 the identifier
|
||||||
* @return string
|
* @return string
|
||||||
@ -22,6 +40,17 @@ trait GrantTrait {
|
|||||||
return $this->identifier;
|
return $this->identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the identifier
|
||||||
|
* @param string $identifier
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setIdentifier($identifier)
|
||||||
|
{
|
||||||
|
$this->identifier = $identifier;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the response type
|
* Return the response type
|
||||||
* @return string
|
* @return string
|
||||||
@ -42,4 +71,15 @@ trait GrantTrait {
|
|||||||
return $this;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -23,10 +23,9 @@ interface GrantTypeInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param Authorization $authServer Authorization server instance
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(Authorization $authServer);
|
public function __construct(Authorization $authServer = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the grant flow
|
* Complete the grant flow
|
||||||
|
@ -50,16 +50,6 @@ class Implicit implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $accessTokenTTL = null;
|
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
|
* Complete the client credentials grant
|
||||||
* @param null|array $inputParams
|
* @param null|array $inputParams
|
||||||
|
@ -56,16 +56,6 @@ class Password implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $accessTokenTTL = null;
|
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
|
* Set the callback to verify a user's username and password
|
||||||
* @param callable $callback The callback function
|
* @param callable $callback The callback function
|
||||||
|
@ -62,16 +62,6 @@ class RefreshToken implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
protected $rotateRefreshTokens = false;
|
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
|
* Set the TTL of the refresh token
|
||||||
* @param int $refreshTokenTTL
|
* @param int $refreshTokenTTL
|
||||||
|
@ -20,10 +20,26 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
return new League\OAuth2\Server\Authorization($this->client, $this->session, $this->scope);
|
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();
|
$a = $this->returnDefault();
|
||||||
$grant = new League\OAuth2\Server\Grant\AuthCode($a);
|
$grant = new League\OAuth2\Server\Grant\AuthCode($a);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_setIdentifier()
|
||||||
|
{
|
||||||
|
$grant = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
|
$grant->setIdentifier('foobar');
|
||||||
|
$this->assertEquals($grant->getIdentifier(), 'foobar');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_setAuthTokenTTL()
|
||||||
|
{
|
||||||
|
$a = $this->returnDefault();
|
||||||
|
$grant = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$grant->setAuthTokenTTL(30);
|
$grant->setAuthTokenTTL(30);
|
||||||
|
|
||||||
$reflector = new ReflectionClass($grant);
|
$reflector = new ReflectionClass($grant);
|
||||||
@ -41,7 +57,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_checkAuthoriseParams_noClientId()
|
public function test_checkAuthoriseParams_noClientId()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$g->checkAuthoriseParams();
|
$g->checkAuthoriseParams();
|
||||||
}
|
}
|
||||||
@ -53,7 +69,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_checkAuthoriseParams_noRedirectUri()
|
public function test_checkAuthoriseParams_noRedirectUri()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$g->checkAuthoriseParams(array(
|
$g->checkAuthoriseParams(array(
|
||||||
'client_id' => 1234
|
'client_id' => 1234
|
||||||
@ -67,7 +83,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_checkAuthoriseParams_noRequiredState()
|
public function test_checkAuthoriseParams_noRequiredState()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$a->requireStateParam(true);
|
$a->requireStateParam(true);
|
||||||
$g->checkAuthoriseParams(array(
|
$g->checkAuthoriseParams(array(
|
||||||
@ -86,7 +102,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 League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$g->checkAuthoriseParams(array(
|
$g->checkAuthoriseParams(array(
|
||||||
'client_id' => 1234,
|
'client_id' => 1234,
|
||||||
@ -108,7 +124,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$g->checkAuthoriseParams(array(
|
$g->checkAuthoriseParams(array(
|
||||||
'client_id' => 1234,
|
'client_id' => 1234,
|
||||||
@ -130,7 +146,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$g->checkAuthoriseParams(array(
|
$g->checkAuthoriseParams(array(
|
||||||
'client_id' => 1234,
|
'client_id' => 1234,
|
||||||
@ -153,9 +169,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
$a->requireScopeParam(true);
|
$a->requireScopeParam(true);
|
||||||
|
|
||||||
$g->checkAuthoriseParams(array(
|
$g->checkAuthoriseParams(array(
|
||||||
@ -183,9 +199,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$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->setDefaultScope('test.scope');
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
|
|
||||||
@ -217,9 +233,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$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->setDefaultScope(array('test.scope', 'test.scope2'));
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
|
|
||||||
@ -250,9 +266,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 League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$g->checkAuthoriseParams(array(
|
$g->checkAuthoriseParams(array(
|
||||||
'client_id' => 1234,
|
'client_id' => 1234,
|
||||||
@ -265,9 +281,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 League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$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(
|
$this->client->shouldReceive('getClient')->andReturn(array(
|
||||||
'client_id' => 1234,
|
'client_id' => 1234,
|
||||||
@ -331,9 +347,9 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$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['client_id'] = 1234;
|
||||||
$_GET['redirect_uri'] = 'http://foo/redirect';
|
$_GET['redirect_uri'] = 'http://foo/redirect';
|
||||||
@ -380,7 +396,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$this->session->shouldReceive('associateAuthCodeScope')->andReturn(null);
|
$this->session->shouldReceive('associateAuthCodeScope')->andReturn(null);
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
$g = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$a->addGrantType($g);
|
$a->addGrantType($g);
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
|
@ -69,6 +69,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$grant = M::mock('League\OAuth2\Server\Grant\GrantTypeInterface');
|
$grant = M::mock('League\OAuth2\Server\Grant\GrantTypeInterface');
|
||||||
$grant->shouldReceive('getResponseType')->andReturn('test');
|
$grant->shouldReceive('getResponseType')->andReturn('test');
|
||||||
|
$grant->shouldReceive('setAuthorizationServer')->andReturn($grant);
|
||||||
$a->addGrantType($grant, 'test');
|
$a->addGrantType($grant, 'test');
|
||||||
|
|
||||||
$this->assertTrue($a->hasGrantType('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 = M::mock('League\OAuth2\Server\Grant\GrantTypeInterface');
|
||||||
$grant->shouldReceive('getIdentifier')->andReturn('test');
|
$grant->shouldReceive('getIdentifier')->andReturn('test');
|
||||||
$grant->shouldReceive('getResponseType')->andReturn('test');
|
$grant->shouldReceive('getResponseType')->andReturn('test');
|
||||||
|
$grant->shouldReceive('setAuthorizationServer')->andReturn($grant);
|
||||||
$a->addGrantType($grant);
|
$a->addGrantType($grant);
|
||||||
|
|
||||||
$this->assertTrue($a->hasGrantType('test'));
|
$this->assertTrue($a->hasGrantType('test'));
|
||||||
@ -199,7 +201,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_getGrantType()
|
public function test_getGrantType()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$reflector = new ReflectionClass($a);
|
$reflector = new ReflectionClass($a);
|
||||||
$method = $reflector->getMethod('getGrantType');
|
$method = $reflector->getMethod('getGrantType');
|
||||||
@ -227,7 +229,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_missingGrantType()
|
public function test_issueAccessToken_missingGrantType()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$a->issueAccessToken();
|
$a->issueAccessToken();
|
||||||
}
|
}
|
||||||
@ -239,7 +241,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_badGrantType()
|
public function test_issueAccessToken_badGrantType()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$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'));
|
$a->issueAccessToken(array('grant_type' => 'foo'));
|
||||||
}
|
}
|
||||||
@ -251,7 +253,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_missingClientId()
|
public function test_issueAccessToken_missingClientId()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$a->issueAccessToken(array(
|
||||||
'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
@ -265,7 +267,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_missingClientSecret()
|
public function test_issueAccessToken_missingClientSecret()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$a->issueAccessToken(array(
|
||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
@ -280,7 +282,7 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_missingRedirectUri()
|
public function test_issueAccessToken_missingRedirectUri()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$a->issueAccessToken(array(
|
||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
@ -298,7 +300,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 League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$a->issueAccessToken(array(
|
||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
@ -317,7 +319,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 League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$a->issueAccessToken(array(
|
||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
@ -337,7 +339,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 League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$a->issueAccessToken(array(
|
||||||
'grant_type' => 'authorization_code',
|
'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));
|
$this->session->shouldReceive('getAuthCodeScopes')->andReturn(array('scope_id' => 1));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$v = $a->issueAccessToken(array(
|
$v = $a->issueAccessToken(array(
|
||||||
'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
@ -404,7 +406,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 League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$_POST['grant_type'] = 'authorization_code';
|
$_POST['grant_type'] = 'authorization_code';
|
||||||
$_POST['client_id'] = 1234;
|
$_POST['client_id'] = 1234;
|
||||||
@ -443,7 +445,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();
|
||||||
$grant = new League\OAuth2\Server\Grant\AuthCode($a);
|
$grant = new League\OAuth2\Server\Grant\AuthCode();
|
||||||
$grant->setAccessTokenTTL(30);
|
$grant->setAccessTokenTTL(30);
|
||||||
$a->addGrantType($grant);
|
$a->addGrantType($grant);
|
||||||
|
|
||||||
@ -486,7 +488,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 League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
|
|
||||||
$_POST['grant_type'] = 'authorization_code';
|
$_POST['grant_type'] = 'authorization_code';
|
||||||
$_SERVER['PHP_AUTH_USER'] = 1234;
|
$_SERVER['PHP_AUTH_USER'] = 1234;
|
||||||
|
@ -27,7 +27,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_clientCredentialsGrant_missingClientId()
|
public function test_issueAccessToken_clientCredentialsGrant_missingClientId()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$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);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -44,7 +44,7 @@ class Client_Credentials_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_clientCredentialsGrant_missingClientPassword()
|
public function test_issueAccessToken_clientCredentialsGrant_missingClientPassword()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$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);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -64,7 +64,7 @@ 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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
|
|
||||||
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
$a->requireScopeParam(true);
|
$a->requireScopeParam(true);
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
$a->setDefaultScope('foobar');
|
$a->setDefaultScope('foobar');
|
||||||
|
|
||||||
@ -170,7 +170,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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
$a->setDefaultScope(array('foobar', 'barfoo'));
|
$a->setDefaultScope(array('foobar', 'barfoo'));
|
||||||
|
|
||||||
@ -209,7 +209,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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
|
|
||||||
$a->issueAccessToken(array(
|
$a->issueAccessToken(array(
|
||||||
'grant_type' => 'client_credentials',
|
'grant_type' => 'client_credentials',
|
||||||
@ -243,7 +243,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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
|
|
||||||
$v = $a->issueAccessToken(array(
|
$v = $a->issueAccessToken(array(
|
||||||
'grant_type' => 'client_credentials',
|
'grant_type' => 'client_credentials',
|
||||||
@ -275,7 +275,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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
|
|
||||||
$v = $a->issueAccessToken(array(
|
$v = $a->issueAccessToken(array(
|
||||||
@ -310,7 +310,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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
|
|
||||||
$_POST['grant_type'] = 'client_credentials';
|
$_POST['grant_type'] = 'client_credentials';
|
||||||
@ -348,7 +348,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 League\OAuth2\Server\Grant\ClientCredentials($a);
|
$grant = new League\OAuth2\Server\Grant\ClientCredentials();
|
||||||
$grant->setAccessTokenTTL(30);
|
$grant->setAccessTokenTTL(30);
|
||||||
$a->addGrantType($grant);
|
$a->addGrantType($grant);
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
@ -390,7 +390,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 League\OAuth2\Server\Grant\ClientCredentials($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\ClientCredentials());
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
|
|
||||||
$_POST['grant_type'] = 'client_credentials';
|
$_POST['grant_type'] = 'client_credentials';
|
||||||
|
@ -27,7 +27,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_passwordGrant_missingClientId()
|
public function test_issueAccessToken_passwordGrant_missingClientId()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$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);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -44,7 +44,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_passwordGrant_missingClientPassword()
|
public function test_issueAccessToken_passwordGrant_missingClientPassword()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$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);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -64,7 +64,7 @@ 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 League\OAuth2\Server\Grant\Password($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\Password());
|
||||||
|
|
||||||
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -98,7 +98,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = null;
|
$testCredentials = null;
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return false; };
|
$testCredentials = function() { return false; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return false; };
|
$testCredentials = function() { return false; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return false; };
|
$testCredentials = function() { return false; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$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() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
@ -365,7 +365,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
@ -413,7 +413,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
|
|
||||||
@ -452,7 +452,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
@ -494,7 +494,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
@ -539,7 +539,7 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$pgrant->setAccessTokenTTL(30);
|
$pgrant->setAccessTokenTTL(30);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
@ -587,10 +587,10 @@ class Password_Grant_Test extends PHPUnit_Framework_TestCase
|
|||||||
$testCredentials = function() { return 1; };
|
$testCredentials = function() { return 1; };
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$pgrant = new League\OAuth2\Server\Grant\Password($a);
|
$pgrant = new League\OAuth2\Server\Grant\Password();
|
||||||
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
$pgrant->setVerifyCredentialsCallback($testCredentials);
|
||||||
$a->addGrantType($pgrant);
|
$a->addGrantType($pgrant);
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
|
||||||
$a->requireScopeParam(false);
|
$a->requireScopeParam(false);
|
||||||
|
|
||||||
$_POST['grant_type'] = 'password';
|
$_POST['grant_type'] = 'password';
|
||||||
|
@ -23,7 +23,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_setRefreshTokenTTL()
|
public function test_setRefreshTokenTTL()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$rt = new League\OAuth2\Server\Grant\RefreshToken($a);
|
$rt = new League\OAuth2\Server\Grant\RefreshToken();
|
||||||
$rt->setRefreshTokenTTL(30);
|
$rt->setRefreshTokenTTL(30);
|
||||||
$this->assertEquals(30, $rt->getRefreshTokenTTL());
|
$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));
|
$this->session->shouldReceive('getAuthCodeScopes')->andReturn(array('scope_id' => 1));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode());
|
||||||
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
|
||||||
|
|
||||||
$_POST['grant_type'] = 'authorization_code';
|
$_POST['grant_type'] = 'authorization_code';
|
||||||
$_POST['client_id'] = 1234;
|
$_POST['client_id'] = 1234;
|
||||||
@ -77,7 +77,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_refreshTokenGrant_missingClientId()
|
public function test_issueAccessToken_refreshTokenGrant_missingClientId()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$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);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -94,7 +94,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
|||||||
public function test_issueAccessToken_refreshTokenGrant_missingClientSecret()
|
public function test_issueAccessToken_refreshTokenGrant_missingClientSecret()
|
||||||
{
|
{
|
||||||
$a = $this->returnDefault();
|
$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);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -114,7 +114,7 @@ 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 League\OAuth2\Server\Grant\RefreshToken($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
|
||||||
|
|
||||||
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -135,7 +135,7 @@ 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 League\OAuth2\Server\Grant\RefreshToken($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
|
||||||
|
|
||||||
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -157,7 +157,7 @@ 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 League\OAuth2\Server\Grant\RefreshToken($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
|
||||||
|
|
||||||
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
$request = new League\OAuth2\Server\Util\Request(array(), $_POST);
|
||||||
$a->setRequest($request);
|
$a->setRequest($request);
|
||||||
@ -190,7 +190,7 @@ 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 League\OAuth2\Server\Grant\RefreshToken($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
|
||||||
|
|
||||||
$_POST['grant_type'] = 'refresh_token';
|
$_POST['grant_type'] = 'refresh_token';
|
||||||
$_POST['client_id'] = 1234;
|
$_POST['client_id'] = 1234;
|
||||||
@ -232,7 +232,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 League\OAuth2\Server\Grant\RefreshToken($a));
|
$a->addGrantType(new League\OAuth2\Server\Grant\RefreshToken());
|
||||||
|
|
||||||
$v = $a->issueAccessToken(array(
|
$v = $a->issueAccessToken(array(
|
||||||
'grant_type' => 'refresh_token',
|
'grant_type' => 'refresh_token',
|
||||||
@ -272,7 +272,7 @@ class Refresh_Token_test extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
|
|
||||||
$rt = new League\OAuth2\Server\Grant\RefreshToken($a);
|
$rt = new League\OAuth2\Server\Grant\RefreshToken();
|
||||||
$rt->rotateRefreshTokens(true);
|
$rt->rotateRefreshTokens(true);
|
||||||
$a->addGrantType($rt);
|
$a->addGrantType($rt);
|
||||||
|
|
||||||
@ -314,7 +314,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 League\OAuth2\Server\Grant\RefreshToken($a);
|
$grant = new League\OAuth2\Server\Grant\RefreshToken();
|
||||||
$grant->setAccessTokenTTL(30);
|
$grant->setAccessTokenTTL(30);
|
||||||
$a->addGrantType($grant);
|
$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'));
|
$this->scope->shouldReceive('getScope')->andReturn(array('id' => 1, 'scope' => 'foo'));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$grant = new League\OAuth2\Server\Grant\RefreshToken($a);
|
$grant = new League\OAuth2\Server\Grant\RefreshToken();
|
||||||
$grant->setAccessTokenTTL(30);
|
$grant->setAccessTokenTTL(30);
|
||||||
$grant->rotateRefreshTokens(true);
|
$grant->rotateRefreshTokens(true);
|
||||||
$a->addGrantType($grant);
|
$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'));
|
$this->scope->shouldReceive('getScope')->andReturn(array('id' => 1, 'scope' => 'foo'));
|
||||||
|
|
||||||
$a = $this->returnDefault();
|
$a = $this->returnDefault();
|
||||||
$grant = new League\OAuth2\Server\Grant\RefreshToken($a);
|
$grant = new League\OAuth2\Server\Grant\RefreshToken();
|
||||||
$grant->setAccessTokenTTL(30);
|
$grant->setAccessTokenTTL(30);
|
||||||
$grant->rotateRefreshTokens(true);
|
$grant->rotateRefreshTokens(true);
|
||||||
$a->addGrantType($grant);
|
$a->addGrantType($grant);
|
||||||
|
Loading…
Reference in New Issue
Block a user