http: /sys/seal-status should return 400 if still uninitialized

This commit is contained in:
Mitchell Hashimoto 2015-03-30 23:36:03 -07:00
parent 5102c89221
commit e657ac8b52
2 changed files with 18 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package http
import (
"encoding/hex"
"errors"
"fmt"
"net/http"
"github.com/hashicorp/errwrap"
@ -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,

View File

@ -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)