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:
parent
784ca07419
commit
a188491091
7 changed files with 76 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- policy.yaml
|
||||
assert:
|
||||
- policy-ready.yaml
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: failure-policy-test-noconfigmap-diffimage-success
|
|
@ -0,0 +1,5 @@
|
|||
apiVersion: kuttl.dev/v1beta1
|
||||
kind: TestStep
|
||||
apply:
|
||||
- file: bad-pod.yaml
|
||||
shouldFail: false
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Add table
Reference in a new issue