test : add unit tests for NetworkPolicyEngine audit export methods
@Rafiaminhaj ya está trabajando en esto.
Desde el 15/8/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Summary of What Needs to be Done:
Add unit tests for the export_audit_log and clear_audit_entries methods of NetworkPolicyEngine in backend/secuscan/network_policy.py. These methods are not covered by the existing test_network_policy.py suite which focuses on check_access and policy enforcement logic.
The methods require patching the backend.secuscan.config module (which imports Pydantic) so the engine can be instantiated with test settings. Both methods have substantial logic worth testing: export_audit_log formats audit entries as JSON or CSV, and clear_audit_entries removes all entries from memory.
Changes that Need to be Made:
Create testing/backend/unit/test_network_policy_audit_export.py:
- Patch
sys.modules['backend.secuscan.config']with a mock config module before importingNetworkPolicyEngineandPolicyAction export_audit_log(format="json"): Test that it returns valid JSON with expected fields (timestamp, plugin_id, task_id, action, dest_ip, dest_port, reason)export_audit_log(format="csv"): Test that it returns valid CSV with header row and data rowsexport_audit_log(format="csv"): Test that empty audit log produces just the header rowclear_audit_entries(): Test that it removes all entries after entries have been addedclear_audit_entries(): Test that calling it on an already-empty log is safe (no exception)get_audit_entries()as a companion: verify it returns entries before clear and empty list after- Use a temp file path for
audit_log_pathandmax_audit_entries=1000in the engine constructor - Import the real production class directly (not mocked)
- Run with
python3 -m pytest testing/backend/unit/test_network_policy_audit_export.py -v --noconftest
Impact that it would Provide:
- Tests audit log export functionality that is currently completely untested
- Prevents regressions in the JSON and CSV export formatting logic
- Ensures the clear operation is idempotent and safe on empty state
- Complements the existing
TestAuditLoggingclass which only tests audit entry creation, not export/clear
Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.
- Lenguaje dominante
- Python
- Estrellas
- 36
- Forks
- 234
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de utksh1/SecuScan
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
area:frontend good first issue level:beginner priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
area:frontend good first issue level:intermediate priority:low type:testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Todos los issues de utksh1/SecuScan
Issues similares
-
[BUG] HTTP lifecycle dispatch treats a NO_PROXY-only environment as corporate egress and skips the resolve-and-pinned sessionPosiblemente ocupada @bodapatisaikrishna la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[integration]: NoMacSandboxAbiertoexternal
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
langchain-ai/docs#7652 ·
Los mantenedores suelen responder en 1 día
-
[oblt-aw][autodoc] Document new e2e-secret-leak-artifacts workflow and update e2e-all leaf listAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
elastic/oblt-aw#2513 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
amd/gaia#7326 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
NCAR/CLM-Tutorial#113 · 1 comentario ·
Los mantenedores suelen responder en 1 día