-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathe2e.bats
36 lines (27 loc) · 1.04 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
#!/usr/bin/env bats
@test "accept if the request is valid" {
run kwctl run --raw -e opa annotated-policy.wasm -r test_data/valid.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 if the request is invalid" {
run kwctl run --raw -e opa annotated-policy.wasm -r test_data/invalid.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" : '.*User not allowed.*') -ne 0 ]
}
@test "reject if the request has no user field" {
run kwctl run --raw -e opa annotated-policy.wasm -r test_data/invalid_no_user_field.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" : '.*User not allowed.*') -ne 0 ]
}