1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 02:18:15 +00:00

add kuttl tests (#7283)

Signed-off-by: ShutingZhao <shuting@nirmata.com>
This commit is contained in:
shuting 2023-05-26 09:16:50 +08:00 committed by GitHub
parent 64e3dde6ff
commit 0938003aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 94 additions and 0 deletions

View file

@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- policy.yaml
assert:
- policy-assert.yaml

View file

@ -0,0 +1,9 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- file: bad-pod-1.yaml
shouldFail: true
- file: bad-pod-2.yaml
shouldFail: true
- file: good-pod.yaml
shouldFail: false

View file

@ -0,0 +1,10 @@
## Description
This test ensures the PSS checks with the latest version, without exclusions, are applied to the resources successfully.
## Expected Behavior
The two pods should not be created as it violate the baseline:latest `seccomp` PSS check.
## Reference Issue(s)
https://github.com/kyverno/kyverno/issues/7260

View file

@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-restricted-seccomp-profile-1
spec:
containers:
- name: busybox
image: busybox:1.35
args:
- sleep
- 1d
securityContext:
seccompProfile:
type: Unconfined

View file

@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-restricted-seccomp-profile-2
spec:
containers:
- name: busybox
image: busybox:1.35
args:
- sleep
- 1d
securityContext:
seccompProfile:
type: Unconfined

View file

@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-restricted-seccomp-profile-3
spec:
containers:
- name: busybox
image: busybox:1.35
args:
- sleep
- 1d
securityContext:
seccompProfile:
type: RuntimeDefault

View file

@ -0,0 +1,9 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: latest-check-no-exclusion
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,18 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: latest-check-no-exclusion
spec:
background: false
validationFailureAction: Enforce
rules:
- name: restricted
match:
any:
- resources:
kinds:
- Pod
validate:
podSecurity:
level: baseline
version: latest