diff --git a/command/write_test.go b/command/write_test.go index 6e719ef8c..ce570f373 100644 --- a/command/write_test.go +++ b/command/write_test.go @@ -4,6 +4,7 @@ import ( "io" "io/ioutil" "os" + "strings" "testing" "github.com/hashicorp/vault/http" @@ -219,3 +220,29 @@ func TestWrite_fileValue(t *testing.T) { t.Fatalf("bad: %#v", resp) } } + +func TestWrite_Output(t *testing.T) { + core, _, token := vault.TestCoreUnsealed(t) + ln, addr := http.TestServer(t, core) + defer ln.Close() + + ui := new(cli.MockUi) + c := &WriteCommand{ + Meta: Meta{ + ClientToken: token, + Ui: ui, + }, + } + + args := []string{ + "-address", addr, + "auth/token/create", + "display_name=foo", + } + if code := c.Run(args); code != 0 { + t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) + } + if !strings.Contains(string(ui.OutputWriter.Bytes()), "Key") { + t.Fatalf("bad: %s", string(ui.OutputWriter.Bytes())) + } +}