2015-03-13 18:33:17 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/http"
|
|
|
|
"github.com/hashicorp/vault/vault"
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
)
|
|
|
|
|
2015-04-20 19:11:21 +00:00
|
|
|
func TestStatus(t *testing.T) {
|
2015-03-13 18:33:17 +00:00
|
|
|
ui := new(cli.MockUi)
|
2015-04-20 19:11:21 +00:00
|
|
|
c := &StatusCommand{
|
2015-03-13 18:33:17 +00:00
|
|
|
Meta: Meta{
|
|
|
|
Ui: ui,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
core := vault.TestCore(t)
|
2015-03-24 23:20:05 +00:00
|
|
|
key, _ := vault.TestCoreInit(t, core)
|
2015-03-13 18:33:17 +00:00
|
|
|
ln, addr := http.TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
|
|
|
|
args := []string{"-address", addr}
|
2016-01-30 00:31:01 +00:00
|
|
|
if code := c.Run(args); code != 2 {
|
2015-03-13 18:33:17 +00:00
|
|
|
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
|
|
|
}
|
|
|
|
|
2015-03-16 00:10:33 +00:00
|
|
|
if _, err := core.Unseal(key); err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
2015-03-13 18:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if code := c.Run(args); code != 0 {
|
|
|
|
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
|
|
|
}
|
|
|
|
}
|