Skip to content

Commit

Permalink
fixup! Handle missing env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew MacInnis authored and Drew MacInnis committed Nov 22, 2016
1 parent 3e775e9 commit b826f5e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 1 addition & 4 deletions vault/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func getAuthStrategy() AuthStrategy {
if auth := NewTokenAuthStrategy(); auth != nil {
return auth
}
logFatal("No vault auth strategy configured")
return nil
}

Expand Down Expand Up @@ -89,10 +90,6 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {

// Login - log in to Vault with the discovered auth backend and save the token
func (c *Client) Login() error {
if c.Auth == nil {
logFatal("No vault auth strategy configured")
return nil
}
token, err := c.Auth.GetToken(c.Addr)
if err != nil {
logFatal(err)
Expand Down
4 changes: 1 addition & 3 deletions vault/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ func TestLogin_NoAuthStrategy(t *testing.T) {
os.Setenv("HOME", "/tmp")
defer restoreLogFatal()
setupMockLogFatal()
c := NewClient()
assert.Nil(t, c.Auth)
c.Login()
_ = NewClient()
assert.Equal(t, "No vault auth strategy configured", spyLogFatalMsg)
}

Expand Down

0 comments on commit b826f5e

Please sign in to comment.