open-vault/vault/identity_store_util_test.go
Vishal Nayak f7ed6732a5 Porting identity store (#3419)
* porting identity to OSS

* changes that glue things together

* add testing bits

* wrapped entity id

* fix mount error

* some more changes to core

* fix storagepacker tests

* fix some more tests

* fix mount tests

* fix http mount tests

* audit changes for identity

* remove upgrade structs on the oss side

* added go-memdb to vendor
2017-10-11 10:21:20 -07:00

41 lines
746 B
Go

package vault
import (
"reflect"
"testing"
)
func TestIdentityStore_parseMetadata(t *testing.T) {
goodKVs := []string{
"key1=value1",
"key2=value1=value2",
}
expectedMap := map[string]string{
"key1": "value1",
"key2": "value1=value2",
}
actualMap, err := parseMetadata(goodKVs)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expectedMap, actualMap) {
t.Fatalf("bad: metadata; expected: %#v\n, actual: %#v\n", expectedMap, actualMap)
}
badKV := []string{
"=world",
}
actualMap, err = parseMetadata(badKV)
if err == nil {
t.Fatalf("expected an error; got: %#v", actualMap)
}
badKV[0] = "world"
actualMap, err = parseMetadata(badKV)
if err == nil {
t.Fatalf("expected an error: %#v", actualMap)
}
}