You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: strategy_jwt_test.go
    path of file: ./repos/fosite/handler/oauth2
    
    the code of the file until where you have to start completion: // Copyright Â© 2024 Ory Corp
// SPDX-License-Identifier: Apache-2.0

package oauth2

import (
	"context"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"strings"
	"testing"
	"time"

	"github.com/ory/fosite/internal/gen"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"

	"github.com/ory/fosite"
	"github.com/ory/fosite/token/jwt"
)

var rsaKey = gen.MustRSAKey()
var j = &DefaultJWTStrategy{
	Signer: &jwt.DefaultSigner{
		GetPrivateKey: func(_ cont
    
func TestAccessToken(t *testing.T) {
	for s, scopeField := range []jwt.JWTScopeFieldEnum{
		jwt.JWTScopeFieldList,
		jwt.JWTScopeFieldString,
		jwt.JWTScopeFieldBoth,
	} {
		for k, c := range []struct {
			r    *fosite.Request
			pass bool
		}{
			{
				r:    jwtValidCase(fosite.AccessToken),
				pass: true,
			},
			{
				r:    jwtExpiredCase(fosite.AccessToken),
				pass: false,
			},
			{
				r:    jwtValidCaseWithZeroRefreshExpiry(fosite.AccessToken),
				pass: true,
			},
			{
				r:    jwtValidCaseWithRefreshExpiry(fosite.AccessToken),
				pass: true,
			},
		} {
			t.Run(fmt.Sprintf("case=%d/%d", s, k), func(t *testing.T) {
				j.Config = &fosite.Config{
					JWTScopeClaimKey: scopeField,
				}
				token, signature, err := j.GenerateAccessToken(context.Background(), c.r)
				assert.NoError(t, err)

				parts := strings.Split(token, ".")
				require.Len(t, parts, 3, "%s - %v", token, parts)
				assert.Equal(t, parts[2], signature)

				rawPayload, err := base64.RawURLEncoding.DecodeString(parts[1])
				require.NoError(t, err)
				var payload map[string]interface{}
				err = json.Unmarshal(rawPayload, &payload)
				require.NoError(t, err)
				if scopeField == jwt.JWTScopeFieldList || scopeField == jwt.JWTScopeFieldBoth {
					scope, ok := payload["scp"]
					require.True(t, ok)
					assert.Equal(t, []interface{}{"email", "offline"}, scope)
				}
				if scopeField == jwt.JWTScopeFieldString || scopeField == jwt.JWTScopeFieldBoth {
					scope, ok := payload["scope"]
					require.True(t, ok)
					assert.Equal(t, "email offline", scope)
				}

				extraClaimsSession, ok := c.r.GetSession().(fosite.ExtraClaimsSession)
				require.True(t, ok)
				claims := extraClaimsSession.GetExtraClaims()
				assert.Equal(t, "bar", claims["foo"])
				// Returned, but will be ignored by the introspect handler.
				assert.Equal(t, "peter", claims["sub"])
				assert.Equal(t, []string{"group0"}, claims["aud"])
				// Scope field is always a string.
				assert.Equal(t, "email offline", claims["scope"])

				validate := j.signature(token)
				err = j.ValidateAccessToken(context.Background(), c.r, token)
				if c.pass {
					assert.NoError(t, err)
					assert.Equal(t, signature, validate)
				} else {
					assert.Error(t, err)
				}
			})
		}
	}
}