Fix mount config test by proxying mounts/ in addition to mounts

This commit is contained in:
Jeff Mitchell
2015-09-03 08:54:59 -04:00
parent 0df0df2fcb
commit 205ef29a59
3 changed files with 19 additions and 17 deletions

View File

@@ -25,6 +25,7 @@ func Handler(core *vault.Core) http.Handler {
mux.Handle("/v1/sys/seal", handleSysSeal(core))
mux.Handle("/v1/sys/unseal", handleSysUnseal(core))
mux.Handle("/v1/sys/mounts", proxySysRequest(core))
mux.Handle("/v1/sys/mounts/", proxySysRequest(core))
mux.Handle("/v1/sys/remount", proxySysRequest(core))
mux.Handle("/v1/sys/policy", handleSysListPolicies(core))
mux.Handle("/v1/sys/policy/", handleSysPolicy(core))

View File

@@ -317,6 +317,7 @@ func TestSysTuneMount(t *testing.T) {
},
},
}
testResponseStatus(t, resp, 200)
testResponseBody(t, resp, &actual)
@@ -325,14 +326,14 @@ func TestSysTuneMount(t *testing.T) {
}
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/foo/tune")
actual = map[string]interface{}{}
expected = map[string]interface{}{
"foo/": map[string]interface{}{
"config": map[string]interface{}{
"default_lease_ttl": float64(time.Duration(time.Hour * 71999)),
"max_lease_ttl": float64(time.Duration(time.Hour * 72000)),
},
"config": map[string]interface{}{
"default_lease_ttl": float64(time.Duration(time.Hour * 71999)),
"max_lease_ttl": float64(time.Duration(time.Hour * 72000)),
},
}
testResponseStatus(t, resp, 200)
testResponseBody(t, resp, &actual)

View File

@@ -44,17 +44,6 @@ func NewSystemBackend(core *Core) logical.Backend {
},
Paths: []*framework.Path{
&framework.Path{
Pattern: "mounts$",
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.handleMountTable,
},
HelpSynopsis: strings.TrimSpace(sysHelp["mounts"][0]),
HelpDescription: strings.TrimSpace(sysHelp["mounts"][1]),
},
&framework.Path{
Pattern: "mounts/(?P<path>.+?)/tune$",
@@ -109,6 +98,17 @@ func NewSystemBackend(core *Core) logical.Backend {
HelpDescription: strings.TrimSpace(sysHelp["mount"][1]),
},
&framework.Path{
Pattern: "mounts$",
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.handleMountTable,
},
HelpSynopsis: strings.TrimSpace(sysHelp["mounts"][0]),
HelpDescription: strings.TrimSpace(sysHelp["mounts"][1]),
},
&framework.Path{
Pattern: "remount",
@@ -530,7 +530,7 @@ func (b *SystemBackend) handleMountTune(
"unable to convert given mount config information: %s", err)),
logical.ErrInvalidRequest
}
// Attempt tune
if err := b.Core.tuneMount(path, config); err != nil {
b.Backend.Logger().Printf("[ERR] sys: tune of path '%s' failed: %v", path, err)