1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 15:37:19 +00:00

test: new kuttl test for image verify failure policy (#6788)

* add a kuttl test

Signed-off-by: ShutingZhao <shuting@nirmata.com>

* rename policy

Signed-off-by: ShutingZhao <shuting@nirmata.com>

---------

Signed-off-by: ShutingZhao <shuting@nirmata.com>
This commit is contained in:
shuting 2023-04-05 19:11:49 +08:00 committed by GitHub
parent 784ca07419
commit a188491091
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 0 deletions

View file

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

View file

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: failure-policy-test-noconfigmap-diffimage-success

View file

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

View file

@ -0,0 +1,11 @@
## Description
This test verifies that resource creation is not blocked if the `failurePolicy` is set to `Ignore`, when there is an error resolving context variables.
## Expected Behavior
The pod should be created successfully.
## Reference Issue(s)
https://github.com/kyverno/kyverno/issues/6742

View file

@ -0,0 +1,9 @@
apiVersion: v1
kind: Pod
metadata:
name: test-fail
namespace: failure-policy-test-noconfigmap-diffimage-success
spec:
containers:
- image: ghcr.io/kyverno/test-verify-image:signed
name: test-fail

View file

@ -0,0 +1,9 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: image-verify-polset-failurepolicy-ignore
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready

View file

@ -0,0 +1,32 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
annotations:
pod-policies.kyverno.io/autogen-controllers: none
name: image-verify-polset-failurepolicy-ignore
spec:
background: false
failurePolicy: Ignore
rules:
- context:
- configMap:
name: myconfigmap
namespace: mynamespace
name: myconfigmap
match:
any:
- resources:
kinds:
- Pod
name: image-verify-pol1
verifyImages:
- imageReferences:
- ghcr.io/*
mutateDigest: false
verifyDigest: false
attestors:
- entries:
- keys:
publicKeys: '{{myconfigmap.data.configmapkey}}'
validationFailureAction: Audit
webhookTimeoutSeconds: 30