-
Notifications
You must be signed in to change notification settings - Fork 30
/
dump_test.go
63 lines (54 loc) · 1.31 KB
/
dump_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"encoding/json"
"reflect"
"testing"
"github.com/miquella/vaulted/lib"
)
func TestDump(t *testing.T) {
store := NewTestStore()
store.Vaults["one"] = &vaulted.Vault{
AWSKey: &vaulted.AWSKey{
AWSCredentials: vaulted.AWSCredentials{
ID: "id",
Secret: "secret",
},
MFA: "mfa",
Role: "role",
},
Vars: map[string]string{
"VAR1": "TESTING",
"VAR2": "ANOTHER",
},
SSHKeys: map[string]string{
"KEY1": "value1",
"KEY2": "value2",
},
}
output := CaptureStdout(func() {
d := Dump{
VaultName: "one",
}
err := d.Run(store)
if err != nil {
t.Fatal(err)
}
})
var v vaulted.Vault
err := json.Unmarshal(output, &v)
if err != nil {
t.Fatalf("Failed to read vault: %v", err)
}
if !reflect.DeepEqual(store.Vaults["one"].AWSKey, v.AWSKey) {
t.Fatalf("Expected: %#v, got: %#v", store.Vaults["one"].AWSKey, v.AWSKey)
}
if !reflect.DeepEqual(store.Vaults["one"].Vars, v.Vars) {
t.Fatalf("Expected: %#v, got: %#v", store.Vaults["one"].Vars, v.Vars)
}
if !reflect.DeepEqual(store.Vaults["one"].SSHKeys, v.SSHKeys) {
t.Fatalf("Expected: %#v, got: %#v", store.Vaults["one"].SSHKeys, v.SSHKeys)
}
if !reflect.DeepEqual(store.Vaults["one"].Duration, v.Duration) {
t.Fatalf("Expected: %#v, got: %#v", store.Vaults["one"].Duration, v.Duration)
}
}