-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathe2e.bats
35 lines (27 loc) · 1.26 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
31
32
33
34
35
#!/usr/bin/env bats
@test "reject because runtime is reserved" {
run kwctl run policy.wasm -r test_data/PodRequestWithRuncRuntime.json --settings-json '{"reservedRuntimes": ["runC"]}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# request rejected
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*false*') -ne 0 ]
[ $(expr "$output" : ".*'runC' is reserved.*") -ne 0 ]
}
@test "accept because runtime is not reserved" {
run kwctl run policy.wasm -r test_data/PodRequestWithRuncRuntime.json --settings-json '{"reservedRuntimes": ["gVisor"]}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# request accepted
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
}
@test "modify incoming request" {
run kwctl run policy.wasm -r test_data/PodRequestWithRuncRuntime.json --settings-json '{"reservedRuntimes": ["runC"], "fallbackRuntime": "kata"}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# request accepted
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
[ $(expr "$output" : '.*patch":"W3sib3AiOiJyZXBsYWNlIiwicGF0aCI6Ii9zcGVjL3J1bnRpbWVDbGFzc05hbWUiLCJ2YWx1ZSI6ImthdGEifV0=') -ne 0 ]
}