mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-03 10:41:51 +05:30
Updated tests
This commit is contained in:
parent
48dea185d8
commit
c6bc1b0cfc
@ -16,12 +16,12 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
$time = time();
|
$time = time();
|
||||||
|
|
||||||
$entity = new StubAbstractTokenEntity($server);
|
$entity = new StubAbstractTokenEntity($server);
|
||||||
$entity->setToken('foobar');
|
$entity->setId('foobar');
|
||||||
$entity->setExpireTime($time);
|
$entity->setExpireTime($time);
|
||||||
$entity->setSession((new SessionEntity($server)));
|
$entity->setSession((new SessionEntity($server)));
|
||||||
$entity->associateScope((new ScopeEntity($server))->setId('foo'));
|
$entity->associateScope((new ScopeEntity($server))->hydrate(['id' => 'foo']));
|
||||||
|
|
||||||
$this->assertEquals('foobar', $entity->getToken());
|
$this->assertEquals('foobar', $entity->getId());
|
||||||
$this->assertEquals($time, $entity->getExpireTime());
|
$this->assertEquals($time, $entity->getExpireTime());
|
||||||
// $this->assertTrue($entity->getSession() instanceof SessionEntity);
|
// $this->assertTrue($entity->getSession() instanceof SessionEntity);
|
||||||
// $this->assertTrue($entity->hasScope('foo'));
|
// $this->assertTrue($entity->hasScope('foo'));
|
||||||
@ -92,8 +92,8 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$scopes = [
|
$scopes = [
|
||||||
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
|
(new ScopeEntity($server))->hydrate(['id' => 'scope1', 'description' => 'foo']),
|
||||||
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
|
(new ScopeEntity($server))->hydrate(['id' => 'scope2', 'description' => 'bar'])
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $method->invokeArgs($entity, [$scopes]);
|
$result = $method->invokeArgs($entity, [$scopes]);
|
||||||
@ -110,7 +110,7 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$entity = new StubAbstractTokenEntity($server);
|
$entity = new StubAbstractTokenEntity($server);
|
||||||
$this->assertEquals('', (string) $entity);
|
$this->assertEquals('', (string) $entity);
|
||||||
$entity->setToken('foobar');
|
$entity->setId('foobar');
|
||||||
$this->assertEquals('foobar', (string) $entity);
|
$this->assertEquals('foobar', (string) $entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
|
@ -18,7 +18,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$code = new AuthCodeEntity($server);
|
$code = new AuthCodeEntity($server);
|
||||||
$code->setRedirectUri('http://foo/bar');
|
$code->setRedirectUri('http://foo/bar');
|
||||||
$code->setToken('foobar');
|
$code->setId('foobar');
|
||||||
$code->setSession($session);
|
$code->setSession($session);
|
||||||
|
|
||||||
$this->assertEquals('http://foo/bar', $code->getRedirectUri());
|
$this->assertEquals('http://foo/bar', $code->getRedirectUri());
|
||||||
@ -37,7 +37,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authCodeStorage->shouldReceive('associateScope');
|
$authCodeStorage->shouldReceive('associateScope');
|
||||||
$authCodeStorage->shouldReceive('setServer');
|
$authCodeStorage->shouldReceive('setServer');
|
||||||
$authCodeStorage->shouldReceive('getScopes')->andReturn([
|
$authCodeStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$server->shouldReceive('getStorage')->with('auth_code')->andReturn($authCodeStorage);
|
$server->shouldReceive('getStorage')->with('auth_code')->andReturn($authCodeStorage);
|
||||||
|
@ -10,11 +10,12 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testSetGet()
|
public function testSetGet()
|
||||||
{
|
{
|
||||||
$server = M::mock('League\OAuth2\Server\AbstractServer');
|
$server = M::mock('League\OAuth2\Server\AbstractServer');
|
||||||
$client = new ClientEntity($server);
|
$client = (new ClientEntity($server))->hydrate([
|
||||||
$client->setId('foobar');
|
'id' => 'foobar',
|
||||||
$client->setSecret('barfoo');
|
'secret' => 'barfoo',
|
||||||
$client->setName('Test Client');
|
'name' => 'Test Client',
|
||||||
$client->setRedirectUri('http://foo/bar');
|
'redirectUri' => 'http://foo/bar'
|
||||||
|
]);
|
||||||
|
|
||||||
$this->assertEquals('foobar', $client->getId());
|
$this->assertEquals('foobar', $client->getId());
|
||||||
$this->assertEquals('barfoo', $client->getSecret());
|
$this->assertEquals('barfoo', $client->getSecret());
|
||||||
|
@ -39,10 +39,10 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
|
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
|
||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('getByRefreshToken')->andReturn(
|
$accessTokenStorage->shouldReceive('getByRefreshToken')->andReturn(
|
||||||
(new AccessTokenEntity($server))->setToken('foobar')
|
(new AccessTokenEntity($server))->setId('foobar')
|
||||||
);
|
);
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$server->shouldReceive('getStorage')->with('access_token')->andReturn($accessTokenStorage);
|
$server->shouldReceive('getStorage')->with('access_token')->andReturn($accessTokenStorage);
|
||||||
|
@ -10,9 +10,10 @@ class ScopeTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testSetGet()
|
public function testSetGet()
|
||||||
{
|
{
|
||||||
$server = M::mock('League\OAuth2\Server\AbstractServer');
|
$server = M::mock('League\OAuth2\Server\AbstractServer');
|
||||||
$scope = new ScopeEntity($server);
|
$scope = (new ScopeEntity($server))->hydrate([
|
||||||
$scope->setId('foobar');
|
'id' => 'foobar',
|
||||||
$scope->setDescription('barfoo');
|
'description' => 'barfoo'
|
||||||
|
]);
|
||||||
|
|
||||||
$this->assertEquals('foobar', $scope->getId());
|
$this->assertEquals('foobar', $scope->getId());
|
||||||
$this->assertEquals('barfoo', $scope->getDescription());
|
$this->assertEquals('barfoo', $scope->getDescription());
|
||||||
|
@ -14,14 +14,22 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
public function testSetGet()
|
public function testSetGet()
|
||||||
{
|
{
|
||||||
|
$emitter = M::mock('League\Event\Emitter');
|
||||||
|
$emitter->shouldReceive('emit');
|
||||||
$server = M::mock('League\OAuth2\Server\AbstractServer');
|
$server = M::mock('League\OAuth2\Server\AbstractServer');
|
||||||
|
$server->shouldReceive('setEventEmitter');
|
||||||
|
$server->shouldReceive('getEventEmitter')->andReturn($emitter);
|
||||||
|
$server->setEventEmitter($emitter);
|
||||||
|
|
||||||
$entity = new SessionEntity($server);
|
$entity = new SessionEntity($server);
|
||||||
$entity->setId('foobar');
|
$entity->setId('foobar');
|
||||||
$entity->setOwner('user', 123);
|
$entity->setOwner('user', 123);
|
||||||
$entity->associateAccessToken((new AccessTokenEntity($server)));
|
$entity->associateAccessToken((new AccessTokenEntity($server)));
|
||||||
$entity->associateRefreshToken((new RefreshTokenEntity($server)));
|
$entity->associateRefreshToken((new RefreshTokenEntity($server)));
|
||||||
$entity->associateClient((new ClientEntity($server)));
|
$entity->associateClient((new ClientEntity($server)));
|
||||||
$entity->associateScope((new ScopeEntity($server))->setId('foo'));
|
$entity->associateScope(
|
||||||
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
|
);
|
||||||
// $entity->associateAuthCode((new AuthCode($server)));
|
// $entity->associateAuthCode((new AuthCode($server)));
|
||||||
|
|
||||||
$this->assertEquals('foobar', $entity->getId());
|
$this->assertEquals('foobar', $entity->getId());
|
||||||
@ -51,8 +59,8 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$scopes = [
|
$scopes = [
|
||||||
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
|
(new ScopeEntity($server))->hydrate(['id' => 'scope1']),
|
||||||
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
|
(new ScopeEntity($server))->hydrate(['id' => 'scope2'])
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $method->invokeArgs($entity, [$scopes]);
|
$result = $method->invokeArgs($entity, [$scopes]);
|
||||||
@ -124,14 +132,14 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
|||||||
$sessionStorage->shouldReceive('associateScope');
|
$sessionStorage->shouldReceive('associateScope');
|
||||||
$sessionStorage->shouldReceive('setServer');
|
$sessionStorage->shouldReceive('setServer');
|
||||||
$sessionStorage->shouldReceive('getScopes')->andReturn([
|
$sessionStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$server->shouldReceive('getStorage')->with('session')->andReturn($sessionStorage);
|
$server->shouldReceive('getStorage')->with('session')->andReturn($sessionStorage);
|
||||||
|
|
||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('getBySession')->andReturn(
|
$clientStorage->shouldReceive('getBySession')->andReturn(
|
||||||
(new ClientEntity($server))->setId('foo')
|
(new ClientEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$scopes = [
|
$scopes = [
|
||||||
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
|
(new ScopeEntity($server))->hydrate(['id' => 'scope1', 'description' => 'foo']),
|
||||||
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
|
(new ScopeEntity($server))->hydrate(['id' => 'scope2', 'description' => 'bar'])
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $method->invokeArgs($grant, [$scopes]);
|
$result = $method->invokeArgs($grant, [$scopes]);
|
||||||
@ -55,7 +55,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setScopeStorage($scopeStorage);
|
$server->setScopeStorage($scopeStorage);
|
||||||
@ -65,9 +65,8 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
[
|
[
|
||||||
'foo' => (new ScopeEntity($server))->setId('foo')
|
'foo' => (new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
],
|
],
|
||||||
|
|
||||||
$grant->validateScopes('foo')
|
$grant->validateScopes('foo')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -113,7 +112,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
$server->setScopeStorage($scopeStorage);
|
$server->setScopeStorage($scopeStorage);
|
||||||
|
|
||||||
@ -134,7 +133,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
$server->setScopeStorage($scopeStorage);
|
$server->setScopeStorage($scopeStorage);
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -185,14 +185,14 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
$sessionStorage->shouldReceive('setServer');
|
$sessionStorage->shouldReceive('setServer');
|
||||||
$sessionStorage->shouldReceive('create')->andreturn(123);
|
$sessionStorage->shouldReceive('create')->andreturn(123);
|
||||||
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$sessionStorage->shouldReceive('associateScope');
|
$sessionStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -200,14 +200,14 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -229,9 +229,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testNewAuthoriseRequest()
|
public function testNewAuthoriseRequest()
|
||||||
{
|
{
|
||||||
$server = new AuthorizationServer;
|
$server = new AuthorizationServer;
|
||||||
|
$client = (new ClientEntity($server))->hydrate(['id' => 'testapp']);
|
||||||
$client = (new ClientEntity($server))->setId('testapp');
|
$scope = (new ScopeEntity($server))->hydrate(['id' => 'foo']);
|
||||||
$scope = (new ScopeEntity($server))->setId('foo');
|
|
||||||
|
|
||||||
$grant = new AuthCodeGrant;
|
$grant = new AuthCodeGrant;
|
||||||
$server->addGrantType($grant);
|
$server->addGrantType($grant);
|
||||||
@ -346,7 +345,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -395,7 +394,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -444,7 +443,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -464,7 +463,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
|
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
|
||||||
$authCodeStorage->shouldReceive('setServer');
|
$authCodeStorage->shouldReceive('setServer');
|
||||||
$authCodeStorage->shouldReceive('get')->andReturn(
|
$authCodeStorage->shouldReceive('get')->andReturn(
|
||||||
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://fail/face')
|
(new AuthCodeEntity($server))->setId('foobar')->setRedirectUri('http://fail/face')
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -493,10 +492,10 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('getBySession')->andReturn(
|
$clientStorage->shouldReceive('getBySession')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -506,29 +505,32 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
|
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
|
||||||
(new SessionEntity($server))->setId('foobar')
|
(new SessionEntity($server))->setId('foobar')
|
||||||
);
|
);
|
||||||
|
$sessionStorage->shouldReceive('getScopes')->andReturn([
|
||||||
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
|
]);
|
||||||
|
|
||||||
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
|
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
|
||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
|
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
|
||||||
$authCodeStorage->shouldReceive('setServer');
|
$authCodeStorage->shouldReceive('setServer');
|
||||||
$authCodeStorage->shouldReceive('delete');
|
$authCodeStorage->shouldReceive('delete');
|
||||||
$authCodeStorage->shouldReceive('get')->andReturn(
|
$authCodeStorage->shouldReceive('get')->andReturn(
|
||||||
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
|
(new AuthCodeEntity($server))->setId('foobar')->setRedirectUri('http://foo/bar')
|
||||||
);
|
);
|
||||||
$authCodeStorage->shouldReceive('getScopes')->andReturn([
|
$authCodeStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -558,10 +560,10 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('getBySession')->andReturn(
|
$clientStorage->shouldReceive('getBySession')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -571,29 +573,32 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
|
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
|
||||||
(new SessionEntity($server))->setId('foobar')
|
(new SessionEntity($server))->setId('foobar')
|
||||||
);
|
);
|
||||||
|
$sessionStorage->shouldReceive('getScopes')->andReturn([
|
||||||
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
|
]);
|
||||||
|
|
||||||
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
|
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
|
||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
|
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
|
||||||
$authCodeStorage->shouldReceive('setServer');
|
$authCodeStorage->shouldReceive('setServer');
|
||||||
$authCodeStorage->shouldReceive('delete');
|
$authCodeStorage->shouldReceive('delete');
|
||||||
$authCodeStorage->shouldReceive('get')->andReturn(
|
$authCodeStorage->shouldReceive('get')->andReturn(
|
||||||
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
|
(new AuthCodeEntity($server))->setId('foobar')->setRedirectUri('http://foo/bar')
|
||||||
);
|
);
|
||||||
$authCodeStorage->shouldReceive('getScopes')->andReturn([
|
$authCodeStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
|
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
|
||||||
|
@ -80,7 +80,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -120,7 +120,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -138,7 +138,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
// $scopeStorage->shouldReceive('get')->andReturn(
|
// $scopeStorage->shouldReceive('get')->andReturn(
|
||||||
// // (new ScopeEntity($server))->setId('foo')
|
// // (new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
// );
|
// );
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -165,14 +165,14 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
$sessionStorage->shouldReceive('setServer');
|
$sessionStorage->shouldReceive('setServer');
|
||||||
$sessionStorage->shouldReceive('create')->andreturn(123);
|
$sessionStorage->shouldReceive('create')->andreturn(123);
|
||||||
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$sessionStorage->shouldReceive('associateScope');
|
$sessionStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -180,14 +180,14 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -228,7 +228,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
|
@ -80,7 +80,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -123,7 +123,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -167,7 +167,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -212,7 +212,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -259,7 +259,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -309,14 +309,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
$sessionStorage->shouldReceive('setServer');
|
$sessionStorage->shouldReceive('setServer');
|
||||||
$sessionStorage->shouldReceive('create')->andreturn(123);
|
$sessionStorage->shouldReceive('create')->andreturn(123);
|
||||||
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$sessionStorage->shouldReceive('associateScope');
|
$sessionStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -324,14 +324,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -363,14 +363,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
$sessionStorage->shouldReceive('setServer');
|
$sessionStorage->shouldReceive('setServer');
|
||||||
$sessionStorage->shouldReceive('create')->andreturn(123);
|
$sessionStorage->shouldReceive('create')->andreturn(123);
|
||||||
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$sessionStorage->shouldReceive('associateScope');
|
$sessionStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -378,14 +378,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -422,14 +422,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
$sessionStorage->shouldReceive('setServer');
|
$sessionStorage->shouldReceive('setServer');
|
||||||
$sessionStorage->shouldReceive('create')->andreturn(123);
|
$sessionStorage->shouldReceive('create')->andreturn(123);
|
||||||
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$sessionStorage->shouldReceive('associateScope');
|
$sessionStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -437,14 +437,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('setServer');
|
$accessTokenStorage->shouldReceive('setServer');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
|
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
|
||||||
|
@ -92,7 +92,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -127,7 +127,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
|
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
|
||||||
@ -161,7 +161,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -180,7 +180,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('delete');
|
$accessTokenStorage->shouldReceive('delete');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -228,12 +228,12 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$server = new AuthorizationServer;
|
$server = new AuthorizationServer;
|
||||||
$grant = new RefreshTokenGrant;
|
$grant = new RefreshTokenGrant;
|
||||||
|
|
||||||
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));
|
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->hydrate(['id' => 'foo']));
|
||||||
|
|
||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -252,7 +252,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('delete');
|
$accessTokenStorage->shouldReceive('delete');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
@ -300,12 +300,12 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$server = new AuthorizationServer;
|
$server = new AuthorizationServer;
|
||||||
$grant = new RefreshTokenGrant;
|
$grant = new RefreshTokenGrant;
|
||||||
|
|
||||||
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));
|
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->hydrate(['id' => 'foo']));
|
||||||
|
|
||||||
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
|
||||||
$clientStorage->shouldReceive('setServer');
|
$clientStorage->shouldReceive('setServer');
|
||||||
$clientStorage->shouldReceive('get')->andReturn(
|
$clientStorage->shouldReceive('get')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
|
||||||
@ -324,7 +324,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenStorage->shouldReceive('delete');
|
$accessTokenStorage->shouldReceive('delete');
|
||||||
$accessTokenStorage->shouldReceive('create');
|
$accessTokenStorage->shouldReceive('create');
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo')
|
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
|
||||||
]);
|
]);
|
||||||
$accessTokenStorage->shouldReceive('associateScope');
|
$accessTokenStorage->shouldReceive('associateScope');
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
|
||||||
$scopeStorage->shouldReceive('setServer');
|
$scopeStorage->shouldReceive('setServer');
|
||||||
$scopeStorage->shouldReceive('get')->andReturn(
|
$scopeStorage->shouldReceive('get')->andReturn(
|
||||||
(new ScopeEntity($server))->setId('blah')
|
(new ScopeEntity($server))->hydrate(['id' => 'blah'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setClientStorage($clientStorage);
|
$server->setClientStorage($clientStorage);
|
||||||
|
@ -135,23 +135,23 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$scopeStorage
|
$scopeStorage
|
||||||
);
|
);
|
||||||
|
|
||||||
$server->setTokenKey('at');
|
$server->setIdKey('at');
|
||||||
|
|
||||||
$accessTokenStorage->shouldReceive('get')->andReturn(
|
$accessTokenStorage->shouldReceive('get')->andReturn(
|
||||||
(new AccessTokenEntity($server))->setToken('abcdef')
|
(new AccessTokenEntity($server))->setId('abcdef')
|
||||||
);
|
);
|
||||||
|
|
||||||
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
// $accessTokenStorage->shouldReceive('getScopes')->andReturn([
|
||||||
(new ScopeEntity($server))->setId('foo'),
|
// (new ScopeEntity($server))->hydrate(['id' => 'foo']),
|
||||||
(new ScopeEntity($server))->setId('bar')
|
// (new ScopeEntity($server))->hydrate(['id' => 'bar'])
|
||||||
]);
|
// ]);
|
||||||
|
|
||||||
$sessionStorage->shouldReceive('getByAccessToken')->andReturn(
|
$sessionStorage->shouldReceive('getByAccessToken')->andReturn(
|
||||||
(new SessionEntity($server))->setId('foobar')->setOwner('user', 123)
|
(new SessionEntity($server))->setId('foobar')->setOwner('user', 123)
|
||||||
);
|
);
|
||||||
|
|
||||||
$clientStorage->shouldReceive('getBySession')->andReturn(
|
$clientStorage->shouldReceive('getBySession')->andReturn(
|
||||||
(new ClientEntity($server))->setId('testapp')
|
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$request = new \Symfony\Component\HttpFoundation\Request();
|
$request = new \Symfony\Component\HttpFoundation\Request();
|
||||||
@ -161,7 +161,7 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$server->setRequest($request);
|
$server->setRequest($request);
|
||||||
|
|
||||||
$this->assertTrue($server->isValidRequest());
|
$this->assertTrue($server->isValidRequest());
|
||||||
$this->assertEquals('at', $server->getTokenKey());
|
$this->assertEquals('at', $server->getIdKey());
|
||||||
$this->assertEquals(123, $server->getOwnerId());
|
$this->assertEquals(123, $server->getOwnerId());
|
||||||
$this->assertEquals('user', $server->getOwnerType());
|
$this->assertEquals('user', $server->getOwnerType());
|
||||||
$this->assertEquals('abcdef', $server->getAccessToken());
|
$this->assertEquals('abcdef', $server->getAccessToken());
|
||||||
|
Loading…
Reference in New Issue
Block a user