-
Notifications
You must be signed in to change notification settings - Fork 2
/
e2e.bats
63 lines (44 loc) · 2.58 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
#!/usr/bin/env bats
@test "Empty settings should fail" {
run kwctl run --request-path test_data/pvc-fast-storage-class-request.json --settings-json '{}' annotated-policy.wasm
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -ne 0 ]
[ $(expr "$output" : '.*Provided settings are not valid: "deniedStorageClasses cannot be empty".*') -ne 0 ]
}
@test "Empty denied storage classes list should fail" {
run kwctl run --request-path test_data/pvc-fast-storage-class-request.json --settings-json '{"deniedStorageClasses":[]}' annotated-policy.wasm
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -ne 0 ]
[ $(expr "$output" : '.*Provided settings are not valid: "deniedStorageClasses cannot be empty".*') -ne 0 ]
}
@test "Fallback cannot be in the denied storage classes list" {
run kwctl run --request-path test_data/pvc-fast-storage-class-request.json --settings-json '{"deniedStorageClasses":["fast"], fallbackStorageClass: "fast"}' annotated-policy.wasm
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -ne 0 ]
[ $(expr "$output" : '.*Provided settings are not valid: "fallbackStorageClass cannot be in deniedStorageClasses".*') -ne 0 ]
}
@test "Accept PVC not using denied storage classes names" {
run kwctl run --request-path test_data/pvc-fast-storage-class-request.json --settings-json '{"deniedStorageClasses": ["slow"]}' annotated-policy.wasm
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
}
@test "Reject PVC using denied storage classes names" {
run kwctl run --request-path test_data/pvc-fast-storage-class-request.json --settings-json '{"deniedStorageClasses": ["fast"]}' annotated-policy.wasm
# this prints the output when one the checks below fails
echo "output = ${output}"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"storage class \\"fast\\" is not allowed".*') -ne 0 ]
}
@test "Mutate PVC using denied storage classes names when fallback is defined" {
run kwctl run --request-path test_data/pvc-fast-storage-class-request.json --settings-json '{"deniedStorageClasses": ["fast"], "fallbackStorageClass": "fallback"}' annotated-policy.wasm
# this prints the output when one the checks below fails
echo "output = ${output}"
[ "$status" -eq 0 ]
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
[ $(expr "$output" : '.*"patchType":"JSONPatch".*') -ne 0 ]
}