-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e.bats
30 lines (24 loc) · 1.17 KB
/
e2e.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
#!/usr/bin/env bats
@test "Mutate pod definition" {
# Need to run the command inside of `bash -c` because of a bats
# limitation: https://bats-core.readthedocs.io/en/stable/gotchas.html?highlight=pipe#my-piped-command-does-not-work-under-run
run bash -c 'kwctl run \
--request-path test_data/pod_with_5_ndots.json \
annotated-policy.wasm 2>/dev/null | jq -er ".patch | @base64d"'
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*{"op":"replace","path":"/spec/dnsConfig/options/0/value","value":"1"}.*') -ne 0 ]
}
@test "Do not mutate Pod definition" {
# Need to run the command inside of `bash -c` because of a bats
# limitation: https://bats-core.readthedocs.io/en/stable/gotchas.html?highlight=pipe#my-piped-command-does-not-work-under-run
run bash -c 'kwctl run \
--request-path test_data/pod_with_5_ndots.json \
--settings-path test_data/settings-5-ndots.yaml \
annotated-policy.wasm 2>/dev/null | jq -er ".patch"'
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -eq 1 ]
[ $(expr "$output" : 'null') -ne 0 ]
}