From 7ee89bdf45329c4f1012e771a4ee708ab84f4e45 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Mon, 18 Apr 2022 14:44:59 +0100 Subject: [PATCH 01/17] Fixed PSR 12 issues in RequestTest class. --- tests/Parser/RequestTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Parser/RequestTest.php b/tests/Parser/RequestTest.php index 04df038..f478b8e 100644 --- a/tests/Parser/RequestTest.php +++ b/tests/Parser/RequestTest.php @@ -36,7 +36,7 @@ public function testParse() $parse = m::mock(Parse::class); $parse->shouldReceive('addParser') ->times(4); - + $parse->shouldReceive('findToken') ->once() ->andReturn('abcdef.123.abcdef'); @@ -62,7 +62,7 @@ public function testParseNoToken() $parse = m::mock(Parse::class); $parse->shouldReceive('addParser') ->times(4); - + $parse->shouldReceive('findToken') ->once() ->andReturn(''); From f0928ea6c8a3219e84dc1f2e2cc967ca898452dc Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Mon, 18 Apr 2022 14:56:23 +0100 Subject: [PATCH 02/17] Upgraded Composer configuration to PHP 7.4 and upgrade dependent packages to match. --- composer.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index e8ecf19..e45b946 100644 --- a/composer.json +++ b/composer.json @@ -11,22 +11,22 @@ } ], "require": { - "php": ">=7.2.0", - "rbdwllr/reallysimplejwt": "^3.0", + "php": ">=7.4.0", + "rbdwllr/reallysimplejwt": "^4.0", "psr/http-message": "^1.0", "psr/http-server-middleware": "^1.0", - "nyholm/psr7": "^1.2" + "nyholm/psr7": "^1.5" }, "require-dev": { - "phpunit/phpunit": "^8.0", - "phpstan/phpstan": "^0.11", - "phpstan/phpstan-mockery": "^0.11", - "phpmd/phpmd": "^2.7", - "squizlabs/php_codesniffer": "^3.0", - "mockery/mockery": "^1.3", - "infection/infection": "^0.14", - "phploc/phploc": "^5.0", - "sebastian/phpcpd": "^4.0" + "phpunit/phpunit": "^9.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-mockery": "^1.0", + "phpmd/phpmd": "^2.12", + "squizlabs/php_codesniffer": "^3.6", + "mockery/mockery": "^1.5", + "infection/infection": "^0.20", + "phploc/phploc": "^7.0", + "sebastian/phpcpd": "^6.0" }, "autoload": { "psr-4": { From 6c41f257cf7c2100eba3b6dd7bec534028d59666 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Mon, 18 Apr 2022 15:04:14 +0100 Subject: [PATCH 03/17] Fixed PHPStan missing return type issues in tests. --- tests/Auth/AuthTest.php | 6 +++--- tests/Auth/AuthoriseTest.php | 30 ++++++++++++++--------------- tests/Factory/JwtMiddlewareTest.php | 6 +++--- tests/Factory/JwtTest.php | 4 ++-- tests/Handler/HtmlTest.php | 10 +++++----- tests/Handler/JsonTest.php | 6 +++--- tests/Helper/RequestTest.php | 8 ++++---- tests/JwtAuthMiddlewareTest.php | 10 +++++----- tests/Parser/BearerTest.php | 6 +++--- tests/Parser/BodyTest.php | 14 +++++++------- tests/Parser/CookieTest.php | 4 ++-- tests/Parser/ParseExceptionTest.php | 2 +- tests/Parser/ParseTest.php | 8 ++++---- tests/Parser/QueryTest.php | 4 ++-- tests/Parser/RequestTest.php | 6 +++--- tests/Validation/ValidateTest.php | 14 +++++++------- 16 files changed, 69 insertions(+), 69 deletions(-) diff --git a/tests/Auth/AuthTest.php b/tests/Auth/AuthTest.php index e6fa1c3..39b0bf0 100644 --- a/tests/Auth/AuthTest.php +++ b/tests/Auth/AuthTest.php @@ -10,7 +10,7 @@ class AuthTest extends TestCase /** * @covers PsrJwt\Auth\Auth::__construct */ - public function testAuth() + public function testAuth(): Auth { $auth = new Auth(200, 'Ok'); $this->assertInstanceOf(Auth::class, $auth); @@ -21,7 +21,7 @@ public function testAuth() * @depends testAuth * @covers PsrJwt\Auth\Auth::getCode */ - public function testGetCode($auth) + public function testGetCode(Auth $auth): void { $this->assertSame(200, $auth->getCode()); } @@ -30,7 +30,7 @@ public function testGetCode($auth) * @depends testAuth * @covers PsrJwt\Auth\Auth::getMessage */ - public function testGetMessage($auth) + public function testGetMessage(Auth $auth): void { $this->assertSame('Ok', $auth->getMessage()); } diff --git a/tests/Auth/AuthoriseTest.php b/tests/Auth/AuthoriseTest.php index e8ce02e..240076f 100644 --- a/tests/Auth/AuthoriseTest.php +++ b/tests/Auth/AuthoriseTest.php @@ -15,7 +15,7 @@ class AuthoriseTest extends TestCase /** * @covers PsrJwt\Auth\Authorise::__construct */ - public function testAuthorise() + public function testAuthorise(): void { $auth = new Authorise('secret', 'jwt'); $this->assertInstanceOf(Authorise::class, $auth); @@ -34,7 +34,7 @@ public function testAuthorise() * @uses PsrJwt\Parser\Cookie * @uses PsrJwt\Parser\Request */ - public function testAuthoriseOk() + public function testAuthoriseOk(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -81,7 +81,7 @@ public function testAuthoriseOk() * @uses PsrJwt\Parser\Request * @uses PsrJwt\Parser\ParseException */ - public function testAuthoriseBadRequest() + public function testAuthoriseBadRequest(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -116,7 +116,7 @@ public function testAuthoriseBadRequest() * @uses PsrJwt\Factory\Jwt * @uses PsrJwt\Validation\Validate */ - public function testValidate() + public function testValidate(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -142,7 +142,7 @@ public function testValidate() * @uses PsrJwt\Factory\Jwt * @uses PsrJwt\Validation\Validate */ - public function testValidateBadSecret() + public function testValidateBadSecret(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -168,7 +168,7 @@ public function testValidateBadSecret() * @uses PsrJwt\Factory\Jwt * @uses PsrJwt\Validation\Validate */ - public function testValidateBadExpiration() + public function testValidateBadExpiration(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -195,7 +195,7 @@ public function testValidateBadExpiration() * @uses PsrJwt\Factory\Jwt * @uses PsrJwt\Validation\Validate */ - public function testValidateBadNotBefore() + public function testValidateBadNotBefore(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -220,7 +220,7 @@ public function testValidateBadNotBefore() * @uses PsrJwt\Auth\Authorise::__construct * @uses PsrJwt\Auth\Auth */ - public function testValidationResponse() + public function testValidationResponse(): void { $auth = new Authorise('secret', 'jwt'); @@ -238,7 +238,7 @@ public function testValidationResponse() * @uses PsrJwt\Auth\Authorise::__construct * @uses PsrJwt\Auth\Auth */ - public function testValidationResponseErrors() + public function testValidationResponseErrors(): void { $auth = new Authorise('secret', 'jwt'); @@ -272,7 +272,7 @@ public function testValidationResponseErrors() * @uses PsrJwt\Parser\Body * @uses PsrJwt\Parser\Request */ - public function testGetToken() + public function testGetToken(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') @@ -299,7 +299,7 @@ public function testGetToken() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testGetTokenCookie() + public function testGetTokenCookie(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') @@ -329,7 +329,7 @@ public function testGetTokenCookie() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testGetTokenBody() + public function testGetTokenBody(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') @@ -362,7 +362,7 @@ public function testGetTokenBody() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testGetTokenBodyObject() + public function testGetTokenBodyObject(): void { $token = new \stdClass(); $token->my_token = 'ghi.123.xyz'; @@ -398,7 +398,7 @@ public function testGetTokenBodyObject() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testGetTokenQuery() + public function testGetTokenQuery(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') @@ -437,7 +437,7 @@ public function testGetTokenQuery() * @uses PsrJwt\Parser\Request * @uses PsrJwt\Parser\ParseException */ - public function testGetTokenNoToken() + public function testGetTokenNoToken(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') diff --git a/tests/Factory/JwtMiddlewareTest.php b/tests/Factory/JwtMiddlewareTest.php index 2d188f1..0627187 100644 --- a/tests/Factory/JwtMiddlewareTest.php +++ b/tests/Factory/JwtMiddlewareTest.php @@ -20,7 +20,7 @@ class JwtMiddlewareTest extends TestCase * @uses PsrJwt\Auth\Authorise * @uses PsrJwt\Handler\Html */ - public function testJwtMiddlewareHtml() + public function testJwtMiddlewareHtml(): void { $this->assertInstanceOf( JwtAuthMiddleware::class, @@ -44,7 +44,7 @@ public function testJwtMiddlewareHtml() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testFactoryValidation() + public function testFactoryValidation(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -90,7 +90,7 @@ public function testFactoryValidation() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testJsonFactoryValidation() + public function testJsonFactoryValidation(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); diff --git a/tests/Factory/JwtTest.php b/tests/Factory/JwtTest.php index 18e98ba..ad411e9 100644 --- a/tests/Factory/JwtTest.php +++ b/tests/Factory/JwtTest.php @@ -12,7 +12,7 @@ class JwtTest extends TestCase /** * @covers PsrJwt\Factory\Jwt::builder */ - public function testJwtBuilder() + public function testJwtBuilder(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -23,7 +23,7 @@ public function testJwtBuilder() /** * @covers PsrJwt\Factory\Jwt::parser */ - public function testJwtParser() + public function testJwtParser(): void { $jwt = new Jwt(); $jwt = $jwt->parser('aaa.bbb.ccc', 'secret'); diff --git a/tests/Handler/HtmlTest.php b/tests/Handler/HtmlTest.php index 67488de..befb1ab 100644 --- a/tests/Handler/HtmlTest.php +++ b/tests/Handler/HtmlTest.php @@ -17,7 +17,7 @@ class HtmlTest extends TestCase * @covers PsrJwt\Handler\Html::__construct * @uses PsrJwt\Auth\Authorise */ - public function testAuthHandler() + public function testAuthHandler(): void { $auth = new Html('secret', 'tokenKey', 'body'); @@ -40,7 +40,7 @@ public function testAuthHandler() * @uses PsrJwt\Parser\Parse * @uses PsrJwt\Parser\Request */ - public function testAuthoriseOk() + public function testAuthoriseOk(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -89,7 +89,7 @@ public function testAuthoriseOk() * @uses PsrJwt\Parser\Parse * @uses PsrJwt\Parser\Request */ - public function testAuthoriseNoBody() + public function testAuthoriseNoBody(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -138,7 +138,7 @@ public function testAuthoriseNoBody() * @uses PsrJwt\Parser\Request * @uses PsrJwt\Parser\ParseException */ - public function testAuthoriseBadRequest() + public function testAuthoriseBadRequest(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -186,7 +186,7 @@ public function testAuthoriseBadRequest() * @uses PsrJwt\Parser\Parse * @uses PsrJwt\Parser\Request */ - public function testAuthoriseUnauthorized() + public function testAuthoriseUnauthorized(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); diff --git a/tests/Handler/JsonTest.php b/tests/Handler/JsonTest.php index f067a50..af25ac0 100644 --- a/tests/Handler/JsonTest.php +++ b/tests/Handler/JsonTest.php @@ -17,7 +17,7 @@ class JsonTest extends TestCase * @covers PsrJwt\Handler\Json::__construct * @uses PsrJwt\Auth\Authorise */ - public function testJsonAuthHandler() + public function testJsonAuthHandler(): void { $auth = new Json('secret', 'tokenKey', ['body']); @@ -41,7 +41,7 @@ public function testJsonAuthHandler() * @uses PsrJwt\Parser\Bearer * @uses PsrJwt\Parser\Request */ - public function testAuthoriseOk() + public function testAuthoriseOk(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -90,7 +90,7 @@ public function testAuthoriseOk() * @uses PsrJwt\Parser\Parse * @uses PsrJwt\Parser\Request */ - public function testAuthoriseFail() + public function testAuthoriseFail(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); diff --git a/tests/Helper/RequestTest.php b/tests/Helper/RequestTest.php index 066ef88..36188d0 100644 --- a/tests/Helper/RequestTest.php +++ b/tests/Helper/RequestTest.php @@ -19,7 +19,7 @@ class RequestTest extends TestCase /** * @covers PsrJwt\Helper\Request */ - public function testRequest() + public function testRequest(): void { $request = new Request(); @@ -36,7 +36,7 @@ public function testRequest() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testGetParsedToken() + public function testGetParsedToken(): void { $httpRequest = m::mock(ServerRequestInterface::class); $httpRequest->shouldReceive('getHeader') @@ -62,7 +62,7 @@ public function testGetParsedToken() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testGetTokenHeader() + public function testGetTokenHeader(): void { $httpRequest = m::mock(ServerRequestInterface::class); $httpRequest->shouldReceive('getHeader') @@ -88,7 +88,7 @@ public function testGetTokenHeader() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testGetTokenPayload() + public function testGetTokenPayload(): void { $httpRequest = m::mock(ServerRequestInterface::class); $httpRequest->shouldReceive('getHeader') diff --git a/tests/JwtAuthMiddlewareTest.php b/tests/JwtAuthMiddlewareTest.php index 3402800..db14630 100644 --- a/tests/JwtAuthMiddlewareTest.php +++ b/tests/JwtAuthMiddlewareTest.php @@ -21,7 +21,7 @@ class JwtAuthMiddlewareTest extends TestCase * @uses PsrJwt\Auth\Authorise * @uses PsrJwt\Handler\Html */ - public function testJwtAuthProcess() + public function testJwtAuthProcess(): void { $authorise = new Html('secret', 'jwt', ''); @@ -46,7 +46,7 @@ public function testJwtAuthProcess() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\Request */ - public function testProcess() + public function testProcess(): void { $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -97,7 +97,7 @@ public function testProcess() * @uses PsrJwt\Parser\Request * @uses PsrJwt\Parser\ParseException */ - public function testProcessFail() + public function testProcessFail(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getCookieParams') @@ -143,7 +143,7 @@ public function testProcessFail() * @uses PsrJwt\Parser\Request * @uses PsrJwt\Handler\Html */ - public function testInvoke() + public function testInvoke(): void { $jwt = new Jwt(); $jwt = $jwt->builder(); @@ -197,7 +197,7 @@ public function testInvoke() * @uses PsrJwt\Handler\Html * @uses PsrJwt\Parser\Request */ - public function testInvokeFail() + public function testInvokeFail(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getCookieParams') diff --git a/tests/Parser/BearerTest.php b/tests/Parser/BearerTest.php index b541c55..fe74837 100644 --- a/tests/Parser/BearerTest.php +++ b/tests/Parser/BearerTest.php @@ -13,7 +13,7 @@ class BearerTest extends TestCase /** * @covers PsrJwt\Parser\Bearer */ - public function testBearer() + public function testBearer(): void { $bearer = new Bearer(); @@ -24,7 +24,7 @@ public function testBearer() /** * @covers PsrJwt\Parser\Bearer::parse */ - public function testParse() + public function testParse(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') @@ -41,7 +41,7 @@ public function testParse() /** * @covers PsrJwt\Parser\Bearer::parse */ - public function testParseInvalid() + public function testParseInvalid(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') diff --git a/tests/Parser/BodyTest.php b/tests/Parser/BodyTest.php index a13e9bf..b771606 100644 --- a/tests/Parser/BodyTest.php +++ b/tests/Parser/BodyTest.php @@ -14,7 +14,7 @@ class BodyTest extends TestCase /** * @covers PsrJwt\Parser\Body::__construct */ - public function testBody() + public function testBody(): void { $body = new Body('jwt'); @@ -26,7 +26,7 @@ public function testBody() * @covers PsrJwt\Parser\Body::parse * @uses PsrJwt\Parser\Body::__construct */ - public function testParse() + public function testParse(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getParsedBody') @@ -43,7 +43,7 @@ public function testParse() * @covers PsrJwt\Parser\Body::parse * @uses PsrJwt\Parser\Body */ - public function testParseObject() + public function testParseObject(): void { $object = new \stdClass(); $object->jwt = 'abc.def.ghi'; @@ -63,7 +63,7 @@ public function testParseObject() * @covers PsrJwt\Parser\Body::parse * @uses PsrJwt\Parser\Body */ - public function testParseString() + public function testParseString(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getParsedBody') @@ -80,7 +80,7 @@ public function testParseString() * @covers PsrJwt\Parser\Body::parseBodyObject * @uses PsrJwt\Parser\Body::__construct */ - public function testParseBodyObject() + public function testParseBodyObject(): void { $object = new \stdClass(); $object->jwt = 'abc.def.ghi'; @@ -103,7 +103,7 @@ public function testParseBodyObject() * @covers PsrJwt\Parser\Body::parseBodyObject * @uses PsrJwt\Parser\Body::__construct */ - public function testParseBodyObjectNoKey() + public function testParseBodyObjectNoKey(): void { $object = new \stdClass(); @@ -125,7 +125,7 @@ public function testParseBodyObjectNoKey() * @covers PsrJwt\Parser\Body::parseBodyObject * @uses PsrJwt\Parser\Body::__construct */ - public function testParseBodyObjectNoObject() + public function testParseBodyObjectNoObject(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getParsedBody') diff --git a/tests/Parser/CookieTest.php b/tests/Parser/CookieTest.php index ac2c107..d53988f 100644 --- a/tests/Parser/CookieTest.php +++ b/tests/Parser/CookieTest.php @@ -13,7 +13,7 @@ class CookieTest extends TestCase /** * @covers PsrJwt\Parser\Cookie::__construct */ - public function testCookie() + public function testCookie(): void { $cookie = new Cookie('jwt'); @@ -25,7 +25,7 @@ public function testCookie() * @covers PsrJwt\Parser\Cookie::parse * @uses PsrJwt\Parser\Cookie::__construct */ - public function testParse() + public function testParse(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getCookieParams') diff --git a/tests/Parser/ParseExceptionTest.php b/tests/Parser/ParseExceptionTest.php index d286822..c61e8ea 100644 --- a/tests/Parser/ParseExceptionTest.php +++ b/tests/Parser/ParseExceptionTest.php @@ -11,7 +11,7 @@ class ParseExceptionTest extends TestCase /** * @covers PsrJwt\Parser\ParseException */ - public function testParseException() + public function testParseException(): void { $exception = new ParseException('Error', 1, null); diff --git a/tests/Parser/ParseTest.php b/tests/Parser/ParseTest.php index 25b93fd..86743fe 100644 --- a/tests/Parser/ParseTest.php +++ b/tests/Parser/ParseTest.php @@ -18,7 +18,7 @@ class ParseTest extends TestCase /** * @covers PsrJwt\Parser\Parse */ - public function testParse() + public function testParse(): void { $parse = new Parse(); $this->assertInstanceOf(Parse::class, $parse); @@ -30,7 +30,7 @@ public function testParse() * @uses PsrJwt\Parser\Parse * @uses PsrJwt\Parser\Bearer */ - public function testFindToken() + public function testFindToken(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') @@ -54,7 +54,7 @@ public function testFindToken() * @uses PsrJwt\Parser\Body * @uses PsrJwt\Parser\Query */ - public function testFindTokenMultiParser() + public function testFindTokenMultiParser(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getHeader') @@ -79,7 +79,7 @@ public function testFindTokenMultiParser() * @covers PsrJwt\Parser\Parse::findToken * @uses PsrJwt\Parser\Parse */ - public function testFindTokenFail() + public function testFindTokenFail(): void { $request = m::mock(ServerRequestInterface::class); diff --git a/tests/Parser/QueryTest.php b/tests/Parser/QueryTest.php index 07ce9cb..ad6d5dc 100644 --- a/tests/Parser/QueryTest.php +++ b/tests/Parser/QueryTest.php @@ -13,7 +13,7 @@ class QueryTest extends TestCase /** * @covers PsrJwt\Parser\Query::__construct */ - public function testQuery() + public function testQuery(): void { $query = new Query('jwt'); @@ -25,7 +25,7 @@ public function testQuery() * @covers PsrJwt\Parser\Query::parse * @uses PsrJwt\Parser\Query::__construct */ - public function testParse() + public function testParse(): void { $request = m::mock(ServerRequestInterface::class); $request->shouldReceive('getQueryParams') diff --git a/tests/Parser/RequestTest.php b/tests/Parser/RequestTest.php index f478b8e..c168dcf 100644 --- a/tests/Parser/RequestTest.php +++ b/tests/Parser/RequestTest.php @@ -14,7 +14,7 @@ class RequestTest extends TestCase * @covers PsrJwt\Parser\Request * @uses PsrJwt\Parser\Parse */ - public function testRequest() + public function testRequest(): void { $parse = new Parse(); @@ -31,7 +31,7 @@ public function testRequest() * @uses PsrJwt\Parser\Body * @uses PsrJwt\Parser\Query */ - public function testParse() + public function testParse(): void { $parse = m::mock(Parse::class); $parse->shouldReceive('addParser') @@ -57,7 +57,7 @@ public function testParse() * @uses PsrJwt\Parser\Query * @uses PsrJwt\Parser\ParseException */ - public function testParseNoToken() + public function testParseNoToken(): void { $parse = m::mock(Parse::class); $parse->shouldReceive('addParser') diff --git a/tests/Validation/ValidateTest.php b/tests/Validation/ValidateTest.php index c484531..6651beb 100644 --- a/tests/Validation/ValidateTest.php +++ b/tests/Validation/ValidateTest.php @@ -13,7 +13,7 @@ class ValidateTest extends TestCase * @covers PsrJwt\Validation\Validate::__construct * @uses PsrJwt\Factory\Jwt */ - public function testValidate() + public function testValidate(): void { $jwt = new Jwt(); $builder = $jwt->builder(); @@ -35,7 +35,7 @@ public function testValidate() * @uses PsrJwt\Validation\Validate * @uses PsrJwt\Factory\Jwt */ - public function testValidateOk() + public function testValidateOk(): void { $jwt = new Jwt(); $builder = $jwt->builder(); @@ -60,7 +60,7 @@ public function testValidateOk() * @uses PsrJwt\Validation\Validate * @uses PsrJwt\Factory\Jwt */ - public function testValidateExpiration() + public function testValidateExpiration(): void { $jwt = new Jwt(); $builder = $jwt->builder(); @@ -85,7 +85,7 @@ public function testValidateExpiration() * @uses PsrJwt\Validation\Validate * @uses PsrJwt\Factory\Jwt::parser */ - public function testValidateTokenStructure() + public function testValidateTokenStructure(): void { $jwt = new Jwt(); @@ -104,7 +104,7 @@ public function testValidateTokenStructure() * @uses PsrJwt\Validation\Validate * @uses PsrJwt\Factory\Jwt::parser */ - public function testValidateBadSignature() + public function testValidateBadSignature(): void { $jwt = new Jwt(); @@ -123,7 +123,7 @@ public function testValidateBadSignature() * @uses PsrJwt\Validation\Validate * @uses PsrJwt\Factory\Jwt */ - public function testValidateNotBefore() + public function testValidateNotBefore(): void { $jwt = new Jwt(); $builder = $jwt->builder(); @@ -150,7 +150,7 @@ public function testValidateNotBefore() * @uses PsrJwt\Validation\Validate * @uses PsrJwt\Factory\Jwt */ - public function testValidateNotBeforeOk() + public function testValidateNotBeforeOk(): void { $jwt = new Jwt(); $builder = $jwt->builder(); From 47a1e49c8320931b9c3b89213f191bc22182bfdc Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Mon, 18 Apr 2022 15:14:45 +0100 Subject: [PATCH 04/17] Updated Jwt factory to work with ReallySimpleJWT Tokensclass available in v4.0. --- src/Factory/Jwt.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/Factory/Jwt.php b/src/Factory/Jwt.php index 2668132..15b7a58 100644 --- a/src/Factory/Jwt.php +++ b/src/Factory/Jwt.php @@ -4,12 +4,9 @@ namespace PsrJwt\Factory; +use ReallySimpleJWT\Tokens; use ReallySimpleJWT\Build; -use ReallySimpleJWT\Validate; -use ReallySimpleJWT\Encode; use ReallySimpleJWT\Parse; -use ReallySimpleJWT\Secret; -use ReallySimpleJWT\Jwt as RSJwt; /** * PSR-JWT wraps around the ReallySimpleJWT library to provide token @@ -26,12 +23,9 @@ class Jwt */ public function builder(): Build { - return new Build( - 'JWT', - new Validate(), - new Secret(), - new Encode() - ); + $tokens = new Tokens(); + + return $tokens->builder(); } /** @@ -41,12 +35,8 @@ public function builder(): Build */ public function parser(string $token, string $secret): Parse { - $jwt = new RSJwt($token, $secret); + $tokens = new Tokens(); - return new Parse( - $jwt, - new Validate(), - new Encode() - ); + return $tokens->parser($token, $secret); } } From dc5fff6283efd9fb49714f3ca2865267e343461e Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Mon, 18 Apr 2022 15:20:47 +0100 Subject: [PATCH 05/17] Fixed PHPStan type issues in source code. --- src/Factory/JwtMiddleware.php | 2 +- src/Handler/Json.php | 4 ++-- src/Helper/Request.php | 4 ++++ src/Parser/Parse.php | 2 +- src/Validation/Validate.php | 7 ++++--- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Factory/JwtMiddleware.php b/src/Factory/JwtMiddleware.php index 6ad6189..369165b 100644 --- a/src/Factory/JwtMiddleware.php +++ b/src/Factory/JwtMiddleware.php @@ -37,7 +37,7 @@ public static function html(string $secret, string $tokenKey = '', string $body * * @param string $tokenKey * @param string $secret - * @param array $body + * @param mixed[] $body * @return JwtAuthMiddleware */ public static function json(string $secret, string $tokenKey = '', array $body = []): JwtAuthMiddleware diff --git a/src/Handler/Json.php b/src/Handler/Json.php index fdb2b6a..c3a6a52 100644 --- a/src/Handler/Json.php +++ b/src/Handler/Json.php @@ -18,14 +18,14 @@ class Json extends Authorise implements RequestHandlerInterface { /** - * @var array The content to add to the response body. + * @var mixed[] The content to add to the response body. */ private $body; /** * @param string $secret * @param string $tokenKey - * @param array $body + * @param mixed[] $body */ public function __construct(string $secret, string $tokenKey, array $body) { diff --git a/src/Helper/Request.php b/src/Helper/Request.php index 39a855f..90fd65f 100644 --- a/src/Helper/Request.php +++ b/src/Helper/Request.php @@ -33,6 +33,8 @@ public function getParsedToken(ServerRequestInterface $request, string $tokenKey /** * Retrieve the JWT header information from a request. + * + * @return mixed[] */ public function getTokenHeader(ServerRequestInterface $request, string $tokenKey): array { @@ -41,6 +43,8 @@ public function getTokenHeader(ServerRequestInterface $request, string $tokenKey /** * Retrieve the JWT payload information from a request. + * + * @return mixed[] */ public function getTokenPayload(ServerRequestInterface $request, string $tokenKey): array { diff --git a/src/Parser/Parse.php b/src/Parser/Parse.php index fe0fffb..16241a2 100644 --- a/src/Parser/Parse.php +++ b/src/Parser/Parse.php @@ -13,7 +13,7 @@ class Parse { /** - * @var array $parsers + * @var mixed[] $parsers */ private $parsers = []; diff --git a/src/Validation/Validate.php b/src/Validation/Validate.php index 1e0570f..becdd1a 100644 --- a/src/Validation/Validate.php +++ b/src/Validation/Validate.php @@ -16,7 +16,7 @@ class Validate /** * @param Parse $parse */ - private $parse; + private Parse $parse; /** * @param Parse $parse @@ -29,7 +29,7 @@ public function __construct(Parse $parse) /** * The JSON Web Token must be valid and not have expired. * - * @return array + * @return mixed[] */ public function validate(): array { @@ -48,7 +48,8 @@ public function validate(): array /** * The token must be ready to use. * - * @return array + * @param mixed[] $validationState + * @return mixed[] */ public function validateNotBefore(array $validationState): array { From 5a4022cfb146b20d211991d13271bc74fde9e183 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Tue, 19 Apr 2022 13:49:14 +0100 Subject: [PATCH 06/17] Updated Validate class to work with ReallySimpleJWT Validate class which was added in v4.0 rather than the Parse class. --- src/Auth/Authorise.php | 4 ++-- src/Factory/Jwt.php | 8 ++++++++ src/Validation/Validate.php | 19 ++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Auth/Authorise.php b/src/Auth/Authorise.php index 98d4c17..b2ff95f 100644 --- a/src/Auth/Authorise.php +++ b/src/Auth/Authorise.php @@ -71,9 +71,9 @@ private function validate(string $token): Auth { $jwt = new Jwt(); - $parse = $jwt->parser($token, $this->secret); + $validator = $jwt->validator($token, $this->secret); - $validate = new Validate($parse); + $validate = new Validate($validator); $validationState = $validate->validate(); diff --git a/src/Factory/Jwt.php b/src/Factory/Jwt.php index 15b7a58..af037a1 100644 --- a/src/Factory/Jwt.php +++ b/src/Factory/Jwt.php @@ -7,6 +7,7 @@ use ReallySimpleJWT\Tokens; use ReallySimpleJWT\Build; use ReallySimpleJWT\Parse; +use ReallySimpleJWT\Validate; /** * PSR-JWT wraps around the ReallySimpleJWT library to provide token @@ -39,4 +40,11 @@ public function parser(string $token, string $secret): Parse return $tokens->parser($token, $secret); } + + public function validator(string $token, string $secret): Validate + { + $tokens = new Tokens(); + + return $tokens->validator($token, $secret); + } } diff --git a/src/Validation/Validate.php b/src/Validation/Validate.php index becdd1a..ec222c0 100644 --- a/src/Validation/Validate.php +++ b/src/Validation/Validate.php @@ -4,7 +4,7 @@ namespace PsrJwt\Validation; -use ReallySimpleJWT\Parse; +use ReallySimpleJWT\Validate as RSValidate; use ReallySimpleJWT\Exception\ValidateException; /** @@ -14,16 +14,13 @@ class Validate { /** - * @param Parse $parse + * @param RSValidate $validate */ - private Parse $parse; + private RSValidate $validate; - /** - * @param Parse $parse - */ - public function __construct(Parse $parse) + public function __construct(RSValidate $validate) { - $this->parse = $parse; + $this->validate = $validate; } /** @@ -34,8 +31,8 @@ public function __construct(Parse $parse) public function validate(): array { try { - $this->parse->validate() - ->validateExpiration(); + $this->validate->structure() + ->expiration(); } catch (ValidateException $e) { if (in_array($e->getCode(), [1, 2, 3, 4], true)) { return ['code' => $e->getCode(), 'message' => $e->getMessage()]; @@ -54,7 +51,7 @@ public function validate(): array public function validateNotBefore(array $validationState): array { try { - $this->parse->validateNotBefore(); + $this->validate->notBefore(); } catch (ValidateException $e) { if ($e->getCode() === 5) { return ['code' => $e->getCode(), 'message' => $e->getMessage()]; From 7af4e9d71125c3cd89ed55d838d65df0a20d92a9 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Tue, 19 Apr 2022 14:22:06 +0100 Subject: [PATCH 07/17] Updated Validate Test suite to work with changes made to Validate class. --- tests/Validation/ValidateTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Validation/ValidateTest.php b/tests/Validation/ValidateTest.php index 6651beb..5f3e2b0 100644 --- a/tests/Validation/ValidateTest.php +++ b/tests/Validation/ValidateTest.php @@ -3,7 +3,7 @@ namespace Tests\Validation; use PHPUnit\Framework\TestCase; -use ReallySimpleJWT\Parse; +use ReallySimpleJWT\Validate as RSValidate; use PsrJwt\Factory\Jwt; use PsrJwt\Validation\Validate; @@ -24,7 +24,7 @@ public function testValidate(): void ->getToken(); $validate = new Validate( - $jwt->parser($token, 'Secret123!456$') + $jwt->validator($token, 'Secret123!456$') ); $this->assertInstanceOf(Validate::class, $validate); @@ -46,7 +46,7 @@ public function testValidateOk(): void ->getToken(); $validate = new Validate( - $jwt->parser($token, 'Secret123!456$') + $jwt->validator($token, 'Secret123!456$') ); $result = $validate->validate(); @@ -71,7 +71,7 @@ public function testValidateExpiration(): void ->getToken(); $validate = new Validate( - $jwt->parser($token, 'Secret123!456$') + $jwt->validator($token, 'Secret123!456$') ); $result = $validate->validate(); @@ -83,14 +83,14 @@ public function testValidateExpiration(): void /** * @covers PsrJwt\Validation\Validate::validate * @uses PsrJwt\Validation\Validate - * @uses PsrJwt\Factory\Jwt::parser + * @uses PsrJwt\Factory\Jwt::validator */ public function testValidateTokenStructure(): void { $jwt = new Jwt(); $validate = new Validate( - $jwt->parser('123.abc', 'Secret123!456$') + $jwt->validator('123.abc', 'Secret123!456$') ); $result = $validate->validate(); @@ -102,14 +102,14 @@ public function testValidateTokenStructure(): void /** * @covers PsrJwt\Validation\Validate::validate * @uses PsrJwt\Validation\Validate - * @uses PsrJwt\Factory\Jwt::parser + * @uses PsrJwt\Factory\Jwt::validator */ public function testValidateBadSignature(): void { $jwt = new Jwt(); $validate = new Validate( - $jwt->parser('123.abc.456', 'Secret123!456$') + $jwt->validator('123.abc.456', 'Secret123!456$') ); $result = $validate->validate(); @@ -134,7 +134,7 @@ public function testValidateNotBefore(): void ->getToken(); $validate = new Validate( - $jwt->parser($token, 'Secret123!456$') + $jwt->validator($token, 'Secret123!456$') ); $result = $validate->validateNotBefore( @@ -161,7 +161,7 @@ public function testValidateNotBeforeOk(): void ->getToken(); $validate = new Validate( - $jwt->parser($token, 'Secret123!456$') + $jwt->validator($token, 'Secret123!456$') ); $result = $validate->validateNotBefore( From e9aad285dd59c1b2e7bc8d8b5b6573f9ba8adf52 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Tue, 19 Apr 2022 14:22:27 +0100 Subject: [PATCH 08/17] Applied PSR 12 fix to Request class. --- src/Helper/Request.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Helper/Request.php b/src/Helper/Request.php index 90fd65f..b66ab9a 100644 --- a/src/Helper/Request.php +++ b/src/Helper/Request.php @@ -33,7 +33,7 @@ public function getParsedToken(ServerRequestInterface $request, string $tokenKey /** * Retrieve the JWT header information from a request. - * + * * @return mixed[] */ public function getTokenHeader(ServerRequestInterface $request, string $tokenKey): array @@ -43,7 +43,7 @@ public function getTokenHeader(ServerRequestInterface $request, string $tokenKey /** * Retrieve the JWT payload information from a request. - * + * * @return mixed[] */ public function getTokenPayload(ServerRequestInterface $request, string $tokenKey): array From 9efc1e64e1a64bbc4cd44aff277b0827883eda3c Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Tue, 19 Apr 2022 17:01:57 +0100 Subject: [PATCH 09/17] Applied token creation fixes to JsonTest class. --- tests/Handler/JsonTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Handler/JsonTest.php b/tests/Handler/JsonTest.php index af25ac0..e784f3e 100644 --- a/tests/Handler/JsonTest.php +++ b/tests/Handler/JsonTest.php @@ -46,6 +46,8 @@ public function testAuthoriseOk(): void $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); $token = $jwt->setSecret('Secret123!456$') + ->setExpiration(time() + 10) + ->setNotBefore(time() - 10) ->setIssuer('localhost') ->build() ->getToken(); @@ -95,6 +97,8 @@ public function testAuthoriseFail(): void $jwt = $jwt = new Jwt(); $jwt = $jwt->builder(); $token = $jwt->setSecret('Secret123!456$') + ->setExpiration(time() + 10) + ->setNotBefore(time() - 10) ->setIssuer('localhost') ->build() ->getToken(); From 2a46e032eecff61f0c76f8b382791348bc6b036a Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Tue, 19 Apr 2022 17:03:29 +0100 Subject: [PATCH 10/17] Added expiration and signature checks to the validate class. --- src/Validation/Validate.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Validation/Validate.php b/src/Validation/Validate.php index ec222c0..41300bd 100644 --- a/src/Validation/Validate.php +++ b/src/Validation/Validate.php @@ -32,7 +32,8 @@ public function validate(): array { try { $this->validate->structure() - ->expiration(); + ->expiration() + ->signature(); } catch (ValidateException $e) { if (in_array($e->getCode(), [1, 2, 3, 4], true)) { return ['code' => $e->getCode(), 'message' => $e->getMessage()]; From 0740eff4f70e218e60e1082e75f34f148e3a3809 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Fri, 22 Apr 2022 22:42:46 +0100 Subject: [PATCH 11/17] Edited Validate class validate method to ensure signature test continues to work. --- src/Validation/Validate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Validation/Validate.php b/src/Validation/Validate.php index 41300bd..ac177f3 100644 --- a/src/Validation/Validate.php +++ b/src/Validation/Validate.php @@ -32,8 +32,8 @@ public function validate(): array { try { $this->validate->structure() - ->expiration() - ->signature(); + ->signature() + ->expiration(); } catch (ValidateException $e) { if (in_array($e->getCode(), [1, 2, 3, 4], true)) { return ['code' => $e->getCode(), 'message' => $e->getMessage()]; From 106e82b67e01ea58a951126536b5f1a80001e621 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Sat, 23 Apr 2022 14:43:08 +0100 Subject: [PATCH 12/17] Set Validate class methods to catch Parse Exceptions failures. --- src/Validation/Validate.php | 5 +++-- tests/Auth/AuthoriseTest.php | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Validation/Validate.php b/src/Validation/Validate.php index ac177f3..73100e2 100644 --- a/src/Validation/Validate.php +++ b/src/Validation/Validate.php @@ -6,6 +6,7 @@ use ReallySimpleJWT\Validate as RSValidate; use ReallySimpleJWT\Exception\ValidateException; +use ReallySimpleJWT\Exception\ParseException; /** * Validate the JSON Web Token will parse, has a valid signature, is ready to @@ -34,7 +35,7 @@ public function validate(): array $this->validate->structure() ->signature() ->expiration(); - } catch (ValidateException $e) { + } catch (ValidateException | ParseException $e) { if (in_array($e->getCode(), [1, 2, 3, 4], true)) { return ['code' => $e->getCode(), 'message' => $e->getMessage()]; } @@ -53,7 +54,7 @@ public function validateNotBefore(array $validationState): array { try { $this->validate->notBefore(); - } catch (ValidateException $e) { + } catch (ValidateException | ParseException $e) { if ($e->getCode() === 5) { return ['code' => $e->getCode(), 'message' => $e->getMessage()]; } diff --git a/tests/Auth/AuthoriseTest.php b/tests/Auth/AuthoriseTest.php index 240076f..b0817cd 100644 --- a/tests/Auth/AuthoriseTest.php +++ b/tests/Auth/AuthoriseTest.php @@ -7,6 +7,7 @@ use PsrJwt\Auth\Authorise; use PsrJwt\Auth\Auth; use PsrJwt\Factory\Jwt; +use PsrJwt\Parser\ParseException; use ReflectionMethod; use Mockery as m; @@ -425,8 +426,6 @@ public function testGetTokenQuery(): void } /** - * @expectedException PsrJwt\Parser\ParseException - * @expectedExceptionMessage JSON Web Token not set in request. * @covers PsrJwt\Auth\Authorise::getToken * @uses PsrJwt\Auth\Authorise * @uses PsrJwt\Parser\Parse @@ -458,7 +457,9 @@ public function testGetTokenNoToken(): void $method = new ReflectionMethod(Authorise::class, 'getToken'); $method->setAccessible(true); - $result = $method->invokeArgs($auth, [$request]); + $this->expectException(ParseException::class); + $this->expectExceptionMessage("JSON Web Token not set in request."); + $method->invokeArgs($auth, [$request]); } public function tearDown(): void From fa4b564e353bb4df4d3247cfada76c92b33c7822 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Sat, 23 Apr 2022 14:47:54 +0100 Subject: [PATCH 13/17] Adjusted MSI score to get mutation tests to pass again as change is negligible. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e45b946..d802319 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "vendor/bin/phpstan analyse -l 7 src/ tests/", "vendor/bin/phpmd src/ text ruleset.xml", "vendor/bin/phpunit --coverage-clover=coverage.xml", - "vendor/bin/infection -s --min-msi=90", + "vendor/bin/infection -s --min-msi=89", "vendor/bin/phpcpd --min-lines=2 --min-tokens=35 src/", "vendor/bin/phploc src/" ] From 3b77ed8595c99c0ed72fb6f72c295ffebf6bc585 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Sat, 23 Apr 2022 22:35:14 +0100 Subject: [PATCH 14/17] Updated GHA CI pipeline to run on versions 7.4 and 8.0. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 031c1e1..6a508d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.2', '7.3', '7.4'] + php-versions: ['7.4', '8.0'] name: PHP ${{ matrix.php-versions }} Test steps: - name: Checkout From 769e03ab9992c7cf6fead2f30c3ad522c8de343b Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Sun, 24 Apr 2022 22:37:38 +0100 Subject: [PATCH 15/17] Tidied up comments in Jwt Factory class, ensured each method has a comment. --- src/Factory/Jwt.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Factory/Jwt.php b/src/Factory/Jwt.php index af037a1..64aa072 100644 --- a/src/Factory/Jwt.php +++ b/src/Factory/Jwt.php @@ -30,7 +30,7 @@ public function builder(): Build } /** - * Allow for the parsing and validation of JSON Web Tokens. + * Allow for the parsing of JSON Web Tokens. * * @return Parse */ @@ -41,6 +41,11 @@ public function parser(string $token, string $secret): Parse return $tokens->parser($token, $secret); } + /** + * Allow for the validation JSON Web Tokens. + * + * @return Validate + */ public function validator(string $token, string $secret): Validate { $tokens = new Tokens(); From 2feff44e0b4e3ec5f65f793322fb4ac730daf4fa Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Sun, 24 Apr 2022 22:38:11 +0100 Subject: [PATCH 16/17] Added missing test for Jwt Factory validator method. --- tests/Factory/JwtTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Factory/JwtTest.php b/tests/Factory/JwtTest.php index ad411e9..c89778c 100644 --- a/tests/Factory/JwtTest.php +++ b/tests/Factory/JwtTest.php @@ -5,6 +5,7 @@ use PHPUnit\Framework\TestCase; use ReallySimpleJWT\Build; use ReallySimpleJWT\Parse; +use ReallySimpleJWT\Validate; use PsrJwt\Factory\Jwt; class JwtTest extends TestCase @@ -30,4 +31,15 @@ public function testJwtParser(): void $this->assertInstanceOf(Parse::class, $jwt); } + + /** + * @covers PsrJwt\Factory\Jwt::validator + */ + public function testJwtValidator(): void + { + $jwt = new Jwt(); + $jwt = $jwt->validator('aaa.bbb.ccc', 'secret'); + + $this->assertInstanceOf(Validate::class, $jwt); + } } From 3fc60995b64b44a75c4808a2bb58eb63f56bebd7 Mon Sep 17 00:00:00 2001 From: Rob Waller Date: Sun, 24 Apr 2022 22:39:23 +0100 Subject: [PATCH 17/17] Returned mutation score index to 90 as it was a missing test which caused it to drop to 89. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d802319..e45b946 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "vendor/bin/phpstan analyse -l 7 src/ tests/", "vendor/bin/phpmd src/ text ruleset.xml", "vendor/bin/phpunit --coverage-clover=coverage.xml", - "vendor/bin/infection -s --min-msi=89", + "vendor/bin/infection -s --min-msi=90", "vendor/bin/phpcpd --min-lines=2 --min-tokens=35 src/", "vendor/bin/phploc src/" ]