mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-16 06:51:23 +01:00
http: /sys/seal-status should return 400 if still uninitialized
This commit is contained in:
parent
5102c89221
commit
e657ac8b52
@ -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,
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user