From 45ec7d9f51c54c8312579c9a0eab83c29d6d7d06 Mon Sep 17 00:00:00 2001 From: Haoran Wang Date: Tue, 4 Jul 2017 17:20:52 +0800 Subject: [PATCH] fix error type --- .../pkg/authentication/request/websocket/protocol.go | 4 ++-- .../pkg/authentication/request/websocket/protocol_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol.go b/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol.go index e007bf2d57f..4a30bb6359c 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol.go @@ -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." @@ -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 diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol_test.go b/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol_test.go index 2a21aa65d92..62800a40d9d 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol_test.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/request/websocket/protocol_test.go @@ -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) } }