From 5471bccb7cc19cd3795ae18f2c4e7facabf73aad Mon Sep 17 00:00:00 2001 From: Divya shree R Date: Wed, 17 Jun 2026 14:47:18 +0530 Subject: [PATCH] fix: tighten audit log count assertion in integration test The audit log count check used -ge 0, which passes for any non-negative integer including 0. Combined with 2>/dev/null, this assertion could never fail, even if the audit service returned an empty response. Changes: - Replace -ge 0 with -gt 0 to require at least one audit entry - Remove 2>/dev/null to surface potential parsing errors - Exit immediately with code 1 on failure so broken audit logging is not silently ignored Fixes #51 --- tests/integration/run-integration-tests.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration/run-integration-tests.sh b/tests/integration/run-integration-tests.sh index b14d9f0..347e4d9 100644 --- a/tests/integration/run-integration-tests.sh +++ b/tests/integration/run-integration-tests.sh @@ -399,10 +399,12 @@ TESTS+=("Query audit logs") AUDIT_LOGS=$(curl -sf "$AUDIT_SERVICE_URL/api/v1/audit/logs?page=1&page_size=5" \ -H "X-Internal-Key: $AUDIT_KEY") || AUDIT_LOGS="" AUDIT_COUNT=$(echo "$AUDIT_LOGS" | python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d.get('items',d.get('results',[]))))" 2>/dev/null) || AUDIT_COUNT="0" -if [ "$AUDIT_COUNT" -ge 0 ] 2>/dev/null; then - report_pass "Query audit logs ($AUDIT_COUNT entries)" +if [ "$AUDIT_COUNT" -gt 0 ]; then + echo " ${GREEN}PASS${NC} Found $AUDIT_COUNT audit log entries" + PASS=$((PASS + 1)) else - report_fail "Query audit logs" + echo " ${RED}FAIL${NC} No audit log entries found (expected at least 1)" + exit 1 fi # ────────────────────────────────────────────────────────────────────────────