From 0e517b5a5829a0d31f01944003103cd05d3da815 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 7 Aug 2019 10:31:22 -0700 Subject: [PATCH] chore: update invalid credential error with more info (#24) * chore: update invalid credential error with more info * chore: update test suite with new error --- auth/sts.go | 3 ++- auth/sts_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/auth/sts.go b/auth/sts.go index 38a2523b..e09a719c 100644 --- a/auth/sts.go +++ b/auth/sts.go @@ -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) diff --git a/auth/sts_test.go b/auth/sts_test.go index c575a919..4a23b65e 100644 --- a/auth/sts_test.go +++ b/auth/sts_test.go @@ -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) }) }))