mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
Fix broken tests
This commit is contained in:
parent
55ff59edf4
commit
a18b8c57b2
@ -123,8 +123,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
|||||||
$usernameParameter,
|
$usernameParameter,
|
||||||
$passwordParameter,
|
$passwordParameter,
|
||||||
$this->getIdentifier(),
|
$this->getIdentifier(),
|
||||||
$client,
|
$client
|
||||||
$scopes
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($userEntity instanceof UserEntityInterface) {
|
if ($userEntity instanceof UserEntityInterface) {
|
||||||
|
@ -30,7 +30,7 @@ interface ScopeRepositoryInterface extends RepositoryInterface
|
|||||||
public function getScopeEntityByIdentifier($identifier, $grantType, $clientId = null);
|
public function getScopeEntityByIdentifier($identifier, $grantType, $clientId = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a client and user validate the set of scopes requested are valid and optionally
|
* Given a client (and optional user identifier) validate the set of scopes requested are valid and optionally
|
||||||
* append additional scopes or remove requested scopes.
|
* append additional scopes or remove requested scopes.
|
||||||
*
|
*
|
||||||
* @param ScopeEntityInterface[] $scopes
|
* @param ScopeEntityInterface[] $scopes
|
||||||
|
@ -87,6 +87,9 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$grant = new AuthCodeGrant(
|
$grant = new AuthCodeGrant(
|
||||||
$this->getMock(AuthCodeRepositoryInterface::class),
|
$this->getMock(AuthCodeRepositoryInterface::class),
|
||||||
$this->getMock(RefreshTokenRepositoryInterface::class),
|
$this->getMock(RefreshTokenRepositoryInterface::class),
|
||||||
@ -95,6 +98,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||||
|
|
||||||
@ -410,6 +414,9 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$grant = new AuthCodeGrant(
|
$grant = new AuthCodeGrant(
|
||||||
$this->getMock(AuthCodeRepositoryInterface::class),
|
$this->getMock(AuthCodeRepositoryInterface::class),
|
||||||
$this->getMock(RefreshTokenRepositoryInterface::class),
|
$this->getMock(RefreshTokenRepositoryInterface::class),
|
||||||
@ -418,6 +425,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
|||||||
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||||
|
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||||
use LeagueTests\Stubs\ClientEntity;
|
use LeagueTests\Stubs\ClientEntity;
|
||||||
use LeagueTests\Stubs\StubResponseType;
|
use LeagueTests\Stubs\StubResponseType;
|
||||||
use Zend\Diactoros\ServerRequest;
|
use Zend\Diactoros\ServerRequest;
|
||||||
@ -28,9 +29,13 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$grant = new ClientCredentialsGrant();
|
$grant = new ClientCredentialsGrant();
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
|
|
||||||
$serverRequest = new ServerRequest();
|
$serverRequest = new ServerRequest();
|
||||||
$serverRequest = $serverRequest->withParsedBody(
|
$serverRequest = $serverRequest->withParsedBody(
|
||||||
|
@ -6,6 +6,7 @@ use League\OAuth2\Server\Exception\OAuthServerException;
|
|||||||
use League\OAuth2\Server\Grant\ImplicitGrant;
|
use League\OAuth2\Server\Grant\ImplicitGrant;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||||
|
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
|
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
|
||||||
use League\OAuth2\Server\ResponseTypes\HtmlResponse;
|
use League\OAuth2\Server\ResponseTypes\HtmlResponse;
|
||||||
use LeagueTests\Stubs\ClientEntity;
|
use LeagueTests\Stubs\ClientEntity;
|
||||||
@ -72,9 +73,13 @@ class ImplicitGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
$accessTokenRepositoryMock->method('persistNewAccessToken')->willReturnSelf();
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$grant = new ImplicitGrant($userRepositoryMock);
|
$grant = new ImplicitGrant($userRepositoryMock);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
$grant->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||||
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
$grant->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use League\OAuth2\Server\Grant\PasswordGrant;
|
|||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
|
||||||
|
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
|
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
|
||||||
use LeagueTests\Stubs\ClientEntity;
|
use LeagueTests\Stubs\ClientEntity;
|
||||||
use LeagueTests\Stubs\StubResponseType;
|
use LeagueTests\Stubs\StubResponseType;
|
||||||
@ -42,9 +43,13 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
|
|||||||
$refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
|
$refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
|
||||||
$refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf();
|
$refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf();
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$grant = new PasswordGrant($userRepositoryMock, $refreshTokenRepositoryMock);
|
$grant = new PasswordGrant($userRepositoryMock, $refreshTokenRepositoryMock);
|
||||||
$grant->setClientRepository($clientRepositoryMock);
|
$grant->setClientRepository($clientRepositoryMock);
|
||||||
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
|
||||||
|
$grant->setScopeRepository($scopeRepositoryMock);
|
||||||
|
|
||||||
$serverRequest = new ServerRequest();
|
$serverRequest = new ServerRequest();
|
||||||
$serverRequest = $serverRequest->withParsedBody(
|
$serverRequest = $serverRequest->withParsedBody(
|
||||||
|
@ -20,10 +20,13 @@ class AuthenticationServerMiddlewareTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository = $this->getMock(ClientRepositoryInterface::class);
|
$clientRepository = $this->getMock(ClientRepositoryInterface::class);
|
||||||
$clientRepository->method('getClientEntity')->willReturn(new ClientEntity());
|
$clientRepository->method('getClientEntity')->willReturn(new ClientEntity());
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$server = new Server(
|
$server = new Server(
|
||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$scopeRepositoryMock,
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
|
@ -48,10 +48,13 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository = $this->getMock(ClientRepositoryInterface::class);
|
$clientRepository = $this->getMock(ClientRepositoryInterface::class);
|
||||||
$clientRepository->method('getClientEntity')->willReturn(new ClientEntity());
|
$clientRepository->method('getClientEntity')->willReturn(new ClientEntity());
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$server = new Server(
|
$server = new Server(
|
||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$scopeRepositoryMock,
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
@ -75,10 +78,13 @@ class ServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$clientRepository = $this->getMock(ClientRepositoryInterface::class);
|
$clientRepository = $this->getMock(ClientRepositoryInterface::class);
|
||||||
$clientRepository->method('getClientEntity')->willReturn($client);
|
$clientRepository->method('getClientEntity')->willReturn($client);
|
||||||
|
|
||||||
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
||||||
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
||||||
|
|
||||||
$server = new Server(
|
$server = new Server(
|
||||||
$clientRepository,
|
$clientRepository,
|
||||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||||
$this->getMock(ScopeRepositoryInterface::class),
|
$scopeRepositoryMock,
|
||||||
'file://' . __DIR__ . '/Stubs/private.key',
|
'file://' . __DIR__ . '/Stubs/private.key',
|
||||||
'file://' . __DIR__ . '/Stubs/public.key',
|
'file://' . __DIR__ . '/Stubs/public.key',
|
||||||
new StubResponseType()
|
new StubResponseType()
|
||||||
|
Loading…
Reference in New Issue
Block a user