2323use Symfony \Component \Security \Http \AccessToken \Oidc \OidcTokenHandler ;
2424use Symfony \Component \Security \Http \Authenticator \Passport \Badge \UserBadge ;
2525
26+ /**
27+ * @requires extension openssl
28+ */
2629class OidcTokenHandlerTest extends TestCase
2730{
2831 private const AUDIENCE = 'Symfony OIDC ' ;
@@ -64,7 +67,7 @@ public function testGetsUserIdentifierFromSignedToken(string $claim, string $exp
6467 $ this ->assertEquals ($ claims ['sub ' ], $ actualUser ->getUserIdentifier ());
6568 }
6669
67- public function getClaims (): iterable
70+ public static function getClaims (): iterable
6871 {
6972 yield ['sub ' , 'e21bf182-1538-406e-8ccb-e25a17aba39f ' ];
7073 yield ['email ' , 'foo@example.com ' ];
@@ -90,13 +93,13 @@ public function testThrowsAnErrorIfTokenIsInvalid(string $token)
9093 ))->getUserBadgeFrom ($ token );
9194 }
9295
93- public function getInvalidTokens (): iterable
96+ public static function getInvalidTokens (): iterable
9497 {
9598 // Invalid token
9699 yield ['invalid ' ];
97100 // Token is expired
98101 yield [
99- $ this -> buildJWS (json_encode ([
102+ self :: buildJWS (json_encode ([
100103 'iat ' => time () - 3600 ,
101104 'nbf ' => time () - 3600 ,
102105 'exp ' => time () - 3590 ,
@@ -108,7 +111,7 @@ public function getInvalidTokens(): iterable
108111 ];
109112 // Invalid audience
110113 yield [
111- $ this -> buildJWS (json_encode ([
114+ self :: buildJWS (json_encode ([
112115 'iat ' => time (),
113116 'nbf ' => time (),
114117 'exp ' => time () + 3590 ,
@@ -141,25 +144,25 @@ public function testThrowsAnErrorIfUserPropertyIsMissing()
141144
142145 (new OidcTokenHandler (
143146 new ES256 (),
144- $ this -> getJWK (),
147+ self :: getJWK (),
145148 $ loggerMock ,
146149 'email ' ,
147150 self ::AUDIENCE
148151 ))->getUserBadgeFrom ($ token );
149152 }
150153
151- private function buildJWS (string $ payload ): string
154+ private static function buildJWS (string $ payload ): string
152155 {
153156 return (new CompactSerializer ())->serialize ((new JWSBuilder (new AlgorithmManager ([
154157 new ES256 (),
155158 ])))->create ()
156159 ->withPayload ($ payload )
157- ->addSignature ($ this -> getJWK (), ['alg ' => 'ES256 ' ])
160+ ->addSignature (self :: getJWK (), ['alg ' => 'ES256 ' ])
158161 ->build ()
159162 );
160163 }
161164
162- private function getJWK (): JWK
165+ private static function getJWK (): JWK
163166 {
164167 // tip: use https://mkjwk.org/ to generate a JWK
165168 return new JWK ([
0 commit comments