66 "testing"
77
88 "github.com/google/go-cmp/cmp"
9- "gopkg.in/square/go-jose.v2"
109 "gopkg.in/square/go-jose.v2/jwt"
1110)
1211
@@ -30,7 +29,7 @@ func TestValidator_ValidateToken(t *testing.T) {
3029 name string
3130 token string
3231 keyFunc func (context.Context ) (interface {}, error )
33- algorithm jose. SignatureAlgorithm
32+ algorithm string
3433 customClaims CustomClaims
3534 expectedError error
3635 expectedContext * UserContext
@@ -73,7 +72,7 @@ func TestValidator_ValidateToken(t *testing.T) {
7372 keyFunc : func (context.Context ) (interface {}, error ) {
7473 return []byte ("secret" ), nil
7574 },
76- algorithm : jose . RS256 ,
75+ algorithm : " RS256" ,
7776 expectedError : errors .New (`expected "RS256" signing algorithm but token specified "HS256"` ),
7877 },
7978 {
@@ -93,7 +92,7 @@ func TestValidator_ValidateToken(t *testing.T) {
9392 expectedError : errors .New ("error getting the keys from the key func: key func error message" ),
9493 },
9594 {
96- name : "it throws an error when it fails to deserialize the claims" ,
95+ name : "it throws an error when it fails to deserialize the claims because the signature is invalid " ,
9796 token : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2dvLWp3dC1taWRkbGV3YXJlLmV1LmF1dGgwLmNvbS8iLCJzdWIiOiIxMjM0NTY3ODkwIiwiYXVkIjpbImh0dHBzOi8vZ28tand0LW1pZGRsZXdhcmUtYXBpLyJdfQ.vR2K2tZHDrgsEh9zNWcyk4aljtR6gZK0s2anNGlfwz0" ,
9897 keyFunc : func (context.Context ) (interface {}, error ) {
9998 return []byte ("secret" ), nil
@@ -124,14 +123,14 @@ func TestValidator_ValidateToken(t *testing.T) {
124123 for _ , testCase := range testCases {
125124 t .Run (testCase .name , func (t * testing.T ) {
126125 if testCase .algorithm == "" {
127- testCase .algorithm = jose . HS256
126+ testCase .algorithm = " HS256"
128127 }
129128
130129 validator , err := New (
131130 testCase .keyFunc ,
132131 testCase .algorithm ,
133132 issuer ,
134- jwt. Audience {audience },
133+ [] string {audience },
135134 WithCustomClaims (testCase .customClaims ),
136135 )
137136 if err != nil {
0 commit comments