forked from helmfile/vals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vals_azurekeyvault_test.go
77 lines (66 loc) · 1.73 KB
/
vals_azurekeyvault_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
package vals
import (
"fmt"
"testing"
config2 "github.com/helmfile/vals/pkg/config"
)
func TestValues_AzureKeyVault_String(t *testing.T) {
// TODO
// Pre-requisite:
// az group create --name vals-test-rg -l eastus2
// az keyvault create --name vals-test --resource-group vals-test-rg --location eastus2
// az keyvault secret set --name fooKey --vault-name vals-test --value myValue
// create service principal for tests
// az ad sp create-for-rbac --name http://vals-test-sp --skip-assignment
// az keyvault set-policy --name vals-test --spn http://vals-test-sp --secret-permissions get
// set up service principal credentials in the environment:
// "AZURE_CLIENT_ID": "...",
// "AZURE_CLIENT_SECRET": "...",
// "AZURE_TENANT_ID": "..."
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": "azurekeyvault",
"type": "string",
"path": "vals-test",
},
"inline": commonInline,
},
},
{
config: map[string]interface{}{
"provider": map[string]interface{}{
"name": "azurekeyvault",
// 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)
}
}
})
}
}