forked from kyverno/kyverno
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add kuttl tests for jmespath special chars (kyverno#5310)
* Adds tests for fixes in kyverno#4767 Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com> Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com> Co-authored-by: shuting <shuting@nirmata.com>
1 parent
001db94
commit 97a2b9a
Showing
7 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...ormance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/00-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- policy.yaml | ||
assert: | ||
- policy-assert.yaml |
6 changes: 6 additions & 0 deletions
6
...nce/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/01-deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
apply: | ||
- resources.yaml | ||
assert: | ||
- resources-assert.yaml |
12 changes: 12 additions & 0 deletions
12
...ce/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
9 changes: 9 additions & 0 deletions
9
...nce/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
28 changes: 28 additions & 0 deletions
28
...onformance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') }}" |
7 changes: 7 additions & 0 deletions
7
.../kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: busybox | ||
labels: | ||
deploy-zone: FRANKFURT | ||
corp.com/retention: days_30 |
12 changes: 12 additions & 0 deletions
12
...ormance/kuttl/mutate/clusterpolicy/cornercases/jmespath-with-special-chars/resources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |