28 lines
495 B
Go
28 lines
495 B
Go
|
package framework
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/hashicorp/vault/logical"
|
||
|
)
|
||
|
|
||
|
func TestPolicyMap(t *testing.T) {
|
||
|
p := &PolicyMap{PathMap: &PathMap{Name: "foo"}}
|
||
|
s := new(logical.InmemStorage)
|
||
|
|
||
|
p.Put(s, "foo", "bar")
|
||
|
p.Put(s, "bar", "foo,baz ")
|
||
|
|
||
|
// 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)
|
||
|
}
|
||
|
}
|