-
Notifications
You must be signed in to change notification settings - Fork 74
/
vals_hcpvaultsecrets_test.go
78 lines (68 loc) · 1.76 KB
/
vals_hcpvaultsecrets_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package vals
import (
"fmt"
"os"
"testing"
config2 "github.com/helmfile/vals/pkg/config"
)
func TestValues_HCPVaultSecrets_String(t *testing.T) {
// TODO
// Pre-requisite:
// 1. Create a Vault Secrets in HCP
// 2. Configure the HCP Vault Secrets using a Service Principal https://developer.hashicorp.com/vault/tutorials/hcp-vault-secrets-get-started/hcp-vault-secrets-install-cli#configure-the-hcp-vault-secrets-cli
// 3. Set the following environment variables:
// - HCP_CLIENT_ID
// - HCP_CLIENT_SECRET
// 4. Run `vlt config init`
// 5. Create an APP by running `echo y | vlt apps create vals-test`
// 6. Create a simple secret by running `vlt secrets create --app-name vals-test fooKey="myValue"`
if os.Getenv("SKIP_TESTS") != "" {
t.Skip("Skipping tests")
}
type testcase struct {
config map[string]interface{}
}
commonInline := map[string]interface{}{
"vals-test": "fooKey",
}
testcases := []testcase{
{
config: map[string]interface{}{
"provider": map[string]interface{}{
"name": "hcpvaultsecrets",
"type": "string",
"path": "vals-test",
},
"inline": commonInline,
},
},
{
config: map[string]interface{}{
"provider": map[string]interface{}{
"name": "hcpvaultsecrets",
// implies type=string
"path": "vals-test",
},
"inline": commonInline,
},
},
}
for i := range testcases {
tc := testcases[i]
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
config := config2.Map(tc.config)
vals, err := Load(config)
if err != nil {
t.Fatalf("%v", err)
}
{
expected := "myValue"
key := "vals-test"
actual := vals[key]
if actual != expected {
t.Errorf("unepected value for key %q: expected=%q, got=%q", key, expected, actual)
}
}
})
}
}