mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 20:17:59 +00:00
Accept PUT as well as post to sys/mounts
This commit is contained in:
@@ -13,7 +13,7 @@ func handleSysMounts(core *vault.Core) http.Handler {
|
|||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case "GET":
|
||||||
handleSysListMounts(core).ServeHTTP(w, r)
|
handleSysListMounts(core).ServeHTTP(w, r)
|
||||||
case "POST":
|
case "PUT", "POST":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
handleSysMountUnmount(core, w, r)
|
handleSysMountUnmount(core, w, r)
|
||||||
@@ -27,8 +27,7 @@ func handleSysMounts(core *vault.Core) http.Handler {
|
|||||||
func handleSysRemount(core *vault.Core) http.Handler {
|
func handleSysRemount(core *vault.Core) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "POST":
|
case "PUT", "POST":
|
||||||
case "PUT":
|
|
||||||
default:
|
default:
|
||||||
respondError(w, http.StatusMethodNotAllowed, nil)
|
respondError(w, http.StatusMethodNotAllowed, nil)
|
||||||
return
|
return
|
||||||
@@ -80,7 +79,7 @@ func handleSysListMounts(core *vault.Core) http.Handler {
|
|||||||
|
|
||||||
func handleSysMountUnmount(core *vault.Core, w http.ResponseWriter, r *http.Request) {
|
func handleSysMountUnmount(core *vault.Core, w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "POST":
|
case "PUT", "POST":
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
default:
|
default:
|
||||||
respondError(w, http.StatusMethodNotAllowed, nil)
|
respondError(w, http.StatusMethodNotAllowed, nil)
|
||||||
@@ -100,7 +99,7 @@ func handleSysMountUnmount(core *vault.Core, w http.ResponseWriter, r *http.Requ
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "POST":
|
case "PUT", "POST":
|
||||||
handleSysMount(core, w, r, path)
|
handleSysMount(core, w, r, path)
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
handleSysUnmount(core, w, r, path)
|
handleSysUnmount(core, w, r, path)
|
||||||
|
|||||||
@@ -76,6 +76,22 @@ func TestSysMount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSysMount_put(t *testing.T) {
|
||||||
|
core, _, token := vault.TestCoreUnsealed(t)
|
||||||
|
ln, addr := TestServer(t, core)
|
||||||
|
defer ln.Close()
|
||||||
|
TestServerAuth(t, addr, token)
|
||||||
|
|
||||||
|
resp := testHttpPut(t, addr+"/v1/sys/mounts/foo", map[string]interface{}{
|
||||||
|
"type": "generic",
|
||||||
|
"description": "foo",
|
||||||
|
})
|
||||||
|
testResponseStatus(t, resp, 204)
|
||||||
|
|
||||||
|
// The TestSysMount test tests the thing is actually created. See that test
|
||||||
|
// for more info.
|
||||||
|
}
|
||||||
|
|
||||||
func TestSysRemount(t *testing.T) {
|
func TestSysRemount(t *testing.T) {
|
||||||
core, _, token := vault.TestCoreUnsealed(t)
|
core, _, token := vault.TestCoreUnsealed(t)
|
||||||
ln, addr := TestServer(t, core)
|
ln, addr := TestServer(t, core)
|
||||||
|
|||||||
Reference in New Issue
Block a user