From a87d0ba80675fb786ef0181c46de8ed5a86f9871 Mon Sep 17 00:00:00 2001 From: EurusDevSec Date: Tue, 24 Nov 2026 22:17:34 +0700 Subject: [PATCH] fix(ci): kyverno self-test must fail on the flipped case (DRF-67) On the GitHub runner the self-test run printed "exit 1: no summary": it failed for another reason (likely the 0700 mktemp dir unreadable by the non-root CLI user), so the self-test passed without proving anything. Make the copy world-readable and require the flipped run to report "N tests failed" with N >= 1. Co-Authored-By: Claude Opus 5.5 --- gitops/tests/kyverno_test.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gitops/tests/kyverno_test.sh b/gitops/tests/kyverno_test.sh index 58290f2..afce4c6 100644 --- a/gitops/tests/kyverno_test.sh +++ b/gitops/tests/kyverno_test.sh @@ -38,10 +38,19 @@ f="$tmp/tests/kyverno/kyverno-test.yaml" n="$(grep -c '^ result: pass$' "$f" || true)" [[ "$n" -ge 1 ]] || { echo "FAIL self-test: no 'result: pass' to flip"; exit 1; } sed -i '0,/^ result: pass$/s// result: fail/' "$f" +# mktemp -d is 0700; the CLI image runs as a non-root user and must read the copy. +chmod -R a+rX "$tmp" r=0; s="$(run "$tmp")" || r=$? -echo "${s%%$'\n'*}" +first="${s%%$'\n'*}" +echo "$first" if [[ $r -eq 0 ]]; then echo "FAIL self-test: flipped expectation still passed" exit 1 fi +# The run must fail because of the flipped case, not because it could not run. +if [[ ! "$first" =~ tests\ passed\ and\ [1-9][0-9]*\ tests\ failed$ ]]; then + printf '%s\n' "$s" + echo "FAIL self-test: the flipped run did not report failed cases" + exit 1 +fi echo "PASS kyverno test and self-test"