apiVersion: chainsaw.kyverno.io/v1alpha1 kind: Test metadata: name: adding-key-to-config-map spec: steps: - name: step-01 try: - apply: file: chainsaw-step-01-apply-1-1.yaml - name: create policy use: template: ../../../_step-templates/create-policy.yaml with: bindings: - name: file value: policy.yaml - try: - apply: file: chainsaw-step-01-apply-1-3.yaml - name: wait policy ready use: template: ../../../_step-templates/policy-ready.yaml with: bindings: - name: name value: configmap-policy - name: namespace value: test-validate-e2e-adding-key-to-config-map - name: step-02 try: - script: content: "if kubectl patch ConfigMap test-configmap -n test-validate-e2e-adding-key-to-config-map --type='json' -p=\"[{\\\"op\\\": \\\"add\\\", \\\"path\\\": \\\"/data/lock\\\", \\\"value\\\":\"\"admin\"\"}]\" 2>&1 | grep -q 'validation error: Configmap key must be \"abc\"' \nthen \n echo \"Test succeeded. Resource was blocked from adding key.\"\n exit 0\nelse \n echo \"Tested failed. Resource was not blocked from adding key.\"\n exit 1 \nfi\n"