diff --git a/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/00-policy.yaml b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/00-policy.yaml new file mode 100644 index 000000000000..404ce85387df --- /dev/null +++ b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/00-policy.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: + - policy.yaml +assert: + - policy-assert.yaml diff --git a/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/01-deployment.yaml b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/01-deployment.yaml new file mode 100644 index 000000000000..525d7b544ccd --- /dev/null +++ b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/01-deployment.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: + - resources.yaml +assert: + - resources-assert.yaml diff --git a/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/README.md b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/README.md new file mode 100644 index 000000000000..3c948b961598 --- /dev/null +++ b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/README.md @@ -0,0 +1,12 @@ +## Description + +This test checks that document references with special characters in their names are supported. + +## Expected Behavior + +JMESPath references generated when documents are traversed are escaped properly according to the JMESPath standard. + +## Reference Issue(s) + +3578 +3616 diff --git a/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy-assert.yaml b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy-assert.yaml new file mode 100644 index 000000000000..85dd54eef75a --- /dev/null +++ b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy-assert.yaml @@ -0,0 +1,9 @@ +apiVersion: kyverno.io/v1 +kind: ClusterPolicy +metadata: + name: jmespath-with-special-chars-demo +status: + conditions: + - reason: Succeeded + status: "True" + type: Ready diff --git a/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy.yaml b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy.yaml new file mode 100644 index 000000000000..ce91a05aeb71 --- /dev/null +++ b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy.yaml @@ -0,0 +1,28 @@ +apiVersion: kyverno.io/v1 +kind: ClusterPolicy +metadata: + name: jmespath-with-special-chars-demo +spec: + rules: + - name: format-deploy-zone + match: + any: + - resources: + kinds: + - Pod + mutate: + patchStrategicMerge: + metadata: + labels: + deploy-zone: "{{ to_upper('{{@}}') }}" + - name: retention-adjust + match: + any: + - resources: + kinds: + - Pod + mutate: + patchStrategicMerge: + metadata: + labels: + corp.com/retention: "{{ regex_replace_all('([0-9])([0-9])', '{{ @ }}', '${1}0') }}" diff --git a/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources-assert.yaml b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources-assert.yaml new file mode 100644 index 000000000000..0505829a4015 --- /dev/null +++ b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources-assert.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Pod +metadata: + name: busybox + labels: + deploy-zone: FRANKFURT + corp.com/retention: days_30 diff --git a/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources.yaml b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources.yaml new file mode 100644 index 000000000000..63f79ab966f3 --- /dev/null +++ b/test/conformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: busybox + labels: + deploy-zone: frankfurt + corp.com/retention: days_37 +spec: + containers: + - name: busybox + image: busybox:stable + command: ["sleep", "600"]