forked from kubewarden/cel-policy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e.bats
31 lines (25 loc) · 1.01 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
#!/usr/bin/env bats
@test "accept" {
run kwctl run annotated-policy.wasm \
--allow-context-aware \
--replay-host-capabilities-interactions test_data/session.yaml \
--request-path test_data/deployment_lte_max_replicas.json \
--settings-path test_data/settings.json
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
}
@test "reject" {
run kwctl run annotated-policy.wasm \
--allow-context-aware \
--replay-host-capabilities-interactions test_data/session.yaml \
--request-path test_data/deployment_gt_max_replicas.json \
--settings-path test_data/settings.json
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*false') -ne 0 ]
[ $(expr "$output" : '.*Deployment: nginx, namespace: default - replicas must be no greater than 50.*') -ne 0 ]
[ $(expr "$output" : '.*code.*401') -ne 0 ]
}