fix error type

This commit is contained in:
Haoran Wang 2017-07-04 17:20:52 +08:00
parent 4ae3b032f4
commit 45ec7d9f51
2 changed files with 4 additions and 4 deletions

View File

@ -33,7 +33,7 @@ const bearerProtocolPrefix = "base64url.bearer.authorization.k8s.io."
var protocolHeader = textproto.CanonicalMIMEHeaderKey("Sec-WebSocket-Protocol")
var invalidToken = errors.New("invalid bearer token")
var errInvalidToken = errors.New("invalid bearer token")
// ProtocolAuthenticator allows a websocket connection to provide a bearer token as a subprotocol
// in the format "base64url.bearer.authorization.<base64url-without-padding(bearer-token)>"
@ -102,7 +102,7 @@ func (a *ProtocolAuthenticator) AuthenticateRequest(req *http.Request) (user.Inf
// If the token authenticator didn't error, provide a default error
if !ok && err == nil {
err = invalidToken
err = errInvalidToken
}
return user, ok, err

View File

@ -59,8 +59,8 @@ func TestAuthenticateRequestTokenInvalid(t *testing.T) {
if ok || user != nil {
t.Errorf("expected not authenticated user")
}
if err != invalidToken {
t.Errorf("expected invalidToken error, got %v", err)
if err != errInvalidToken {
t.Errorf("expected errInvalidToken error, got %v", err)
}
}