logical/framework: PathMap allows hyphens in keys [GH-119]

This commit is contained in:
Mitchell Hashimoto 2015-05-02 13:17:42 -07:00
parent 2eba902d0d
commit 81b12660c5
4 changed files with 27 additions and 1 deletions

View File

@ -14,6 +14,8 @@ BUG FIXES:
* core: if token helper isn't absolute, prepend with path to Vault
executable, not "vault" (which requires PATH) [GH-60]
* core: Any "mapping" routes allow hyphens in keys [GH-119]
* credential/app-id: app and user IDs can have hyphens in keys [GH-119]
* helper/password: import proper DLL for Windows to ask password [GH-83]
* physical/file: create the storge with 0600 permissions [GH-102]

View File

@ -99,7 +99,7 @@ func (p *PathMap) Paths() []*Path {
},
&Path{
Pattern: fmt.Sprintf("%s/%s/(?P<key>\\w+)", p.Prefix, p.Name),
Pattern: fmt.Sprintf(`%s/%s/(?P<key>[-\w]+)`, p.Prefix, p.Name),
Fields: schema,

View File

@ -68,3 +68,12 @@ func TestPathMap_getInvalid(t *testing.T) {
t.Fatalf("bad: %#v", v)
}
}
func TestPathMap_routes(t *testing.T) {
p := &PathMap{Name: "foo"}
TestBackendRoutes(t, &Backend{Paths: p.Paths()}, []string{
"map/foo", // Normal
"map/foo/bar", // Normal
"map/foo/bar-baz", // Hyphen key
})
}

View File

@ -0,0 +1,15 @@
package framework
import (
"testing"
)
// TestBackendRoutes is a helper to test that all the given routes will
// route properly in the backend.
func TestBackendRoutes(t *testing.T, b *Backend, rs []string) {
for _, r := range rs {
if b.Route(r) == nil {
t.Fatalf("bad route: %s", r)
}
}
}