open-vault/sdk/framework/policy_map_test.go
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

35 lines
685 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package framework
import (
"context"
"reflect"
"testing"
"github.com/hashicorp/vault/sdk/logical"
)
func TestPolicyMap(t *testing.T) {
p := &PolicyMap{}
p.PathMap.Name = "foo"
s := new(logical.InmemStorage)
ctx := context.Background()
p.Put(ctx, s, "foo", map[string]interface{}{"value": "bar"})
p.Put(ctx, s, "bar", map[string]interface{}{"value": "foo,baz "})
// Read via API
actual, err := p.Policies(ctx, 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)
}
}