Skip to content

Commit

Permalink
http: /sys/seal-status should return 400 if still uninitialized
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Mar 31, 2015
1 parent 5102c89 commit e657ac8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions http/sys_seal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package http
import (
"encoding/hex"
"errors"
"fmt"
"net/http"

"github.com/hashicorp/errwrap"
Expand Down Expand Up @@ -92,6 +93,11 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req
respondError(w, http.StatusInternalServerError, err)
return
}
if sealConfig == nil {
respondError(w, http.StatusBadRequest, fmt.Errorf(
"server is not yet initialized"))
return
}

respondOk(w, &SealStatusResponse{
Sealed: sealed,
Expand Down
12 changes: 12 additions & 0 deletions http/sys_seal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ func TestSysSealStatus(t *testing.T) {
}
}

func TestSysSealStatus_uninit(t *testing.T) {
core := vault.TestCore(t)
ln, addr := TestServer(t, core)
defer ln.Close()

resp, err := http.Get(addr + "/v1/sys/seal-status")
if err != nil {
t.Fatalf("err: %s", err)
}
testResponseStatus(t, resp, 400)
}

func TestSysSeal(t *testing.T) {
core := vault.TestCore(t)
vault.TestCoreInit(t, core)
Expand Down

0 comments on commit e657ac8

Please sign in to comment.