This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
integration.bats
227 lines (200 loc) · 7.85 KB
/
integration.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/usr/bin/env bats
@test "invoke install command - install latest with --json global flag set" {
cd cmd/cli/
run go run main.go --json install
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 0 ]
}
@test "invoke status command with --json global flag set - output = '{"status":"stopped","installed-versions":["latest"]}'" {
cd cmd/cli/
run go run main.go --json status
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"stopped","installed-versions":["latest"]}' ]
[ "$status" -eq 0 ]
}
@test "invoke start command - Start dockerhub images (latest)" {
cd cmd/cli/
run go run main.go start -t latest
sleep 10
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 0 ]
}
@test "invoke stop-all command - Stop dockerhub images (latest)" {
cd cmd/cli/
run go run main.go stop-all
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 0 ]
}
@test "invoke remove command - remove all dockerhub images" {
cd cmd/cli/
run go run main.go remove local
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 0 ]
}
############################
# Connection command tests #
############################
@test "invoke con reset command - reset connections file" {
cd cmd/cli/
run go run main.go --json con reset
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK","status_message":"Connection list reset"}' ]
[ "$status" -eq 0 ]
}
@test "invoke con list command - contains just 1 local connection" {
cd cmd/cli/
run go run main.go --json con list
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"schemaversion":1,"connections":[{"id":"local","label":"Codewind local connection","url":"","auth":"","realm":"","clientid":"","username":""}]}' ]
[ "$status" -eq 0 ]
}
@test "invoke con add command - add new connection to the list" {
skip "environment not available yet"
cd cmd/cli/
run go run main.go con add -d kube --label "kube-cluster" --url http://mykube:12345 --auth http://myauth:12345 --realm codewind-cloud --clientid codewind
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK","status_message":"Connection added"}' ]
[ "$status" -eq 0 ]
}
@test "invoke con list command - ensure both connections exist " {
skip "environment not available yet"
cd cmd/cli/
run go run main.go con list
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"schemaversion":1,"connections":[{"id":"local","label":"Codewind local connection","url":"","auth":"","realm":"","clientid":""},{"id":"kube","label":"kube-cluster","url":"http://mykube:12345","auth":"http://myauth:12345","realm":"codewind-cloud","clientid":"codewind"}]}' ]
[ "$status" -eq 0 ]
}
@test "invoke con target command - set a target to something unknown" {
skip "environment not available yet"
cd cmd/cli/
run go run main.go con target -d noname
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"error":"con_not_found","error_description":"Target connection not found"}' ]
[ "$status" -eq 0 ]
}
@test "invoke con target command - set the target to kube" {
skip "environment not available yet"
cd cmd/cli/
run go run main.go con target -d kube
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK","status_message":"New target set"}' ]
[ "$status" -eq 0 ]
}
@test "invoke con target command - check the target is now kube" {
skip "environment not available yet"
cd cmd/cli/
run go run main.go con target
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"id":"kube","label":"kube-cluster","url":"http://mykube:12345","auth":"http://myauth:12345","realm":"codewind-cloud","clientid":"codewind"}' ]
[ "$status" -eq 0 ]
}
@test "invoke con remove command - delete target kube" {
skip "environment not available yet"
cd cmd/cli/
run go run main.go con remove --id kube
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK","status_message":"Connection removed"}' ]
[ "$status" -eq 0 ]
}
#########################
# Keyring command tests #
#########################
# use system keyring (secure)
@test "invoke seckeyring update command (using secure keyring) - create a key" {
cd cmd/cli/
run go run main.go seckeyring update --conid local --username testuser --password seCretphrase
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK"}' ]
[ "$status" -eq 0 ]
}
@test "invoke seckeyring update command (using secure keyring) - update a key" {
cd cmd/cli/
run go run main.go seckeyring update --conid local --username testuser --password new_secretPhrase
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK"}' ]
[ "$status" -eq 0 ]
}
@test "invoke seckeyring validate command (using secure keyring) - validate a key" {
cd cmd/cli/
run go run main.go seckeyring validate --conid local --username testuser
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK"}' ]
[ "$status" -eq 0 ]
}
@test "invoke seckeyring validate command (using secure keyring) - key not found (incorrect connection)" {
cd cmd/cli/
run go run main.go seckeyring validate --conid remoteNotKnown --username testuser
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 1 ]
[[ ${lines[0]} =~ "sec_keyring_secret_not_found" && ${lines[0]} =~ "not found in keyring" ]]
[[ ${lines[1]} = "exit status 1" ]]
}
@test "invoke seckeyring validate command (using secure keyring) - key not found (incorrect username)" {
cd cmd/cli/
run go run main.go seckeyring validate --conid local --username testuser_unknown
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 1 ]
[[ ${lines[0]} =~ "sec_keyring_secret_not_found" && ${lines[0]} =~ "not found in keyring" ]]
[[ ${lines[1]} = "exit status 1" ]]
}
# use our keyring (insecure)
@test "invoke seckeyring update command (using insecure keyring) - create a key" {
cd cmd/cli/
run go run main.go --insecureKeyring seckeyring update --conid local --username testuser --password seCretphrase
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK"}' ]
[ "$status" -eq 0 ]
}
@test "invoke seckeyring update command (using insecure keyring) - update a key" {
cd cmd/cli/
run go run main.go --insecureKeyring seckeyring update --conid local --username testuser --password new_secretPhrase
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK"}' ]
[ "$status" -eq 0 ]
}
@test "invoke seckeyring validate command (using insecure keyring) - validate a key" {
cd cmd/cli/
run go run main.go --insecureKeyring seckeyring validate --conid local --username testuser
echo "status = ${status}"
echo "output trace = ${output}"
[ "$output" = '{"status":"OK"}' ]
[ "$status" -eq 0 ]
}
@test "invoke seckeyring validate command (using insecure keyring) - key not found (incorrect connection)" {
cd cmd/cli/
run go run main.go --insecureKeyring seckeyring validate --conid remoteNotKnown --username testuser
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 1 ]
[[ ${lines[0]} =~ "sec_keyring" && ${lines[0]} =~ "not found in keyring" ]]
[[ ${lines[1]} = "exit status 1" ]]
}
@test "invoke seckeyring validate command (using insecure keyring) - key not found (incorrect username)" {
cd cmd/cli/
run go run main.go --insecureKeyring seckeyring validate --conid local --username testuser_unknown
echo "status = ${status}"
echo "output trace = ${output}"
[ "$status" -eq 1 ]
[[ ${lines[0]} =~ "sec_keyring" && ${lines[0]} =~ "not found in keyring" ]]
[[ ${lines[1]} = "exit status 1" ]]
}