From bddccf6ead84dd3b6c91fed1c2e1b89e77ea8cce Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Thu, 7 Apr 2022 16:03:27 -0500 Subject: [PATCH] add http status check to authenticate --- authn/authenticate.go | 3 +++ authn/authenticate_internal_test.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/authn/authenticate.go b/authn/authenticate.go index a83d552c4..5cc1d64aa 100644 --- a/authn/authenticate.go +++ b/authn/authenticate.go @@ -129,6 +129,9 @@ func (a *Auth) Authenticate(ctx context.Context, bearer string) (*UserInfo, erro if err != nil { return nil, errors.Wrap(err, "refreshing token") } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("refreshing token: %s", resp.Status) + } defer resp.Body.Close() var t oauth2.Token if err := json.NewDecoder(resp.Body).Decode(&t); err != nil { diff --git a/authn/authenticate_internal_test.go b/authn/authenticate_internal_test.go index ca60b4c72..305c0af58 100644 --- a/authn/authenticate_internal_test.go +++ b/authn/authenticate_internal_test.go @@ -198,7 +198,7 @@ func TestAuthenticate(t *testing.T) { refresh: true, errOnRefresh: true, exp: -17764800, - err: fmt.Errorf("decoding refreshed token: invalid character 'b' looking for beginning of value"), + err: fmt.Errorf("refreshing token: 500 Internal Server Error"), }, } for _, test := range cases {