forked from vmware/govmomi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.bats
executable file
·73 lines (57 loc) · 1.73 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
66
67
68
69
70
71
72
73
#!/usr/bin/env bats
load test_helper
@test "extension" {
vcsim_env_todo
govc extension.info | grep Name: | grep govc-test | awk '{print $2}' | $xargs -r govc extension.unregister
run govc extension.info enoent
assert_failure
id=$(new_id)
result=$(govc extension.info | grep $id | wc -l)
[ $result -eq 0 ]
# 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
# test client certificate authentication
(
# remove password from env, set user to extension id and turn of session cache
govc_url_to_vars
unset GOVC_PASSWORD
GOVC_USERNAME=$id
export GOVC_PERSIST_SESSION=false
run govc about -cert "${id}.crt" -key "${id}.key"
assert_success
)
# remove generated cert and key
rm ${id}.{crt,key}
run govc extension.unregister $id
assert_success
result=$(govc extension.info | grep $id | wc -l)
[ $result -eq 0 ]
}