mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
add http status check to authenticate
This commit is contained in:
parent
eea6a40fe0
commit
bddccf6ead
2 changed files with 4 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue