forked from jkroepke/helm-secrets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.bats
executable file
·160 lines (127 loc) · 4.71 KB
/
view.bats
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env bats
load '../lib/helper'
load '../bats/extensions/bats-support/load'
load '../bats/extensions/bats-assert/load'
load '../bats/extensions/bats-file/load'
@test "view: helm view" {
run "${HELM_BIN}" secrets view
assert_failure
assert_output --partial 'Error: secrets file required.'
}
@test "view: helm view --help" {
run "${HELM_BIN}" secrets view --help
assert_success
assert_output --partial 'View specified encrypted yaml file'
}
@test "view: File not exits" {
run "${HELM_BIN}" secrets view nonexists
assert_failure
assert_output --partial '[helm-secrets] File does not exist: nonexists'
}
@test "view: secrets.yaml" {
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
run "${HELM_BIN}" secrets view "${FILE}"
assert_success
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: some-secrets.yaml" {
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/some-secrets.yaml"
run "${HELM_BIN}" secrets view "${FILE}"
assert_success
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: values.yaml" {
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/values.yaml"
run "${HELM_BIN}" secrets view "${FILE}"
assert_success
assert_output --partial 'global_secret: '
assert_output --partial 'global_values'
}
@test "view: secrets.yaml + special char directory name" {
if on_windows; then
skip "Skip on Windows"
fi
FILE="${SPECIAL_CHAR_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
run "${HELM_BIN}" secrets view "${FILE}"
assert_success
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: secrets.yaml + --backend-args (simple)" {
if ! is_backend "sops"; then
skip
fi
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
run "${HELM_BIN}" secrets --backend-args "--verbose" view "${FILE}"
assert_success
assert_output --partial "Data key recovered successfully"
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: secrets.yaml + -a (simple)" {
if ! is_backend "sops"; then
skip
fi
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
run "${HELM_BIN}" secrets -a "--verbose" view "${FILE}"
assert_success
assert_output --partial "Data key recovered successfully"
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: secrets.yaml + HELM_SECRETS_BACKEND_ARGS (simple)" {
if ! is_backend "sops"; then
skip
fi
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
HELM_SECRETS_BACKEND_ARGS=--verbose
export HELM_SECRETS_BACKEND_ARGS
# shellcheck disable=SC2030 disable=SC2031
export WSLENV="HELM_SECRETS_BACKEND_ARGS:${WSLENV}"
run "${HELM_BIN}" secrets view "${FILE}"
assert_success
assert_output --partial "Data key recovered successfully"
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: secrets.yaml + --backend-args (complex)" {
if ! is_backend "sops"; then
skip
fi
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
run "${HELM_BIN}" secrets --backend-args "--verbose --output-type \"yaml\"" view "${FILE}"
assert_success
assert_output --partial "Data key recovered successfully"
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: secrets.yaml + -a (complex)" {
if ! is_backend "sops"; then
skip
fi
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
run "${HELM_BIN}" secrets -a "--verbose --output-type \"yaml\"" view "${FILE}"
assert_success
assert_output --partial "Data key recovered successfully"
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}
@test "view: secrets.yaml + HELM_SECRETS_BACKEND_ARGS (complex)" {
if ! is_backend "sops"; then
skip
fi
FILE="${TEST_TEMP_DIR}/assets/values/${HELM_SECRETS_BACKEND}/secrets.yaml"
# shellcheck disable=SC2089
HELM_SECRETS_BACKEND_ARGS="--verbose --output-type \"yaml\""
# shellcheck disable=SC2090
export HELM_SECRETS_BACKEND_ARGS
# shellcheck disable=SC2030 disable=SC2031
export WSLENV="HELM_SECRETS_BACKEND_ARGS:${WSLENV}"
run "${HELM_BIN}" secrets view "${FILE}"
assert_success
assert_output --partial "Data key recovered successfully"
assert_output --partial 'global_secret: '
assert_output --partial 'global_bar'
}