Skip to content

Commit

Permalink
fix tests and instantiate
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed Aug 2, 2024
1 parent 1378353 commit 012a151
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
}

switch have := got.(type) {
case VerificationKeySet:
case VerificationKeySet[VerificationKey]:
if len(have.Keys) == 0 {
return token, newError("keyfunc returned empty verification key set", ErrTokenUnverifiable)
}
Expand Down
14 changes: 9 additions & 5 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,26 @@ var (
nilKeyFunc jwt.Keyfunc = nil
multipleZeroKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) { return []interface{}{}, nil }
multipleEmptyKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) {
return jwt.VerificationKeySet{Keys: []jwt.VerificationKey{nil, nil}}, nil
keys := []jwt.VerificationKey{nil, nil}
return jwt.VerificationKeySet[jwt.VerificationKey]{Keys: keys}, nil
}
multipleVerificationKeysFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) {
return []jwt.VerificationKey{jwtTestDefaultKey, jwtTestEC256PublicKey}, nil
}
multipleLastKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) {
return jwt.VerificationKeySet{Keys: []jwt.VerificationKey{jwtTestEC256PublicKey, jwtTestDefaultKey}}, nil
keys := []jwt.VerificationKey{jwtTestEC256PublicKey, jwtTestDefaultKey}
return jwt.VerificationKeySet[jwt.VerificationKey]{Keys: keys}, nil
}
multipleFirstKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) {
return jwt.VerificationKeySet{Keys: []jwt.VerificationKey{jwtTestDefaultKey, jwtTestEC256PublicKey}}, nil
keys := []jwt.VerificationKey{jwtTestDefaultKey, jwtTestEC256PublicKey}
return jwt.VerificationKeySet[jwt.VerificationKey]{Keys: keys}, nil
}
multipleAltTypedKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) {
return jwt.VerificationKeySet{Keys: []jwt.VerificationKey{jwtTestDefaultKey, jwtTestDefaultKey}}, nil
keys := []jwt.VerificationKey{jwtTestDefaultKey, jwtTestDefaultKey}
return jwt.VerificationKeySet[jwt.VerificationKey]{Keys: keys}, nil
}
emptyVerificationKeySetFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) {
return jwt.VerificationKeySet{}, nil
return jwt.VerificationKeySet[jwt.VerificationKey]{}, nil
}
)

Expand Down

0 comments on commit 012a151

Please sign in to comment.