mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
CryptTrait tests
This commit is contained in:
@@ -7,7 +7,6 @@ use League\OAuth2\Server\Grant\ImplicitGrant;
|
||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
|
||||
use League\OAuth2\Server\Utils\KeyCrypt;
|
||||
use LeagueTests\Stubs\ClientEntity;
|
||||
use LeagueTests\Stubs\StubResponseType;
|
||||
use LeagueTests\Stubs\UserEntity;
|
||||
@@ -16,6 +15,16 @@ use Zend\Diactoros\ServerRequest;
|
||||
|
||||
class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* CryptTrait stub
|
||||
*/
|
||||
protected $cryptStub;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->cryptStub = new CryptTraitStub;
|
||||
}
|
||||
|
||||
public function testGetIdentifier()
|
||||
{
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
@@ -60,8 +69,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
$grant = new ImplicitGrant($userRepositoryMock);
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -99,8 +108,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
public function testRespondToAuthorizationRequestMissingClientId()
|
||||
{
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -113,9 +122,9 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
'php://input',
|
||||
[],
|
||||
[
|
||||
'oauth_authorize_request' => KeyCrypt::encrypt(
|
||||
'oauth_authorize_request' => $this->cryptStub->doEncrypt(
|
||||
json_encode(['user_id' => 123]),
|
||||
'file://' . __DIR__ . '/../Utils/private.key'
|
||||
'file://' . __DIR__ . '/../Stubs/private.key'
|
||||
),
|
||||
],
|
||||
[
|
||||
@@ -141,8 +150,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -155,9 +164,9 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
'php://input',
|
||||
[],
|
||||
[
|
||||
'oauth_authorize_request' => KeyCrypt::encrypt(
|
||||
'oauth_authorize_request' => $this->cryptStub->doEncrypt(
|
||||
json_encode(['user_id' => 123]),
|
||||
'file://' . __DIR__ . '/../Utils/private.key'
|
||||
'file://' . __DIR__ . '/../Stubs/private.key'
|
||||
),
|
||||
],
|
||||
[
|
||||
@@ -191,8 +200,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -205,9 +214,9 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
'php://input',
|
||||
[],
|
||||
[
|
||||
'oauth_authorize_request' => KeyCrypt::encrypt(
|
||||
'oauth_authorize_request' => $this->cryptStub->doEncrypt(
|
||||
json_encode(['user_id' => 123]),
|
||||
'file://' . __DIR__ . '/../Utils/private.key'
|
||||
'file://' . __DIR__ . '/../Stubs/private.key'
|
||||
),
|
||||
],
|
||||
[
|
||||
@@ -247,8 +256,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -292,8 +301,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -306,9 +315,9 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
'php://input',
|
||||
[],
|
||||
[
|
||||
'oauth_authorize_request' => KeyCrypt::encrypt(
|
||||
'oauth_authorize_request' => $this->cryptStub->doEncrypt(
|
||||
json_encode(['user_id' => null]),
|
||||
'file://' . __DIR__ . '/../Utils/private.key'
|
||||
'file://' . __DIR__ . '/../Stubs/private.key'
|
||||
),
|
||||
],
|
||||
[
|
||||
@@ -341,8 +350,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -355,9 +364,9 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
'php://input',
|
||||
[],
|
||||
[
|
||||
'oauth_authorize_request' => KeyCrypt::encrypt(
|
||||
'oauth_authorize_request' => $this->cryptStub->doEncrypt(
|
||||
json_encode(['user_id' => 123]),
|
||||
'file://' . __DIR__ . '/../Utils/private.key'
|
||||
'file://' . __DIR__ . '/../Stubs/private.key'
|
||||
),
|
||||
],
|
||||
[
|
||||
@@ -389,8 +398,8 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$grant = new ImplicitGrant($this->getMock(UserRepositoryInterface::class));
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
$grant->setPathToPublicKey('file://' . __DIR__ . '/../Utils/public.key');
|
||||
$grant->setPathToPrivateKey('file://' . __DIR__ . '/../Utils/private.key');
|
||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
|
||||
$request = new ServerRequest(
|
||||
[
|
||||
@@ -403,9 +412,9 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
||||
'php://input',
|
||||
[],
|
||||
[
|
||||
'oauth_authorize_request' => KeyCrypt::encrypt(
|
||||
'oauth_authorize_request' => $this->cryptStub->doEncrypt(
|
||||
json_encode(['user_id' => 123]),
|
||||
'file://' . __DIR__ . '/../Utils/private.key'
|
||||
'file://' . __DIR__ . '/../Stubs/private.key'
|
||||
),
|
||||
],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user