-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e.bats
123 lines (107 loc) · 5.14 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env bats
@test "Accept a pod with custom namespace" {
run kwctl run --request-path test_data/pod_creation_custom_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
}
@test "Reject a pod with default namespace" {
run kwctl run --request-path test_data/pod_creation_default_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*Pod.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Reject a pod with empty namespace" {
run kwctl run --request-path test_data/pod_creation_empty_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*Pod.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Accept a job with custom namespace" {
run kwctl run --request-path test_data/job_creation_custom_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
}
@test "Reject a job with default namespace" {
run kwctl run --request-path test_data/job_creation_default_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*Job.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Reject a job with empty namespace" {
run kwctl run --request-path test_data/job_creation_empty_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*Job.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Accept a deployment with custom namespace" {
run kwctl run --request-path test_data/deployment_creation_custom_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
}
@test "Reject a deployment with default namespace" {
run kwctl run --request-path test_data/deployment_creation_default_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*Deployment.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Reject a deployment with empty namespace" {
run kwctl run --request-path test_data/deployment_creation_empty_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*Deployment.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Accept a daemon set with custom namespace" {
run kwctl run --request-path test_data/daemon_set_creation_custom_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
}
@test "Reject a daemon set with default namespace" {
run kwctl run --request-path test_data/daemon_set_creation_default_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*DaemonSet.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Reject a daemon set with empty namespace" {
run kwctl run --request-path test_data/daemon_set_creation_empty_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*DaemonSet.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Accept a stateful set with custom namespace" {
run kwctl run --request-path test_data/stateful_set_creation_custom_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
}
@test "Reject a stateful set with default namespace" {
run kwctl run --request-path test_data/stateful_set_creation_default_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*StatefulSet.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Reject a stateful set with empty namespace" {
run kwctl run --request-path test_data/stateful_set_creation_empty_namespace.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ]
[ $(expr "$output" : '.*"message":"Kind .*StatefulSet.* can not be deployed to the .default. namespace".*') -ne 0 ]
}
@test "Accept a non-workload resource" {
run kwctl run --request-path test_data/ingress_creation.json annotated-policy.wasm
[ "$status" -eq 0 ]
echo "$output"
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ]
}