From edde6ed16036e0a64023e95289b959beb1d2962e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 31 Mar 2015 11:46:55 -0700 Subject: [PATCH] command/seal: test should use the token --- api/sys_seal.go | 4 +++- command/seal_test.go | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/sys_seal.go b/api/sys_seal.go index af4a39ae2a..cfff0f6192 100644 --- a/api/sys_seal.go +++ b/api/sys_seal.go @@ -16,7 +16,9 @@ func (c *Sys) SealStatus() (*SealStatusResponse, error) { func (c *Sys) Seal() error { r := c.c.NewRequest("PUT", "/v1/sys/seal") resp, err := c.c.RawRequest(r) - defer resp.Body.Close() + if err == nil { + defer resp.Body.Close() + } return err } diff --git a/command/seal_test.go b/command/seal_test.go index cbbd099c1d..a2b006f630 100644 --- a/command/seal_test.go +++ b/command/seal_test.go @@ -9,14 +9,15 @@ import ( ) func TestSeal(t *testing.T) { - core, _, _ := vault.TestCoreUnsealed(t) + core, _, token := vault.TestCoreUnsealed(t) ln, addr := http.TestServer(t, core) defer ln.Close() ui := new(cli.MockUi) c := &SealCommand{ Meta: Meta{ - Ui: ui, + ClientToken: token, + Ui: ui, }, }