Skip to content

Commit 77c74ff

Browse files
committed
skip tests if OpenSSL is unable to generate tokens
1 parent e7e25e2 commit 77c74ff

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

Tests/Functional/AccessTokenTest.php

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,14 @@ public function testCustomUserLoader()
356356
*
357357
* @requires extension openssl
358358
*/
359-
public function testOidcSuccess(string $token)
359+
public function testOidcSuccess(callable $tokenFactory)
360360
{
361+
try {
362+
$token = $tokenFactory();
363+
} catch (\RuntimeException $e) {
364+
$this->markTestSkipped($e->getMessage());
365+
}
366+
361367
$client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_oidc.yml']);
362368
$client->request('GET', '/foo', [], [], ['HTTP_AUTHORIZATION' => \sprintf('Bearer %s', $token)]);
363369
$response = $client->getResponse();
@@ -372,8 +378,14 @@ public function testOidcSuccess(string $token)
372378
*
373379
* @requires extension openssl
374380
*/
375-
public function testOidcFailure(string $token)
381+
public function testOidcFailure(callable $tokenFactory)
376382
{
383+
try {
384+
$token = $tokenFactory();
385+
} catch (\RuntimeException $e) {
386+
$this->markTestSkipped($e->getMessage());
387+
}
388+
377389
$client = $this->createClient(['test_case' => 'AccessToken', 'root_config' => 'config_oidc.yml']);
378390
$client->request('GET', '/foo', [], [], ['HTTP_AUTHORIZATION' => \sprintf('Bearer %s', $token)]);
379391
$response = $client->getResponse();
@@ -444,12 +456,10 @@ public static function validAccessTokens(): array
444456
'sub' => 'e21bf182-1538-406e-8ccb-e25a17aba39f',
445457
'username' => 'dunglas',
446458
];
447-
$jws = self::createJws($claims);
448-
$jwe = self::createJwe($jws);
449459

450460
return [
451-
[$jws],
452-
[$jwe],
461+
[fn () => self::createJws($claims)],
462+
[fn () => self::createJwe(self::createJws($claims))],
453463
];
454464
}
455465

@@ -470,14 +480,14 @@ public static function invalidAccessTokens(): array
470480
];
471481

472482
return [
473-
[self::createJws([...$claims, 'aud' => 'Invalid Audience'])],
474-
[self::createJws([...$claims, 'iss' => 'Invalid Issuer'])],
475-
[self::createJws([...$claims, 'exp' => $time - 3600])],
476-
[self::createJws([...$claims, 'nbf' => $time + 3600])],
477-
[self::createJws([...$claims, 'iat' => $time + 3600])],
478-
[self::createJws([...$claims, 'username' => 'Invalid Username'])],
479-
[self::createJwe(self::createJws($claims), ['exp' => $time - 3600])],
480-
[self::createJwe(self::createJws($claims), ['cty' => 'x-specific'])],
483+
[fn () => self::createJws([...$claims, 'aud' => 'Invalid Audience'])],
484+
[fn () => self::createJws([...$claims, 'iss' => 'Invalid Issuer'])],
485+
[fn () => self::createJws([...$claims, 'exp' => $time - 3600])],
486+
[fn () => self::createJws([...$claims, 'nbf' => $time + 3600])],
487+
[fn () => self::createJws([...$claims, 'iat' => $time + 3600])],
488+
[fn () => self::createJws([...$claims, 'username' => 'Invalid Username'])],
489+
[fn () => self::createJwe(self::createJws($claims), ['exp' => $time - 3600])],
490+
[fn () => self::createJwe(self::createJws($claims), ['cty' => 'x-specific'])],
481491
];
482492
}
483493

0 commit comments

Comments
 (0)