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

chore: run range operators test with chainsaw (#8956)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-11-20 07:41:19 +01:00 committed by GitHub
parent 31c089bcc6
commit 4dbd71459a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 3 deletions

View file

@ -178,6 +178,7 @@ jobs:
version: v1.28.0
tests:
# - autogen
- background-only
# - cleanup
# - deferred
# - events
@ -188,14 +189,13 @@ jobs:
# - generate/validation
# - mutate
# - policy-validation
# - rangeoperators
- rangeoperators
- rbac
# - reports
# - validate
# - verify-manifests
# - verifyImages
- webhooks
- background-only
- rbac
needs: prepare-images
name: chainsaw - ${{ matrix.k8s-version.name }} - ${{ matrix.config.name }} - ${{ matrix.tests }}
steps:

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: policy
spec:
try:
- apply:
file: policy.yaml
- assert:
file: policy-assert.yaml

View file

@ -0,0 +1,10 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: TestStep
metadata:
name: resource
spec:
try:
- apply:
file: resource.yaml
check:
(error == null): false

View file

@ -0,0 +1,11 @@
## Description
This test creates a policy with range operators and a configmap. It uses ranges with negative and (un)signed positive integer endpoints.
## Expected Behavior
It ensures that a configmap with values not in a range are not created.
## Reference Issue(s)

View file

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

View file

@ -0,0 +1,23 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-value
spec:
validationFailureAction: Enforce
rules:
- name: check-value
match:
any:
- resources:
kinds:
- ConfigMap
validate:
message: "All data values must be in the specified range."
pattern:
data:
first_value: "+2-+4"
second_value: "-2-5"
third_value: "100Mi!-1024Mi"
fourth_value: "2.5-3.5"
fifth_value: "-10--8"

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
first_value: "3"
second_value: "4"
third_value: "98Mi"
fourth_value: "2.7"
fifth_value: "-15"