-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathe2e.bats
58 lines (43 loc) · 1.93 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
#!/usr/bin/env bats
@test "reject because required TLS failure" {
run kwctl run annotated-policy.wasm -r test_data/ingress-wildcard.json --settings-json '{"requireTLS": true}'
# 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" : '.*Not all hosts have TLS enabled.*') -ne 0 ]
}
@test "reject because not allowed port is used" {
run kwctl run annotated-policy.wasm -r test_data/ingress-wildcard.json --settings-json '{"allowPorts": [80]}'
# 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" : '.*These ports are not on the allowed list: Set{3000}.*') -ne 0 ]
}
@test "reject because not denied port is used" {
run kwctl run annotated-policy.wasm -r test_data/ingress-wildcard.json --settings-json '{"denyPorts": [3000]}'
# 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" : '.*These ports are explicitly denied: Set{3000}.*') -ne 0 ]
}
@test "reject because invalid settings" {
run kwctl run annotated-policy.wasm -r test_data/ingress-wildcard.json --settings-json '{"allowPorts": [80, 3000], "denyPorts": [3000]}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# settings validation fails
[ "$status" -eq 1 ]
}
@test "accept" {
run kwctl run annotated-policy.wasm -r test_data/single-backend-with-tls-termination.json --settings-json '{"requireTLS": true, "denyPorts": [3000]}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# request accepted
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
}