2015-03-12 00:46:25 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseSecret(t *testing.T) {
|
|
|
|
raw := strings.TrimSpace(`
|
|
|
|
{
|
|
|
|
"vault_id": "foo",
|
|
|
|
"renewable": true,
|
|
|
|
"lease_duration": 10,
|
2015-03-16 20:29:51 +00:00
|
|
|
"data": {
|
|
|
|
"key": "value"
|
|
|
|
}
|
2015-03-12 00:46:25 +00:00
|
|
|
}`)
|
|
|
|
|
|
|
|
secret, err := ParseSecret(strings.NewReader(raw))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
expected := &Secret{
|
2015-03-16 20:29:51 +00:00
|
|
|
VaultId: "foo",
|
|
|
|
Renewable: true,
|
|
|
|
LeaseDuration: 10,
|
2015-03-12 00:46:25 +00:00
|
|
|
Data: map[string]interface{}{
|
|
|
|
"key": "value",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(secret, expected) {
|
2015-03-16 20:29:51 +00:00
|
|
|
t.Fatalf("bad: %#v %#v", secret, expected)
|
2015-03-12 00:46:25 +00:00
|
|
|
}
|
|
|
|
}
|