vault: change to /sys/mounts

This commit is contained in:
Mitchell Hashimoto 2015-03-16 10:52:35 -07:00
parent 4161f7a440
commit de1e28a77c
3 changed files with 11 additions and 11 deletions

View File

@ -87,7 +87,7 @@ func handleSysMount(
_, err := core.HandleRequest(&logical.Request{ _, err := core.HandleRequest(&logical.Request{
Operation: logical.WriteOperation, Operation: logical.WriteOperation,
Path: "sys/mount/" + path, Path: "sys/mounts/" + path,
Data: map[string]interface{}{ Data: map[string]interface{}{
"type": req.Type, "type": req.Type,
"description": req.Description, "description": req.Description,
@ -108,7 +108,7 @@ func handleSysUnmount(
path string) { path string) {
_, err := core.HandleRequest(&logical.Request{ _, err := core.HandleRequest(&logical.Request{
Operation: logical.DeleteOperation, Operation: logical.DeleteOperation,
Path: "sys/mount/" + path, Path: "sys/mounts/" + path,
}) })
if err != nil { if err != nil {
respondError(w, http.StatusInternalServerError, err) respondError(w, http.StatusInternalServerError, err)

View File

@ -12,13 +12,13 @@ func NewSystemBackend(core *Core) logical.Backend {
return &framework.Backend{ return &framework.Backend{
PathsRoot: []string{ PathsRoot: []string{
"mount/*", "mounts/*",
"remount", "remount",
}, },
Paths: []*framework.Path{ Paths: []*framework.Path{
&framework.Path{ &framework.Path{
Pattern: "mounts", Pattern: "mounts$",
Callbacks: map[logical.Operation]framework.OperationFunc{ Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.handleMountTable, logical.ReadOperation: b.handleMountTable,
@ -29,7 +29,7 @@ func NewSystemBackend(core *Core) logical.Backend {
}, },
&framework.Path{ &framework.Path{
Pattern: "mount/(?P<path>.+)", Pattern: "mounts/(?P<path>.+)",
Fields: map[string]*framework.FieldSchema{ Fields: map[string]*framework.FieldSchema{
"path": &framework.FieldSchema{ "path": &framework.FieldSchema{
@ -129,7 +129,7 @@ func (b *SystemBackend) handleMount(
// handleUnmount is used to unmount a path // handleUnmount is used to unmount a path
func (b *SystemBackend) handleUnmount( func (b *SystemBackend) handleUnmount(
req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 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 { if len(suffix) == 0 {
return logical.ErrorResponse("path cannot be blank"), logical.ErrInvalidRequest return logical.ErrorResponse("path cannot be blank"), logical.ErrInvalidRequest
} }

View File

@ -9,7 +9,7 @@ import (
func TestSystemBackend_RootPaths(t *testing.T) { func TestSystemBackend_RootPaths(t *testing.T) {
expected := []string{ expected := []string{
"mount/*", "mounts/*",
"remount", "remount",
} }
@ -46,7 +46,7 @@ func TestSystemBackend_mounts(t *testing.T) {
func TestSystemBackend_mount(t *testing.T) { func TestSystemBackend_mount(t *testing.T) {
b := testSystemBackend(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" req.Data["type"] = "generic"
resp, err := b.HandleRequest(req) resp, err := b.HandleRequest(req)
@ -61,7 +61,7 @@ func TestSystemBackend_mount(t *testing.T) {
func TestSystemBackend_mount_invalid(t *testing.T) { func TestSystemBackend_mount_invalid(t *testing.T) {
b := testSystemBackend(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" req.Data["type"] = "nope"
resp, err := b.HandleRequest(req) resp, err := b.HandleRequest(req)
if err != logical.ErrInvalidRequest { if err != logical.ErrInvalidRequest {
@ -75,7 +75,7 @@ func TestSystemBackend_mount_invalid(t *testing.T) {
func TestSystemBackend_unmount(t *testing.T) { func TestSystemBackend_unmount(t *testing.T) {
b := testSystemBackend(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) resp, err := b.HandleRequest(req)
if err != nil { if err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
@ -88,7 +88,7 @@ func TestSystemBackend_unmount(t *testing.T) {
func TestSystemBackend_unmount_invalid(t *testing.T) { func TestSystemBackend_unmount_invalid(t *testing.T) {
b := testSystemBackend(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) resp, err := b.HandleRequest(req)
if err != logical.ErrInvalidRequest { if err != logical.ErrInvalidRequest {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)