Check for invalid token when authing via cli

If a token does not exist, the Read request returns without an
error, but the secret returned is `nil`, so we need to check for
that.

Closes #75
This commit is contained in:
David Wittman
2015-04-28 21:23:26 -05:00
parent f61e0b120a
commit e4ffd4ac27
2 changed files with 27 additions and 0 deletions

View File

@@ -82,6 +82,29 @@ func TestAuth_token(t *testing.T) {
}
}
func TestAuth_badToken(t *testing.T) {
core, _, _ := vault.TestCoreUnsealed(t)
ln, addr := http.TestServer(t, core)
defer ln.Close()
testAuthInit(t)
ui := new(cli.MockUi)
c := &AuthCommand{
Meta: Meta{
Ui: ui,
},
}
args := []string{
"-address", addr,
"not-a-valid-token",
}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
}
}
func TestAuth_method(t *testing.T) {
core, _, token := vault.TestCoreUnsealed(t)
ln, addr := http.TestServer(t, core)