Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
chore: update invalid credential error with more info (#24)
Browse files Browse the repository at this point in the history
* chore: update invalid credential error with more info

* chore: update test suite with new error
  • Loading branch information
davidzhao98 authored and fieldju committed Aug 7, 2019
1 parent 228ce8b commit 0e517b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion auth/sts.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func (a *STSAuth) authenticate() error {
defer response.Body.Close()

if response.StatusCode == http.StatusUnauthorized || response.StatusCode == http.StatusForbidden {
return api.ErrorUnauthorized
return fmt.Errorf("Invalid credentials given. Verify that the role you are currently using is valid " +
"with the AWS CLI ($ aws sts get-caller-identity) or with gimme-aws-creds.")
}
if response.StatusCode != http.StatusOK {
return fmt.Errorf("Error while trying to authenticate. Got HTTP response code %d", response.StatusCode)
Expand Down
2 changes: 1 addition & 1 deletion auth/sts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestGetTokenSTS(t *testing.T) {
os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
Convey("Should error with invalid login", func() {
tok, err := a.GetToken(nil)
So(err, ShouldEqual, api.ErrorUnauthorized)
So(err, ShouldNotBeNil)
So(tok, ShouldBeEmpty)
})
}))
Expand Down

0 comments on commit 0e517b5

Please sign in to comment.