1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-29 10:55:05 +00:00

add validate_hostpath testrunner

This commit is contained in:
Shuting Zhao 2019-09-09 15:06:54 -07:00
parent f1192d1dc1
commit 0fe5a065dd
3 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,18 @@
apiVersion: v1
kind: Pod
metadata:
name: image-with-hostpath
labels:
app.type: prod
namespace: "my-namespace"
spec:
containers:
- name: image-with-hostpath
image: docker.io/nautiker/curl
volumeMounts:
- name: var-lib-etcd
mountPath: /var/lib
volumes:
- name: var-lib-etcd
hostPath:
path: /var/lib

View file

@ -83,3 +83,7 @@ func Test_mutate_pod_disable_automoutingapicred_pass(t *testing.T) {
func Test_validate_default_namespace(t *testing.T) {
testScenario(t, "test/scenarios/test/scenario_validate_default_namespace.yaml")
}
func Test_validate_host_path(t *testing.T) {
testScenario(t, "test/scenarios/test/scenario_validate_host_path.yaml")
}

View file

@ -0,0 +1,18 @@
# file path relative to project root
input:
policy: examples/best_practices/policy_validate_host_path.yaml
resource: examples/best_practices/resources/resource_validate_host_path.yaml
expected:
validation:
policyresponse:
policy: validate-host-path
resource:
kind: Pod
apiVersion: v1
namespace: ''
name: "image-with-hostpath"
rules:
- name: validate-host-path
type: Validation
message: Validation rule 'validate-host-path' failed at '/spec/volumes/0/hostPath/path/' for resource Pod//image-with-hostpath. Host path '/var/lib/' is not allowed
success: false