vault: change to /sys/mounts
This commit is contained in:
parent
4161f7a440
commit
de1e28a77c
|
@ -87,7 +87,7 @@ func handleSysMount(
|
|||
|
||||
_, err := core.HandleRequest(&logical.Request{
|
||||
Operation: logical.WriteOperation,
|
||||
Path: "sys/mount/" + path,
|
||||
Path: "sys/mounts/" + path,
|
||||
Data: map[string]interface{}{
|
||||
"type": req.Type,
|
||||
"description": req.Description,
|
||||
|
@ -108,7 +108,7 @@ func handleSysUnmount(
|
|||
path string) {
|
||||
_, err := core.HandleRequest(&logical.Request{
|
||||
Operation: logical.DeleteOperation,
|
||||
Path: "sys/mount/" + path,
|
||||
Path: "sys/mounts/" + path,
|
||||
})
|
||||
if err != nil {
|
||||
respondError(w, http.StatusInternalServerError, err)
|
||||
|
|
|
@ -12,13 +12,13 @@ func NewSystemBackend(core *Core) logical.Backend {
|
|||
|
||||
return &framework.Backend{
|
||||
PathsRoot: []string{
|
||||
"mount/*",
|
||||
"mounts/*",
|
||||
"remount",
|
||||
},
|
||||
|
||||
Paths: []*framework.Path{
|
||||
&framework.Path{
|
||||
Pattern: "mounts",
|
||||
Pattern: "mounts$",
|
||||
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.ReadOperation: b.handleMountTable,
|
||||
|
@ -29,7 +29,7 @@ func NewSystemBackend(core *Core) logical.Backend {
|
|||
},
|
||||
|
||||
&framework.Path{
|
||||
Pattern: "mount/(?P<path>.+)",
|
||||
Pattern: "mounts/(?P<path>.+)",
|
||||
|
||||
Fields: map[string]*framework.FieldSchema{
|
||||
"path": &framework.FieldSchema{
|
||||
|
@ -129,7 +129,7 @@ func (b *SystemBackend) handleMount(
|
|||
// handleUnmount is used to unmount a path
|
||||
func (b *SystemBackend) handleUnmount(
|
||||
req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
suffix := strings.TrimPrefix(req.Path, "mount/")
|
||||
suffix := strings.TrimPrefix(req.Path, "mounts/")
|
||||
if len(suffix) == 0 {
|
||||
return logical.ErrorResponse("path cannot be blank"), logical.ErrInvalidRequest
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func TestSystemBackend_RootPaths(t *testing.T) {
|
||||
expected := []string{
|
||||
"mount/*",
|
||||
"mounts/*",
|
||||
"remount",
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ func TestSystemBackend_mounts(t *testing.T) {
|
|||
func TestSystemBackend_mount(t *testing.T) {
|
||||
b := testSystemBackend(t)
|
||||
|
||||
req := logical.TestRequest(t, logical.WriteOperation, "mount/prod/secret/")
|
||||
req := logical.TestRequest(t, logical.WriteOperation, "mounts/prod/secret/")
|
||||
req.Data["type"] = "generic"
|
||||
|
||||
resp, err := b.HandleRequest(req)
|
||||
|
@ -61,7 +61,7 @@ func TestSystemBackend_mount(t *testing.T) {
|
|||
func TestSystemBackend_mount_invalid(t *testing.T) {
|
||||
b := testSystemBackend(t)
|
||||
|
||||
req := logical.TestRequest(t, logical.WriteOperation, "mount/prod/secret/")
|
||||
req := logical.TestRequest(t, logical.WriteOperation, "mounts/prod/secret/")
|
||||
req.Data["type"] = "nope"
|
||||
resp, err := b.HandleRequest(req)
|
||||
if err != logical.ErrInvalidRequest {
|
||||
|
@ -75,7 +75,7 @@ func TestSystemBackend_mount_invalid(t *testing.T) {
|
|||
func TestSystemBackend_unmount(t *testing.T) {
|
||||
b := testSystemBackend(t)
|
||||
|
||||
req := logical.TestRequest(t, logical.DeleteOperation, "mount/secret/")
|
||||
req := logical.TestRequest(t, logical.DeleteOperation, "mounts/secret/")
|
||||
resp, err := b.HandleRequest(req)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -88,7 +88,7 @@ func TestSystemBackend_unmount(t *testing.T) {
|
|||
func TestSystemBackend_unmount_invalid(t *testing.T) {
|
||||
b := testSystemBackend(t)
|
||||
|
||||
req := logical.TestRequest(t, logical.DeleteOperation, "mount/foo/")
|
||||
req := logical.TestRequest(t, logical.DeleteOperation, "mounts/foo/")
|
||||
resp, err := b.HandleRequest(req)
|
||||
if err != logical.ErrInvalidRequest {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
|
Loading…
Reference in New Issue