@@ -356,8 +356,14 @@ public function testCustomUserLoader()
356
356
*
357
357
* @requires extension openssl
358
358
*/
359
- public function testOidcSuccess (string $ token )
359
+ public function testOidcSuccess (callable $ tokenFactory )
360
360
{
361
+ try {
362
+ $ token = $ tokenFactory ();
363
+ } catch (\RuntimeException $ e ) {
364
+ $ this ->markTestSkipped ($ e ->getMessage ());
365
+ }
366
+
361
367
$ client = $ this ->createClient (['test_case ' => 'AccessToken ' , 'root_config ' => 'config_oidc.yml ' ]);
362
368
$ client ->request ('GET ' , '/foo ' , [], [], ['HTTP_AUTHORIZATION ' => \sprintf ('Bearer %s ' , $ token )]);
363
369
$ response = $ client ->getResponse ();
@@ -372,8 +378,14 @@ public function testOidcSuccess(string $token)
372
378
*
373
379
* @requires extension openssl
374
380
*/
375
- public function testOidcFailure (string $ token )
381
+ public function testOidcFailure (callable $ tokenFactory )
376
382
{
383
+ try {
384
+ $ token = $ tokenFactory ();
385
+ } catch (\RuntimeException $ e ) {
386
+ $ this ->markTestSkipped ($ e ->getMessage ());
387
+ }
388
+
377
389
$ client = $ this ->createClient (['test_case ' => 'AccessToken ' , 'root_config ' => 'config_oidc.yml ' ]);
378
390
$ client ->request ('GET ' , '/foo ' , [], [], ['HTTP_AUTHORIZATION ' => \sprintf ('Bearer %s ' , $ token )]);
379
391
$ response = $ client ->getResponse ();
@@ -444,12 +456,10 @@ public static function validAccessTokens(): array
444
456
'sub ' => 'e21bf182-1538-406e-8ccb-e25a17aba39f ' ,
445
457
'username ' => 'dunglas ' ,
446
458
];
447
- $ jws = self ::createJws ($ claims );
448
- $ jwe = self ::createJwe ($ jws );
449
459
450
460
return [
451
- [$ jws ],
452
- [$ jwe ],
461
+ [fn () => self :: createJws ( $ claims ) ],
462
+ [fn () => self :: createJwe ( self :: createJws ( $ claims )) ],
453
463
];
454
464
}
455
465
@@ -470,14 +480,14 @@ public static function invalidAccessTokens(): array
470
480
];
471
481
472
482
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 ' ])],
481
491
];
482
492
}
483
493
0 commit comments