logical/framework: PathMap is case insensitive by default

This commit is contained in:
Mitchell Hashimoto
2015-05-11 10:27:04 -07:00
parent 5d1baaace4
commit 11a009d5ab
3 changed files with 15 additions and 7 deletions

View File

@@ -18,7 +18,6 @@ func Backend() *framework.Backend {
b.Map = &framework.PolicyMap{ b.Map = &framework.PolicyMap{
PathMap: framework.PathMap{ PathMap: framework.PathMap{
Name: "teams", Name: "teams",
CaseInsensitive: true,
}, },
DefaultKey: "default", DefaultKey: "default",
} }

View File

@@ -18,7 +18,7 @@ type PathMap struct {
Prefix string Prefix string
Name string Name string
Schema map[string]*FieldSchema Schema map[string]*FieldSchema
CaseInsensitive bool CaseSensitive bool
once sync.Once once sync.Once
} }
@@ -43,7 +43,7 @@ func (p *PathMap) pathStruct(k string) *PathStruct {
p.once.Do(p.init) p.once.Do(p.init)
// If we don't care about casing, store everything lowercase // If we don't care about casing, store everything lowercase
if p.CaseInsensitive { if !p.CaseSensitive {
k = strings.ToLower(k) k = strings.ToLower(k)
} }

View File

@@ -46,6 +46,15 @@ func TestPathMap(t *testing.T) {
t.Fatalf("bad: %#v", v) t.Fatalf("bad: %#v", v)
} }
// Read via API with other casing
v, err = p.Get(storage, "A")
if err != nil {
t.Fatalf("bad: %#v", err)
}
if v["value"] != "bar" {
t.Fatalf("bad: %#v", v)
}
// Verify List // Verify List
keys, err := p.List(storage, "") keys, err := p.List(storage, "")
if err != nil { if err != nil {