Skip to content

Commit

Permalink
⬆️ update to require PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
M4tini committed Apr 17, 2024
1 parent 0d0a054 commit 967a178
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 35 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions tests/CheckForAnyScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,20 @@ protected function setUp(): void
$this->scopeChecker = new CheckForAnyScope();
}

/** @test */
public function testHandle(): void
{
$this->scopeChecker->setAuthenticator($this->createAuthenticatorReturningScopes(['test-scope']));

$this->assertTrue($this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope'));
}

/** @test */
public function testHandleWithOnlyOneScopeExisting(): void
{
$this->scopeChecker->setAuthenticator($this->createAuthenticatorReturningScopes(['test-scope']));

$this->assertTrue($this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope', 'test-scope2'));
}

/** @test */
public function testHandleWithMissingScopeGivesMissingScopeExceptionWhenMissingOne(): void
{
$this->expectException(MissingScopeException::class);
Expand All @@ -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([
Expand Down
8 changes: 1 addition & 7 deletions tests/CheckForScopesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,18 @@ 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']));

$this->assertTrue($this->scopeChecker->handle($this->request, $this->trueClosure, 'test-scope'));
}

/** @test */
public function testHandleWithMissingScopesGivesMissingScopeExceptionWhenMissingOnlyOne(): void
{
$this->expectException(MissingScopeException::class);
Expand All @@ -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);
Expand All @@ -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([
Expand Down
9 changes: 0 additions & 9 deletions tests/JwtRequestAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ protected function setUp(): void
->setPublicKey($this->publicKey);
}

/** @test */
public function testAuthenticate(): void
{
$authorizationHeader = 'Bearer ' . $this->createTokenString([], null, 'some-user-id', []);
Expand All @@ -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, [
Expand All @@ -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('');
Expand All @@ -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', []);
Expand All @@ -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]);
Expand All @@ -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', []);
Expand All @@ -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]);
Expand All @@ -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]);
Expand All @@ -118,7 +110,6 @@ public function testAccessTokenParsing(): void
$this->authenticator->authenticate($request);
}

/** @test */
public function testGetPublicKeyExceptionWithoutKey(): void
{
$this->authenticator = new JwtRequestAuthenticator();
Expand Down
6 changes: 0 additions & 6 deletions tests/PublicKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ protected function setUp(): void
$this->key->setPath($tempFile);
}

/** @test */
public function testGetKeyString(): void
{
$keyString = $this->key->getKeyString();
Expand All @@ -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();
Expand All @@ -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());
Expand All @@ -76,7 +72,6 @@ public function testCache(): void
);
}

/** @test */
public function testSetPath(): void
{
$publicKey = new PublicKey();
Expand All @@ -98,7 +93,6 @@ public function testSetPath(): void
);
}

/** @test */
public function testUnSetPath(): void
{
$publicKey = new PublicKey();
Expand Down
2 changes: 0 additions & 2 deletions tests/ScopeCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ protected function setUp(): void
$this->scopeChecker = new ScopeChecker();
}

/** @test */
public function testTokenCan(): void
{
$request = $this->createAuthorizationRequest();
Expand All @@ -37,7 +36,6 @@ public function testTokenCan(): void
$this->assertTrue($result);
}

/** @test */
public function testTokenCanNot(): void
{
$request = $this->createAuthorizationRequest();
Expand Down

0 comments on commit 967a178

Please sign in to comment.