Merge pull request #48464 from wanghaoran1988/fix_err_type

Automatic merge from submit-queue (batch tested with PRs 47700, 48464, 48502)

fix error type

**What this PR does / why we need it**:
invalidToken should be errInvalideToken
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:
No
**Release note**:
```
None
```
pull/6/head
Kubernetes Submit Queue 2017-07-05 13:27:45 -07:00 committed by GitHub
commit d630c0b6b1
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)
}
}