From 967a178ae29f37dc65ffffdc993524cf3ea76ffa Mon Sep 17 00:00:00 2001 From: Martin Boer Date: Wed, 17 Apr 2024 14:43:47 +0200 Subject: [PATCH] :arrow_up: update to require PHP 8.2 --- .github/workflows/ci.yml | 11 ++++------- tests/CheckForAnyScopeTest.php | 4 ---- tests/CheckForScopesTest.php | 8 +------- tests/JwtRequestAuthenticatorTest.php | 9 --------- tests/PublicKeyTest.php | 6 ------ tests/ScopeCheckerTest.php | 2 -- 6 files changed, 5 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b14926..0ee103b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,15 +12,12 @@ jobs: - name: Composer uses: php-actions/composer@v6 with: - php_version: 8.0 + php_version: 8.2 - name: PHPUnit uses: php-actions/phpunit@v3 with: - bootstrap: vendor/autoload.php - test_suffix: Test.php - php_extensions: xdebug + php_version: 8.2 configuration: phpunit.xml - coverage_text: true - env: - XDEBUG_MODE: coverage + test_suffix: Test.php + args: --no-coverage diff --git a/tests/CheckForAnyScopeTest.php b/tests/CheckForAnyScopeTest.php index 991dc6e..fe5c18b 100644 --- a/tests/CheckForAnyScopeTest.php +++ b/tests/CheckForAnyScopeTest.php @@ -35,7 +35,6 @@ protected function setUp(): void $this->scopeChecker = new CheckForAnyScope(); } - /** @test */ public function testHandle(): void { $this->scopeChecker->setAuthenticator($this->createAuthenticatorReturningScopes(['test-scope'])); @@ -43,7 +42,6 @@ public function testHandle(): void $this->assertTrue($this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope')); } - /** @test */ public function testHandleWithOnlyOneScopeExisting(): void { $this->scopeChecker->setAuthenticator($this->createAuthenticatorReturningScopes(['test-scope'])); @@ -51,7 +49,6 @@ public function testHandleWithOnlyOneScopeExisting(): void $this->assertTrue($this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope', 'test-scope2')); } - /** @test */ public function testHandleWithMissingScopeGivesMissingScopeExceptionWhenMissingOne(): void { $this->expectException(MissingScopeException::class); @@ -63,7 +60,6 @@ public function testHandleWithMissingScopeGivesMissingScopeExceptionWhenMissingO $this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope'); } - /** @test */ public function testHandleWithMultipleScopes(): void { $this->scopeChecker->setAuthenticator($this->createAuthenticatorReturningScopes([ diff --git a/tests/CheckForScopesTest.php b/tests/CheckForScopesTest.php index cd4745a..eed89bd 100644 --- a/tests/CheckForScopesTest.php +++ b/tests/CheckForScopesTest.php @@ -28,14 +28,11 @@ protected function setUp(): void parent::setUp(); $this->generateKeys(); - $this->trueClosure = function () { - return true; - }; + $this->trueClosure = fn () => true; $this->request = $this->createAuthorizationRequest(); $this->scopeChecker = new CheckForScopes(); } - /** @test */ public function testHandle(): void { $this->scopeChecker->setAuthenticator($this->createAuthenticatorReturningScopes(['test-scope'])); @@ -43,7 +40,6 @@ public function testHandle(): void $this->assertTrue($this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope')); } - /** @test */ public function testHandleWithMissingScopesGivesMissingScopeExceptionWhenMissingOnlyOne(): void { $this->expectException(MissingScopeException::class); @@ -52,7 +48,6 @@ public function testHandleWithMissingScopesGivesMissingScopeExceptionWhenMissing $this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope', 'test-scope2'); } - /** @test */ public function testHandleWithMissingScopeGivesMissingScopeExceptionWhenMissingOne(): void { $this->expectException(MissingScopeException::class); @@ -64,7 +59,6 @@ public function testHandleWithMissingScopeGivesMissingScopeExceptionWhenMissingO $this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope'); } - /** @test */ public function testHandleWithMultipleScopes(): void { $this->scopeChecker->setAuthenticator($this->createAuthenticatorReturningScopes([ diff --git a/tests/JwtRequestAuthenticatorTest.php b/tests/JwtRequestAuthenticatorTest.php index 8de3ed5..29e5aa3 100644 --- a/tests/JwtRequestAuthenticatorTest.php +++ b/tests/JwtRequestAuthenticatorTest.php @@ -31,7 +31,6 @@ protected function setUp(): void ->setPublicKey($this->publicKey); } - /** @test */ public function testAuthenticate(): void { $authorizationHeader = 'Bearer ' . $this->createTokenString([], null, 'some-user-id', []); @@ -41,7 +40,6 @@ public function testAuthenticate(): void $this->assertEquals('some-user-id', $token->claims()->get('user_id')); } - /** @test */ public function testAuthenticateWithQueryParameter(): void { $request = Mockery::mock(Request::class, [ @@ -54,7 +52,6 @@ public function testAuthenticateWithQueryParameter(): void $this->assertEquals('some-user-id', $token->claims()->get('user_id')); } - /** @test */ public function testAuthenticateWithInvalidKey(): void { $this->authenticator->setPublicKey(''); @@ -65,7 +62,6 @@ public function testAuthenticateWithInvalidKey(): void $this->authenticator->authenticate($request); } - /** @test */ public function testAuthenticateWithInvalidToken(): void { $authorizationHeader = 'Bearer ' . $this->createTokenString([], null, 'some-user-id', []); @@ -76,7 +72,6 @@ public function testAuthenticateWithInvalidToken(): void $this->authenticator->authenticate($request); } - /** @test */ public function testAuthenticateWithInvalidSignature(): void { $privateKeyResource = openssl_pkey_new(['private_key_bits' => 2048]); @@ -90,7 +85,6 @@ public function testAuthenticateWithInvalidSignature(): void $this->authenticator->authenticate($request); } - /** @test */ public function testAuthenticateWithExpiredToken(): void { $authorizationHeader = 'Bearer ' . $this->createTokenString([], time() - 100, 'some-user-id', []); @@ -100,7 +94,6 @@ public function testAuthenticateWithExpiredToken(): void $this->authenticator->authenticate($request); } - /** @test */ public function testAccessTokenWithRequestWithoutAuthorizationHeader(): void { $request = Mockery::mock(Request::class, ['header' => null, 'has' => false]); @@ -109,7 +102,6 @@ public function testAccessTokenWithRequestWithoutAuthorizationHeader(): void $this->authenticator->authenticate($request); } - /** @test */ public function testAccessTokenParsing(): void { $request = Mockery::mock(Request::class, ['header' => 'r.i.p', 'has' => false]); @@ -118,7 +110,6 @@ public function testAccessTokenParsing(): void $this->authenticator->authenticate($request); } - /** @test */ public function testGetPublicKeyExceptionWithoutKey(): void { $this->authenticator = new JwtRequestAuthenticator(); diff --git a/tests/PublicKeyTest.php b/tests/PublicKeyTest.php index dbea313..341000f 100644 --- a/tests/PublicKeyTest.php +++ b/tests/PublicKeyTest.php @@ -26,7 +26,6 @@ protected function setUp(): void $this->key->setPath($tempFile); } - /** @test */ public function testGetKeyString(): void { $keyString = $this->key->getKeyString(); @@ -35,7 +34,6 @@ public function testGetKeyString(): void $this->assertEquals('this-is-an-oauth-key', $keyString); } - /** @test */ public function testGetKeyStringWithoutSsl(): void { $keyString = $this->key->setVerifySsl(false)->getKeyString(); @@ -44,13 +42,11 @@ public function testGetKeyStringWithoutSsl(): void $this->assertEquals('this-is-an-oauth-key', $keyString); } - /** @test */ public function testToString(): void { $this->assertEquals($this->key->getKeyString(), (string) $this->key); } - /** @test */ public function testCache(): void { $publicKey = $this->key->setCache(new CacheMock()); @@ -76,7 +72,6 @@ public function testCache(): void ); } - /** @test */ public function testSetPath(): void { $publicKey = new PublicKey(); @@ -98,7 +93,6 @@ public function testSetPath(): void ); } - /** @test */ public function testUnSetPath(): void { $publicKey = new PublicKey(); diff --git a/tests/ScopeCheckerTest.php b/tests/ScopeCheckerTest.php index 21f5893..6affebb 100644 --- a/tests/ScopeCheckerTest.php +++ b/tests/ScopeCheckerTest.php @@ -27,7 +27,6 @@ protected function setUp(): void $this->scopeChecker = new ScopeChecker(); } - /** @test */ public function testTokenCan(): void { $request = $this->createAuthorizationRequest(); @@ -37,7 +36,6 @@ public function testTokenCan(): void $this->assertTrue($result); } - /** @test */ public function testTokenCanNot(): void { $request = $this->createAuthorizationRequest();