@@ -37,8 +37,8 @@ func (k *keyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
3737
3838type signingKey struct {
3939 keyID string // optional
40- priv interface {}
41- pub interface {}
40+ priv any
41+ pub any
4242 alg jose.SignatureAlgorithm
4343}
4444
@@ -173,8 +173,7 @@ func TestKeyVerifyContextCanceled(t *testing.T) {
173173}
174174
175175func testKeyVerify (t * testing.T , good , bad * signingKey , verification ... * signingKey ) {
176- ctx , cancel := context .WithCancel (context .Background ())
177- defer cancel ()
176+ ctx := t .Context ()
178177
179178 keySet := jose.JSONWebKeySet {}
180179 for _ , v := range verification {
@@ -222,8 +221,7 @@ func testKeyVerify(t *testing.T, good, bad *signingKey, verification ...*signing
222221}
223222
224223func TestRotation (t * testing.T ) {
225- ctx , cancel := context .WithCancel (context .Background ())
226- defer cancel ()
224+ ctx := t .Context ()
227225
228226 key1 := newRSAKey (t )
229227 key2 := newRSAKey (t )
@@ -287,8 +285,7 @@ func TestRotation(t *testing.T) {
287285}
288286
289287func TestUpdateKeysSendsCacheControlNoCache (t * testing.T ) {
290- ctx , cancel := context .WithCancel (context .Background ())
291- defer cancel ()
288+ ctx := t .Context ()
292289
293290 key := newRSAKey (t )
294291 var requestHeaders []http.Header
@@ -325,21 +322,19 @@ func TestUpdateKeysSendsCacheControlNoCache(t *testing.T) {
325322 }
326323}
327324
328-
329325func BenchmarkVerify (b * testing.B ) {
330- ctx , cancel := context .WithCancel (context .Background ())
331- defer cancel ()
326+ ctx := b .Context ()
332327
333328 key := newRSAKey (b )
334329
335330 now := time .Date (2022 , 1 , 29 , 0 , 0 , 0 , 0 , time .UTC )
336331 exp := now .Add (time .Hour )
337- payload := [] byte ( fmt .Sprintf ( `{
332+ payload := fmt .Appendf ( nil , `{
338333 "iss": "https://example.com",
339334 "sub": "test_user",
340335 "aud": "test_client_id",
341336 "exp": %d
342- }` , exp .Unix ()))
337+ }` , exp .Unix ())
343338
344339 idToken := key .sign (b , payload )
345340 server := & keyServer {
@@ -361,8 +356,7 @@ func BenchmarkVerify(b *testing.B) {
361356 b .Fatalf ("verifying id token: %v" , err )
362357 }
363358
364- b .ResetTimer ()
365- for i := 0 ; i < b .N ; i ++ {
359+ for b .Loop () {
366360 if _ , err := verifier .Verify (ctx , idToken ); err != nil {
367361 b .Fatalf ("verifying id token: %v" , err )
368362 }
0 commit comments