-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e.bats
54 lines (42 loc) · 1.68 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
#!/usr/bin/env bats
@test "reject because invalid settings" {
run kwctl run annotated-policy.wasm \
-r test_data/pod-creation.json \
--settings-json '{"requiredAnnotations": {"fluxcd.io/cat": "felix"}, "forbiddenAnnotations": ["fluxcd.io/cat"]}'
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -eq 1 ]
[ $(expr "$output" : ".*The following annotations are.*") -ne 0 ]
}
@test "accept but no mutation" {
run kwctl run annotated-policy.wasm \
-r test_data/pod-creation.json \
--settings-json '{"requiredAnnotations": {"fluxcd.io/cat": "felix"}}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# request accepted but not mutated
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
[ $(expr "$output" : '.*"patchType":"JSONPatch".*') -eq 0 ]
}
@test "accept and mutate" {
run kwctl run annotated-policy.wasm \
-r test_data/pod-creation.json \
--settings-json '{"requiredAnnotations": {"fluxcd.io/cat": "sylvester"}}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# request accepted but not mutated
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
[ $(expr "$output" : '.*"patchType":"JSONPatch".*') -ne 0 ]
}
@test "reject because forbidden annotation is being used" {
run kwctl run annotated-policy.wasm \
-r test_data/pod-creation.json \
--settings-json '{"forbiddenAnnotations": ["fluxcd.io/cat"]}'
# this prints the output when one the checks below fails
echo "output = ${output}"
# request rejected
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*allowed.*false') -ne 0 ]
}