-
Notifications
You must be signed in to change notification settings - Fork 916
/
Copy pathextension.bats
executable file
·65 lines (49 loc) · 1.43 KB
/
extension.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
#!/usr/bin/env bats
load test_helper
@test "extension" {
vcsim_env
run govc extension.info enoent
assert_failure
run govc extension.info
assert_success
id=$(new_id)
# register extension
run govc extension.register $id <<EOS
{
"Description": {
"Label": "govc",
"Summary": "Go interface to vCenter"
},
"Key": "${id}",
"Company": "VMware, Inc.",
"Version": "0.2.0"
}
EOS
assert_success
# check info output is legit
run govc extension.info $id
assert_line "Name: $id"
json=$(govc extension.info -json $id)
label=$(jq -r .extensions[].description.label <<<"$json")
assert_equal "govc" "$label"
# change label and update extension
json=$(jq -r '.extensions[] | .description.label = "novc"' <<<"$json")
run govc extension.register -update $id <<<"$json"
assert_success
# check label changed in info output
json=$(govc extension.info -json $id)
label=$(jq -r .extensions[].description.label <<<"$json")
assert_equal "novc" "$label"
# set extension certificate to generated certificate
run govc extension.setcert -cert-pem '+' $id
assert_success
# client certificate authentication is tested in session.bats
# remove generated cert and key
rm ${id}.{crt,key}
run govc extension.info $(govc extension.info -json | jq -r .extensions[].key)
assert_success
run govc extension.unregister $id
assert_success
run govc extension.info $id
assert_failure
}