-
Notifications
You must be signed in to change notification settings - Fork 0
/
SOPSGenerator_test.go
59 lines (49 loc) · 1.24 KB
/
SOPSGenerator_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
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package main_test
import (
"fmt"
"io/ioutil"
"testing"
sg "omninonsense.github.io/kustomize-sopsgenerator"
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
)
// TODO: Write more tests
func TestSOPSGeneratorPlugin(t *testing.T) {
th := kusttest_test.
MakeEnhancedHarness(t)
defer th.Reset()
json, _ := ioutil.ReadFile("__test__/encrypted/secret.json")
yaml, _ := ioutil.ReadFile("__test__/encrypted/secret.yaml")
env, _ := ioutil.ReadFile("__test__/encrypted/secret.env")
th.WriteF("secret.json", string(json))
th.WriteF("top/secret.yaml", string(yaml))
th.WriteF("secret.env", string(env))
m := th.LoadAndRunGenerator(fmt.Sprintf(`
apiVersion: %s/%s
kind: %s
metadata:
name: zero-zero-seven
namespace: test
annotations:
omninonsense.github.io/sopsgenerator.logLevel: debug
envs:
- secret.env
files:
- secret.json
- renamed.yaml=top/secret.yaml
`, sg.Domain, sg.Version, sg.Kind))
th.AssertActualEqualsExpected(m, `
apiVersion: v1
data:
EMPTY: ""
HELLO: d29ybGQ=
renamed.yaml: aGVsbG86IHdvcmxkCg==
secret.json: ewoJImhlbGxvIjogIndvcmxkIgp9
kind: Secret
metadata:
name: zero-zero-seven
namespace: test
type: Opaque
`)
}