Skip to content

test: add tests for NetworkPolicyEngine audit export and clear (closes #2447) - #2452

Open
tmdeveloper007 wants to merge 2 commits into
utksh1:mainfrom
tmdeveloper007:#2447
Open

test: add tests for NetworkPolicyEngine audit export and clear (closes #2447)#2452
tmdeveloper007 wants to merge 2 commits into
utksh1:mainfrom
tmdeveloper007:#2447

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary

Adds unit tests for NetworkPolicyEngine.export_audit_log and
NetworkPolicyEngine.clear_audit_entries in backend.secuscan.network_policy.

Changes

  • New test file: testing/backend/unit/test_network_policy_audit_export.py
  • 11 tests covering: JSON export, CSV export, empty-log edge cases,
    clear entries, post-clear independence

Testing

  • All 11 tests pass with python -m pytest testing/backend/unit/test_network_policy_audit_export.py --noconftest -v

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: this test module also mutates the module-level singleton without restoring it and hard-codes a temporary filesystem path for its audit file. Use the pytest temporary-path fixture plus a fixture that restores singleton state after each test. Parse CSV with Python csv instead of splitting on newlines, and remove the unused pytest import.

@utksh1 utksh1 added area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants