mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
Merge pull request #82 from DavidWittman/75-auth-revoked-token
Check for invalid token when authing via cli
This commit is contained in:
commit
8c7771f299
2 changed files with 27 additions and 0 deletions
|
|
@ -151,6 +151,10 @@ func (c *AuthCommand) Run(args []string) int {
|
|||
"Error validating token: %s", err))
|
||||
return 1
|
||||
}
|
||||
if secret == nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error: Invalid token"))
|
||||
return 1
|
||||
}
|
||||
|
||||
// Get the policies we have
|
||||
policiesRaw, ok := secret.Data["policies"]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue