Skip to content

Commit fceef49

Browse files
authored
Merge pull request #8 from viccuad/main
deps: Consume kubewarden-policy-sdk 0.1.2
2 parents 86db7af + b93ed2b commit fceef49

3 files changed

Lines changed: 76 additions & 7 deletions

File tree

e2e.bats

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@test "accept because hostname is not on the deny list" {
1616
run kwctl run annotated-policy.wasm -r test_data/pod_with_hostname.json --settings-json '{"denied_hostnames": ["forbidden-host"]}'
17-
17+
1818
# this prints the output when one the checks below fails
1919
echo "output = ${output}"
2020

@@ -25,7 +25,7 @@
2525

2626
@test "accept because the deny list is empty" {
2727
run kwctl run annotated-policy.wasm -r test_data/pod_with_hostname.json
28-
28+
2929
# this prints the output when one the checks below fails
3030
echo "output = ${output}"
3131

@@ -36,7 +36,7 @@
3636

3737
@test "accept because pod has no hostname set" {
3838
run kwctl run annotated-policy.wasm -r test_data/pod.json --settings-json '{"denied_hostnames": ["forbidden-host"]}'
39-
39+
4040
# this prints the output when one the checks below fails
4141
echo "output = ${output}"
4242

@@ -46,12 +46,12 @@
4646
}
4747

4848
@test "accept non-pod resources" {
49-
run kwctl run annotated-policy.wasm -r test_data/pod.json --settings-json '{"denied_hostnames": ["forbidden-host"]}'
50-
49+
run kwctl run annotated-policy.wasm -r test_data/service.json --settings-json '{"denied_hostnames": ["forbidden-host"]}'
50+
5151
# this prints the output when one the checks below fails
5252
echo "output = ${output}"
5353

5454
# request accepted (not a pod)
5555
[ "$status" -eq 0 ]
5656
[ $(expr "$output" : '.*allowed.*true') -ne 0 ]
57-
}
57+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"url": "https://github.com/kubewarden/js-policy-template/issues"
3838
},
3939
"dependencies": {
40-
"kubewarden-policy-sdk": "^0.1.0-alpha.1"
40+
"kubewarden-policy-sdk": "^0.1.2"
4141
}
4242
}

test_data/service.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"uid": "1299d386-525b-4032-98ae-1949f69f9cfc",
3+
"kind": {
4+
"group": "",
5+
"version": "v1",
6+
"kind": "Service"
7+
},
8+
"resource": {
9+
"group": "",
10+
"version": "v1",
11+
"resource": "services"
12+
},
13+
"requestKind": {
14+
"group": "",
15+
"version": "v1",
16+
"kind": "Service"
17+
},
18+
"requestResource": {
19+
"group": "",
20+
"version": "v1",
21+
"resource": "services"
22+
},
23+
"name": "nginx",
24+
"namespace": "default",
25+
"operation": "CREATE",
26+
"userInfo": {
27+
"username": "kubernetes-admin",
28+
"groups": [
29+
"system:masters",
30+
"system:authenticated"
31+
]
32+
},
33+
"object": {
34+
"kind": "Service",
35+
"apiVersion": "v1",
36+
"metadata": {
37+
"name": "nginx",
38+
"namespace": "default",
39+
"uid": "04dc7a5e-e1f1-4e34-8d65-2c9337a43e64",
40+
"creationTimestamp": "2020-11-12T15:18:36Z",
41+
"labels": {
42+
"env": "test"
43+
}
44+
},
45+
"spec": {
46+
"selector": {
47+
"app": "nginx"
48+
},
49+
"sessionAffinity": "None",
50+
"type": "NodePort",
51+
"ports": [
52+
{
53+
"port": 80,
54+
"targetPort": 80,
55+
"nodePort": 30080
56+
}
57+
]
58+
},
59+
"status": {
60+
"loadBalancer": {}
61+
}
62+
},
63+
"oldObject": null,
64+
"dryRun": false,
65+
"options": {
66+
"kind": "CreateOptions",
67+
"apiVersion": "meta.k8s.io/v1"
68+
}
69+
}

0 commit comments

Comments
 (0)