mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-09 23:12:10 +05:30
Update PHPUnit, run static analysis on tests
This commit is contained in:
parent
97089ad49e
commit
1f87c7a7be
@ -16,7 +16,7 @@ install:
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit
|
||||
- vendor/bin/phpstan analyse -l 6 src
|
||||
- vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
@ -13,9 +13,10 @@
|
||||
"defuse/php-encryption": "^2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.38 || ^5.7.21",
|
||||
"phpunit/phpunit": "^6.3 || ^7.0",
|
||||
"zendframework/zend-diactoros": "^1.0",
|
||||
"phpstan/phpstan": "^0.9.2"
|
||||
"phpstan/phpstan": "^0.9.2",
|
||||
"phpstan/phpstan-phpunit": "^0.9.4"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
9
phpstan.neon
Normal file
9
phpstan.neon
Normal file
@ -0,0 +1,9 @@
|
||||
includes:
|
||||
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||
- vendor/phpstan/phpstan-phpunit/rules.neon
|
||||
- vendor/phpstan/phpstan-phpunit/strictRules.neon
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
- '#Class Zend\\Diactoros\\ServerRequest constructor invoked with \d+ parameters, 0-6 required#'
|
||||
- '#Parameter \#2 \$key of method Lcobucci\\JWT\\Builder::sign\(\) expects string, Lcobucci\\JWT\\Signer\\Key given#'
|
||||
reportUnmatchedIgnoredErrors: false
|
@ -236,10 +236,13 @@ class OAuthServerException extends \Exception
|
||||
$this->redirectUri .= (strstr($this->redirectUri, '?') === false) ? '?' : '&';
|
||||
}
|
||||
|
||||
return $response->withStatus(302)->withHeader('Location', $this->redirectUri . http_build_query($payload));
|
||||
/** @var ResponseInterface $response */
|
||||
$response = $response->withStatus(302)->withHeader('Location', $this->redirectUri . http_build_query($payload));
|
||||
return $response;
|
||||
}
|
||||
|
||||
foreach ($headers as $header => $content) {
|
||||
/** @var ResponseInterface $response */
|
||||
$response = $response->withHeader($header, $content);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@ class RedirectResponse extends AbstractResponseType
|
||||
*/
|
||||
public function generateHttpResponse(ResponseInterface $response)
|
||||
{
|
||||
return $response->withStatus(302)->withHeader('Location', $this->redirectUri);
|
||||
/** @var ResponseInterface $response */
|
||||
$response = $response->withStatus(302)->withHeader('Location', $this->redirectUri);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
@ -198,16 +198,16 @@ class AuthorizationServerTest extends TestCase
|
||||
$clientRepositoryMock->method('getClientEntity')->willReturn($client);
|
||||
|
||||
$grant = new AuthCodeGrant(
|
||||
$this->getMock(AuthCodeRepositoryInterface::class),
|
||||
$this->getMock(RefreshTokenRepositoryInterface::class),
|
||||
$this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
|
||||
$this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
|
||||
new \DateInterval('PT10M')
|
||||
);
|
||||
$grant->setClientRepository($clientRepositoryMock);
|
||||
|
||||
$server = new AuthorizationServer(
|
||||
$clientRepositoryMock,
|
||||
$this->getMock(AccessTokenRepositoryInterface::class),
|
||||
$this->getMock(ScopeRepositoryInterface::class),
|
||||
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
||||
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
||||
'file://' . __DIR__ . '/Stubs/private.key',
|
||||
'file://' . __DIR__ . '/Stubs/public.key'
|
||||
);
|
||||
|
@ -20,9 +20,7 @@ class BearerResponseTypeTest extends TestCase
|
||||
{
|
||||
public function testGenerateHttpResponse()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||
$responseType->setEncryptionKey(base64_encode(random_bytes(36)));
|
||||
|
||||
@ -64,9 +62,7 @@ class BearerResponseTypeTest extends TestCase
|
||||
|
||||
public function testGenerateHttpResponseWithExtraParams()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
|
||||
$responseType = new BearerTokenResponseWithParams($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponseWithParams();
|
||||
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||
$responseType->setEncryptionKey(base64_encode(random_bytes(36)));
|
||||
|
||||
@ -111,10 +107,7 @@ class BearerResponseTypeTest extends TestCase
|
||||
|
||||
public function testDetermineAccessTokenInHeaderValidToken()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||
$responseType->setEncryptionKey(base64_encode(random_bytes(36)));
|
||||
|
||||
@ -158,9 +151,8 @@ class BearerResponseTypeTest extends TestCase
|
||||
public function testDetermineAccessTokenInHeaderInvalidJWT()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||
$responseType->setEncryptionKey(base64_encode(random_bytes(36)));
|
||||
|
||||
@ -247,9 +239,7 @@ class BearerResponseTypeTest extends TestCase
|
||||
|
||||
public function testDetermineAccessTokenInHeaderInvalidToken()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||
$responseType->setEncryptionKey(base64_encode(random_bytes(36)));
|
||||
|
||||
@ -273,9 +263,7 @@ class BearerResponseTypeTest extends TestCase
|
||||
|
||||
public function testDetermineMissingBearerInHeader()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||
$responseType->setEncryptionKey(base64_encode(random_bytes(36)));
|
||||
|
||||
|
@ -17,7 +17,7 @@ class CryptKeyTest extends TestCase
|
||||
|
||||
public function testKeyCreation()
|
||||
{
|
||||
$keyFile = __DIR__ . '/Stubs/public.key';
|
||||
$keyFile = __DIR__ . '/../Stubs/public.key';
|
||||
$key = new CryptKey($keyFile, 'secret');
|
||||
|
||||
$this->assertEquals('file://' . $keyFile, $key->getKeyPath());
|
||||
@ -26,7 +26,7 @@ class CryptKeyTest extends TestCase
|
||||
|
||||
public function testKeyFileCreation()
|
||||
{
|
||||
$keyContent = file_get_contents(__DIR__ . '/Stubs/public.key');
|
||||
$keyContent = file_get_contents(__DIR__ . '/../Stubs/public.key');
|
||||
$key = new CryptKey($keyContent);
|
||||
|
||||
$this->assertEquals(
|
||||
@ -34,7 +34,7 @@ class CryptKeyTest extends TestCase
|
||||
$key->getKeyPath()
|
||||
);
|
||||
|
||||
$keyContent = file_get_contents(__DIR__ . '/Stubs/private.key.crlf');
|
||||
$keyContent = file_get_contents(__DIR__ . '/../Stubs/private.key.crlf');
|
||||
$key = new CryptKey($keyContent);
|
||||
|
||||
$this->assertEquals(
|
Loading…
Reference in New Issue
Block a user