From 3229a2baaff6183c214b2dc1b935011f858e3bc9 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Wed, 21 Feb 2024 07:44:03 +0100 Subject: [PATCH 1/7] Add support for Laravel 11 --- .github/workflows/phpunit.yml | 24 +++++++++++++++++++++--- CHANGELOG.md | 6 ++++++ composer.json | 14 +++++++------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 62badae4..6784a318 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: php: [7.4, 8.0, 8.1, 8.2] - laravel: [6.*, 7.*, 8.*, 9.*, 10.*] + laravel: [6.*, 7.*, 8.*, 9.*, 10.*, 11.*] stability: [prefer-lowest, prefer-stable] os: [ubuntu-latest] coverage: [none] @@ -41,6 +41,12 @@ jobs: php: 7.4 - laravel: 10.* php: 8.0 + - laravel: 11.* + php: 7.4 + - laravel: 11.* + php: 8.0 + - laravel: 11.* + php: 8.1 include: - laravel: 6.* dotenv: ^3.3 @@ -57,6 +63,9 @@ jobs: - laravel: 10.* dotenv: ^5.4.1 + - laravel: 11.* + dotenv: ^5.4.1 + - php: 8.0 laravel: 9.* stability: prefer-stable @@ -94,9 +103,18 @@ jobs: id: composer-cache run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - name: Set Minimum PHP 8.0 Versions + - name: Set phpunit for PHP >= 8 but Laravel < 11 run: composer require phpunit/phpunit:^9.4 --no-interaction --no-progress --no-update - if: matrix.php >= 8 + if: matrix.php >= 8 || matrix.laravel != '11.*' + + - name: Set phpunit for Laravel >= 11 + run: composer require phpunit/phpunit:^10 --no-interaction --no-progress --no-update + if: matrix.laravel == '11.*' + + # Packages which are not striclty required for testing but could cause + # conflicts with other packages + - name: Remove packages not necessary + run: composer remove --dev rector/rector --no-interaction --no-progress --no-update - name: Set Minimum Laravel ${{ matrix.laravel }} Versions run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c26add8..b4bd85dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ You can find and compare releases at the GitHub release page. ### Added - Different TTL configurations for each guard +- Laravel 11 support + +## [2.1.0] 2023-02-17 + +### Added +- Laravel 10 support ## [2.0.0] 2022-09-08 - No changes to 2.0.0-RC1 diff --git a/composer.json b/composer.json index ccb16f27..9e7ab956 100644 --- a/composer.json +++ b/composer.json @@ -35,19 +35,19 @@ "require": { "php": "^7.4|^8.0", "ext-json": "*", - "illuminate/auth": "^6|^7|^8.67|^9|^10", - "illuminate/contracts": "^6|^7|^8.67|^9|^10", - "illuminate/http": "^6|^7|^8.67|^9|^10", - "illuminate/support": "^6|^7|^8.67|^9|^10", + "illuminate/auth": "^6|^7|^8.67|^9|^10|^11", + "illuminate/contracts": "^6|^7|^8.67|^9|^10|^11", + "illuminate/http": "^6|^7|^8.67|^9|^10|^11", + "illuminate/support": "^6|^7|^8.67|^9|^10|^11", "lcobucci/jwt": "^4.0", "namshi/jose": "^7.0", "nesbot/carbon": "^1.0|^2.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3", - "illuminate/console": "^6|^7|^8.67|^9|^10", - "illuminate/routing": "^6|^7|^8.67|^9|^10", - "orchestra/testbench": "^4.18|^5.8|^6.3|^7|^8", + "illuminate/console": "^6|^7|^8.67|^9|^10|^11", + "illuminate/routing": "^6|^7|^8.67|^9|^10|^11", + "orchestra/testbench": "^4.18|^5.8|^6.3|^7|^8|^9|9.x-dev", "mockery/mockery": "^1.4.4", "phpstan/phpstan": "^1", "phpunit/phpunit": "^8.5|^9.4|^10", From 4ae549c007936c9c0f91b8f9f87980586cd34b24 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Wed, 21 Feb 2024 08:52:54 +0100 Subject: [PATCH 2/7] Remove unsupported --verbose for phpunit 10 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9e7ab956..e970f1fe 100644 --- a/composer.json +++ b/composer.json @@ -88,7 +88,7 @@ "scripts": { "php-cs-fixer": "php-cs-fixer fix --diff", "test": "phpunit --colors=always", - "test:ci": "composer test -- --verbose --coverage-text --coverage-clover=coverage.xml", + "test:ci": "composer test -- --coverage-text --coverage-clover=coverage.xml", "phpstan": "phpstan analyse --memory-limit=256M", "phpstan-baseline": "phpstan analyse --generate-baseline --memory-limit=256M" } From f951f4c70a9fd8f39daca77da3a3b47fcd49af8c Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Wed, 21 Feb 2024 08:58:02 +0100 Subject: [PATCH 3/7] Add new getAuthPasswordName for stub Was added to the L11 Authenticable contract --- tests/Stubs/LaravelUserStub.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Stubs/LaravelUserStub.php b/tests/Stubs/LaravelUserStub.php index 196ca62d..83e25547 100644 --- a/tests/Stubs/LaravelUserStub.php +++ b/tests/Stubs/LaravelUserStub.php @@ -25,6 +25,10 @@ public function getAuthIdentifier() { } + public function getAuthPasswordName() + { + } + public function getAuthPassword() { } From 0e375057cf30888ea527ced987ee9b77864eedb2 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Wed, 21 Feb 2024 10:35:01 +0100 Subject: [PATCH 4/7] vendor/bin/phpunit --migrate-configuration Also removed setting which have their default anyway, I consulted https://docs.phpunit.de/en/10.5/configuration.html for this. Note: removed `colors=true` nevertheless, don't think it's really necessary --- phpunit.xml.dist | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4f7dda60..cd6688ba 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,31 +1,14 @@ - - - src/ - - - src/Providers/LumenServiceProvider.php - src/Facades/ - src/Console/ - @@ -40,4 +23,14 @@ + + + src/ + + + src/Providers/LumenServiceProvider.php + src/Facades/ + src/Console/ + + From 5cfc5a082fa69529a42b0ede8cb44da5b603ace2 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Wed, 21 Feb 2024 10:39:24 +0100 Subject: [PATCH 5/7] tests: rename abstract class for tests phpunit does not want non-executable test classes, fixes: > `Class PHPOpenSourceSaver\JWTAuth\Test\Middleware\AbstractMiddlewareTest declared in /home/runner/work/jwt-auth/jwt-auth/tests/Middleware/AbstractMiddlewareTest.php is abstract` --- .../{AbstractMiddlewareTest.php => AbstractMiddleware.php} | 2 +- tests/Middleware/AuthenticateAndRenewTest.php | 2 +- tests/Middleware/AuthenticateTest.php | 2 +- tests/Middleware/CheckTest.php | 2 +- tests/Middleware/RefreshTokenTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename tests/Middleware/{AbstractMiddlewareTest.php => AbstractMiddleware.php} (92%) diff --git a/tests/Middleware/AbstractMiddlewareTest.php b/tests/Middleware/AbstractMiddleware.php similarity index 92% rename from tests/Middleware/AbstractMiddlewareTest.php rename to tests/Middleware/AbstractMiddleware.php index 2e677a99..afa067db 100644 --- a/tests/Middleware/AbstractMiddlewareTest.php +++ b/tests/Middleware/AbstractMiddleware.php @@ -17,7 +17,7 @@ use PHPOpenSourceSaver\JWTAuth\JWTAuth; use PHPOpenSourceSaver\JWTAuth\Test\AbstractTestCase; -abstract class AbstractMiddlewareTest extends AbstractTestCase +abstract class AbstractMiddleware extends AbstractTestCase { /** * @var MockInterface|JWTAuth diff --git a/tests/Middleware/AuthenticateAndRenewTest.php b/tests/Middleware/AuthenticateAndRenewTest.php index d33f202c..33991140 100644 --- a/tests/Middleware/AuthenticateAndRenewTest.php +++ b/tests/Middleware/AuthenticateAndRenewTest.php @@ -20,7 +20,7 @@ use PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; -class AuthenticateAndRenewTest extends AbstractMiddlewareTest +class AuthenticateAndRenewTest extends AbstractMiddleware { /** * @var Authenticate|AuthenticateAndRenew diff --git a/tests/Middleware/AuthenticateTest.php b/tests/Middleware/AuthenticateTest.php index c8c2c583..016679af 100644 --- a/tests/Middleware/AuthenticateTest.php +++ b/tests/Middleware/AuthenticateTest.php @@ -18,7 +18,7 @@ use PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; -class AuthenticateTest extends AbstractMiddlewareTest +class AuthenticateTest extends AbstractMiddleware { /** * @var Authenticate diff --git a/tests/Middleware/CheckTest.php b/tests/Middleware/CheckTest.php index 01886b84..e43fa920 100644 --- a/tests/Middleware/CheckTest.php +++ b/tests/Middleware/CheckTest.php @@ -17,7 +17,7 @@ use PHPOpenSourceSaver\JWTAuth\Http\Parser\Parser; use PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub; -class CheckTest extends AbstractMiddlewareTest +class CheckTest extends AbstractMiddleware { /** * @var Check diff --git a/tests/Middleware/RefreshTokenTest.php b/tests/Middleware/RefreshTokenTest.php index e4454fc0..38563372 100644 --- a/tests/Middleware/RefreshTokenTest.php +++ b/tests/Middleware/RefreshTokenTest.php @@ -18,7 +18,7 @@ use PHPOpenSourceSaver\JWTAuth\Http\Parser\Parser; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; -class RefreshTokenTest extends AbstractMiddlewareTest +class RefreshTokenTest extends AbstractMiddleware { /** * @var RefreshToken From 9a2ad4369810ed747f730d1a9fda9fd84f071c0b Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Wed, 21 Feb 2024 10:41:55 +0100 Subject: [PATCH 6/7] tests: make data providers static Fixes: ``` 1) PHPOpenSourceSaver\JWTAuth\Test\BlacklistTest::itShouldCheckWhetherATokenHasNotBeenBlacklisted Data Provider method PHPOpenSourceSaver\JWTAuth\Test\BlacklistTest::blacklist_provider() is not static /home/runner/work/jwt-auth/jwt-auth/tests/BlacklistTest.php:198 2) PHPOpenSourceSaver\JWTAuth\Test\Http\ParserTest::itShouldHandleExcessWhitespaceFromTheAuthorizationHeader Data Provider method PHPOpenSourceSaver\JWTAuth\Test\Http\ParserTest::whitespaceProvider() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Http/ParserTest.php:137 3) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldReturnFalseWhenProvidingAMalformedToken Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderMalformedTokens() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Validators/TokenValidatorTest.php:46 4) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldThrowAnExceptionWhenProvidingAMalformedToken Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderMalformedTokens() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Validators/TokenValidatorTest.php:56 5) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldReturnFalseWhenProvidingATokenWithWrongSegmentsNumber Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderTokensWithWrongSegmentsNumber() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Validators/TokenValidatorTest.php:69 6) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldThrowAnExceptionWhenProvidingAMalformedTokenWithWrongSegmentsNumber Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderTokensWithWrongSegmentsNumber() is not static ``` --- tests/BlacklistTest.php | 2 +- tests/Http/ParserTest.php | 2 +- tests/Validators/TokenValidatorTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/BlacklistTest.php b/tests/BlacklistTest.php index a178e0eb..76ac86d9 100644 --- a/tests/BlacklistTest.php +++ b/tests/BlacklistTest.php @@ -179,7 +179,7 @@ public function itShouldCheckWhetherATokenHasBeenBlacklisted() $this->assertTrue($this->blacklist->has($payload)); } - public function blacklist_provider() + public static function blacklist_provider() { return [ [null], diff --git a/tests/Http/ParserTest.php b/tests/Http/ParserTest.php index d0b908c1..2a36c9ba 100644 --- a/tests/Http/ParserTest.php +++ b/tests/Http/ParserTest.php @@ -152,7 +152,7 @@ public function itShouldHandleExcessWhitespaceFromTheAuthorizationHeader($whites $this->assertTrue($parser->hasToken()); } - public function whitespaceProvider() + public static function whitespaceProvider() { return [ 'space' => [' '], diff --git a/tests/Validators/TokenValidatorTest.php b/tests/Validators/TokenValidatorTest.php index 2055bc06..9880c07a 100644 --- a/tests/Validators/TokenValidatorTest.php +++ b/tests/Validators/TokenValidatorTest.php @@ -84,7 +84,7 @@ public function itShouldThrowAnExceptionWhenProvidingAMalformedTokenWithWrongSeg $this->validator->check($token); } - public function dataProviderMalformedTokens() + public static function dataProviderMalformedTokens() { return [ ['one.two.'], @@ -97,7 +97,7 @@ public function dataProviderMalformedTokens() ]; } - public function dataProviderTokensWithWrongSegmentsNumber() + public static function dataProviderTokensWithWrongSegmentsNumber() { return [ ['one.two'], From cff349a95d596ada1be93c9d98cfe731be9331c3 Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Wed, 21 Feb 2024 10:53:25 +0100 Subject: [PATCH 7/7] gha: always make xdebug available Fixes the following phpunit warning for now (which fails the workflow): > `No code coverage driver available` We still only upload the coverage when explicitly enabled. --- .github/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 6784a318..a3718e8d 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -91,7 +91,7 @@ jobs: with: php-version: ${{ matrix.php }} extensions: mbstring json openssl - coverage: ${{ matrix.coverage }} + coverage: xdebug ini-values: memory_limit=-1 - name: Setup Problem Matchers