mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
logical/framework: PathMap is case insensitive by default
This commit is contained in:
@@ -17,8 +17,7 @@ func Backend() *framework.Backend {
|
||||
var b backend
|
||||
b.Map = &framework.PolicyMap{
|
||||
PathMap: framework.PathMap{
|
||||
Name: "teams",
|
||||
CaseInsensitive: true,
|
||||
Name: "teams",
|
||||
},
|
||||
DefaultKey: "default",
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
// The primary use case for this is for credential providers to do their
|
||||
// mapping to policies.
|
||||
type PathMap struct {
|
||||
Prefix string
|
||||
Name string
|
||||
Schema map[string]*FieldSchema
|
||||
CaseInsensitive bool
|
||||
Prefix string
|
||||
Name string
|
||||
Schema map[string]*FieldSchema
|
||||
CaseSensitive bool
|
||||
|
||||
once sync.Once
|
||||
}
|
||||
@@ -43,7 +43,7 @@ func (p *PathMap) pathStruct(k string) *PathStruct {
|
||||
p.once.Do(p.init)
|
||||
|
||||
// If we don't care about casing, store everything lowercase
|
||||
if p.CaseInsensitive {
|
||||
if !p.CaseSensitive {
|
||||
k = strings.ToLower(k)
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,15 @@ func TestPathMap(t *testing.T) {
|
||||
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
|
||||
keys, err := p.List(storage, "")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user