-
Notifications
You must be signed in to change notification settings - Fork 6
/
e2e.bats
63 lines (48 loc) · 2.09 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
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
#!/usr/bin/env bats
@test "reject because privileged container" {
run kwctl run annotated-policy.wasm -r test_data/privileged_container.json
# 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" : '.*Privileged container is not allowed*') -ne 0 ]
}
@test "accept" {
run kwctl run annotated-policy.wasm -r test_data/no_privileged_containers.json
# 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 "reject deployment because privileged container" {
run kwctl run annotated-policy.wasm -r test_data/deployment_with_privileged_containers.json
# 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" : '.*Privileged container is not allowed*') -ne 0 ]
}
@test "reject statefulset because privileged container" {
run kwctl run annotated-policy.wasm -r test_data/statefulset_with_privileged_container.json
# 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" : '.*Privileged container is not allowed*') -ne 0 ]
}
@test "accept privileged init container when required" {
run kwctl run annotated-policy.wasm -r test_data/privileged_init_container.json --settings-path test_data/settings_skip_init_and_ephemeral_containers.json
# request accepted
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
}
@test "accept privileged ephemeral container when required" {
run kwctl run annotated-policy.wasm -r test_data/privileged_ephemeral_container.json --settings-path test_data/settings_skip_init_and_ephemeral_containers.json
# request accepted
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
}