logical/framework: PathMap allows hyphens in keys [GH-119]
This commit is contained in:
parent
2eba902d0d
commit
81b12660c5
|
@ -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]
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue