Accept PUT as well as post to sys/mounts

This commit is contained in:
Seth Vargo
2015-06-16 13:02:15 -04:00
parent 2d865b831d
commit 24b9ef49c1
2 changed files with 20 additions and 5 deletions

View File

@@ -13,7 +13,7 @@ func handleSysMounts(core *vault.Core) http.Handler {
switch r.Method {
case "GET":
handleSysListMounts(core).ServeHTTP(w, r)
case "POST":
case "PUT", "POST":
fallthrough
case "DELETE":
handleSysMountUnmount(core, w, r)
@@ -27,8 +27,7 @@ func handleSysMounts(core *vault.Core) http.Handler {
func handleSysRemount(core *vault.Core) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "POST":
case "PUT":
case "PUT", "POST":
default:
respondError(w, http.StatusMethodNotAllowed, nil)
return
@@ -80,7 +79,7 @@ func handleSysListMounts(core *vault.Core) http.Handler {
func handleSysMountUnmount(core *vault.Core, w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "POST":
case "PUT", "POST":
case "DELETE":
default:
respondError(w, http.StatusMethodNotAllowed, nil)
@@ -100,7 +99,7 @@ func handleSysMountUnmount(core *vault.Core, w http.ResponseWriter, r *http.Requ
}
switch r.Method {
case "POST":
case "PUT", "POST":
handleSysMount(core, w, r, path)
case "DELETE":
handleSysUnmount(core, w, r, path)

View File

@@ -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) {
core, _, token := vault.TestCoreUnsealed(t)
ln, addr := TestServer(t, core)