open-vault/logical/framework/policy_map_test.go

29 lines
555 B
Go
Raw Normal View History

2015-04-01 22:46:13 +00:00
package framework
import (
"reflect"
"testing"
"github.com/hashicorp/vault/logical"
)
func TestPolicyMap(t *testing.T) {
p := &PolicyMap{}
p.PathMap.Name = "foo"
2015-04-01 22:46:13 +00:00
s := new(logical.InmemStorage)
p.Put(s, "foo", map[string]interface{}{"value": "bar"})
p.Put(s, "bar", map[string]interface{}{"value": "foo,baz "})
2015-04-01 22:46:13 +00:00
// Read via API
actual, err := p.Policies(s, "foo", "bar")
if err != nil {
t.Fatalf("bad: %#v", err)
}
expected := []string{"bar", "baz", "foo"}
if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual)
}
}