Updated grant tests with new grant name

This commit is contained in:
Alex Bilbie 2014-05-02 17:25:04 +01:00
parent ffc25fb276
commit 107991b0a7
4 changed files with 54 additions and 54 deletions

View File

@ -2,8 +2,8 @@
namespace LeagueTests\Grant;
use League\OAuth2\Server\Grant\AuthCode;
use League\OAuth2\Server\Grant\RefreshToken;
use League\OAuth2\Server\Grant\AuthCodeGrant;
use League\OAuth2\Server\Grant\RefreshTokenGrant;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\Entity\SessionEntity;
@ -16,7 +16,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
{
public function testSetAuthTokenTTL()
{
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$grant->setAuthTokenTTL(100);
$class = new \ReflectionClass($grant);
@ -32,7 +32,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$_POST = [];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$grant->checkAuthoriseParams();
@ -48,7 +48,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'client_id' => 'testapp'
];
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$grant->checkAuthoriseParams();
@ -64,7 +64,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->requireStateParam(true);
$server->addGrantType($grant);
@ -81,7 +81,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$grant->checkAuthoriseParams();
@ -98,7 +98,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$grant->checkAuthoriseParams();
@ -115,7 +115,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -140,7 +140,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -181,7 +181,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -234,7 +234,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$client = (new ClientEntity($server))->setId('testapp');
$scope = (new ScopeEntity($server))->setId('foo');
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -266,7 +266,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'authorization_code';
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -283,7 +283,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -300,7 +300,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -318,7 +318,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -342,7 +342,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -391,7 +391,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -440,7 +440,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -489,7 +489,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$grant = new AuthCodeGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -553,8 +553,8 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new AuthCode;
$rtgrant = new RefreshToken;
$grant = new AuthCodeGrant;
$rtgrant = new RefreshTokenGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');

View File

@ -2,14 +2,14 @@
namespace LeagueTests\Grant;
use League\OAuth2\Server\Grant\ClientCredentials;
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Grant\ClientException;
use Mockery as M;
class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
{
function testCompleteFlowMissingClientId()
{
@ -18,7 +18,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'client_credentials';
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$grant = new ClientCredentialsGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -35,7 +35,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$grant = new ClientCredentialsGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -52,7 +52,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$grant = new ClientCredentialsGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -76,7 +76,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$grant = new ClientCredentialsGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -116,7 +116,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$grant = new ClientCredentialsGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -161,7 +161,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$grant = new ClientCredentialsGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');

View File

@ -2,8 +2,8 @@
namespace LeagueTests\Grant;
use League\OAuth2\Server\Grant\Password;
use League\OAuth2\Server\Grant\RefreshToken;
use League\OAuth2\Server\Grant\PasswordGrant;
use League\OAuth2\Server\Grant\RefreshTokenGrant;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\RefreshTokenEntity;
@ -20,7 +20,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'password';
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -37,7 +37,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -54,7 +54,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -77,7 +77,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -120,7 +120,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -164,7 +164,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -209,7 +209,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -256,7 +256,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -306,7 +306,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -360,7 +360,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -419,7 +419,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new Password;
$grant = new PasswordGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -465,7 +465,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
});
$server->addGrantType($grant);
$server->addGrantType(new RefreshToken);
$server->addGrantType(new RefreshTokenGrant);
$response = $server->issueAccessToken();
$this->assertTrue(isset($response['access_token']));

View File

@ -2,7 +2,7 @@
namespace LeagueTests\Grant;
use League\OAuth2\Server\Grant\RefreshToken;
use League\OAuth2\Server\Grant\RefreshTokenGrant;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
@ -15,7 +15,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
{
function testSetRefreshTokenTTL()
{
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$grant->setRefreshTokenTTL(86400);
$property = new \ReflectionProperty($grant, 'refreshTokenTTL');
@ -31,7 +31,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'refresh_token';
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -47,7 +47,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$server->addGrantType($grant);
$server->issueAccessToken();
@ -64,7 +64,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -87,7 +87,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -122,7 +122,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -156,7 +156,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
@ -226,7 +226,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));
@ -298,7 +298,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
];
$server = new AuthorizationServer;
$grant = new RefreshToken;
$grant = new RefreshTokenGrant;
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));