mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-17 07:21:18 +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 (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/hashicorp/errwrap"
|
"github.com/hashicorp/errwrap"
|
||||||
@ -92,6 +93,11 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req
|
|||||||
respondError(w, http.StatusInternalServerError, err)
|
respondError(w, http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if sealConfig == nil {
|
||||||
|
respondError(w, http.StatusBadRequest, fmt.Errorf(
|
||||||
|
"server is not yet initialized"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
respondOk(w, &SealStatusResponse{
|
respondOk(w, &SealStatusResponse{
|
||||||
Sealed: sealed,
|
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) {
|
func TestSysSeal(t *testing.T) {
|
||||||
core := vault.TestCore(t)
|
core := vault.TestCore(t)
|
||||||
vault.TestCoreInit(t, core)
|
vault.TestCoreInit(t, core)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user