Package list golang-github-go-kit-kit / e32d2aa
Added tests for the type of error returned Brian Kassouf 5 years ago
2 changed file(s) with 13 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1818 var (
1919 ErrTokenContextMissing = errors.New("Token up for parsing was not passed through the context")
2020 ErrTokenInvalid = errors.New("JWT Token was invalid")
21 ErrUnexpectedSigningMethod = errors.New("Unexptected signing method")
21 ErrUnexpectedSigningMethod = errors.New("Unexpected signing method")
2222 ErrKIDNotFound = errors.New("Key ID was not found in key set")
2323 ErrNoKIDHeader = errors.New("Token doesn't have 'kid' header")
2424 )
8989 return key.Key, nil
9090 })
9191 if err != nil {
92 if e, ok := err.(*jwt.ValidationError); ok && e.Inner != nil {
93 return nil, e.Inner
94 }
95
9296 return nil, err
9397 }
9498
6161 t.Error("Parser should have returned an error")
6262 }
6363
64 if err != ErrTokenContextMissing {
65 t.Errorf("unexpected error returned, expected: %s got: %s", ErrTokenContextMissing, err)
66 }
67
6468 // Invalid Token is passed into the parser
6569 ctx := context.WithValue(context.Background(), JWTTokenContextKey, invalidKey)
6670 _, err = parser(ctx, struct{}{})
8185 _, err = badParser(ctx, struct{}{})
8286 if err == nil {
8387 t.Error("Parser should have returned an error")
88 }
89
90 if err != ErrUnexpectedSigningMethod {
91 t.Errorf("unexpected error returned, expected: %s got: %s", ErrUnexpectedSigningMethod, err)
8492 }
8593
8694 // Invalid key is used in the parser