Commit Graph

8 Commits

Author SHA1 Message Date
curo1305 cc2825b3b7 fix(phase-04): use MagicMock(spec=MinIOBackend) in test_daily_export_download
Plain MagicMock() failed the isinstance(backend, MinIOBackend) guard in
download_daily_export(), returning 404. spec=MinIOBackend sets __class__
so isinstance passes and the mock path executes correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 18:14:54 +02:00
curo1305 839bfe0ffe feat(06.2-04): backend — handle enrichment, user_handle filter, two daily-export endpoints
- Add _audit_to_dict_with_handles() with user_handle + actor_handle fields
- Add _build_filtered_query_with_handles() with aliased User double-JOIN
- Change list_audit_log user_id param to user_handle string with handle→UUID resolution
- Change export_audit_log user_id param to user_handle (Pitfall 7 — both endpoints enriched)
- Add GET /audit-log/daily-exports — lists MinIO audit-logs bucket, asyncio.to_thread
- Add GET /audit-log/daily-exports/{date} — streams CSV, date regex validation (T-06.2-04-01)
- Move daily-export endpoints before viewer to ensure specific path registration order
- Update test_audit_log_export_csv to match enriched CSV header (user_handle, actor_handle)
- All 10 test_audit.py tests pass
2026-05-31 15:17:53 +02:00
curo1305 d7cfc5ccee test(06.2-04): add failing tests for handle enrichment, user_handle filter, daily exports
- test_audit_log_includes_user_handle: asserts user_handle/actor_handle in items
- test_audit_log_filter_by_handle: asserts filtering by handle works correctly
- test_audit_log_filter_unknown_handle: asserts 200+empty for unknown handle
- test_daily_exports_list: mocks MinIO list_objects, asserts sorted items
- test_daily_export_download: mocks MinIO get_object, asserts CSV response + 404 on bad date
2026-05-31 15:15:46 +02:00
curo1305 7271eeb53c test(06.2-01): add xfail stubs for ADMIN-06 audit enrichment + daily exports (Task 3)
- test_audit_log_includes_user_handle: user_handle and actor_handle in audit items (D-11)
- test_audit_log_filter_by_handle: user_handle query param filters entries (D-12)
- test_audit_log_filter_unknown_handle: unknown handle returns empty list, not 422 (D-12)
- test_daily_exports_list: daily-exports listing endpoint returns {items} (D-15)
- test_daily_export_download: daily export download returns CSV bytes with Content-Disposition (D-16)
2026-05-31 11:58:05 +02:00
curo1305 451fff1e4d test(6.1): add audit filter behavioral test (ADMIN-06 SC3)
Verifies event_type filter returns only matching entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 23:30:05 +02:00
curo1305 57784f9f80 fix(6.1): close WR-01/WR-02 code review findings in test_audit.py
WR-01: extend nested metadata_ forbidden-key check to all 4 keys
WR-02: assert no forbidden fields in CSV export body (D-15)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 23:24:26 +02:00
curo1305 bda123db8d feat(6.1-02): promote test_audit.py stubs to real tests (ADMIN-06)
- Replace all 4 @pytest.mark.xfail stubs with real assertions
- Add _seed_audit() helper calling write_audit_log() + commit
- test_audit_log_viewer: verifies paginated JSON shape and total >= 1
- test_audit_log_no_doc_content: asserts no filename/extracted_text in items
- test_audit_log_regular_user_403: asserts 403 for regular users
- test_audit_log_export_csv: asserts text/csv content-type and CSV header line
- Remove unused 'import os'
- Add pytestmark = pytest.mark.asyncio at module level
2026-05-30 23:10:14 +02:00
curo1305 c8a0443ad2 feat(04-01): add Wave 0 xfail stubs for DOC-02, ADMIN-06, SEC-08, SEC-09
- test_documents.py: append 4 stubs (content_stream 200, 206, admin_403, no_presigned_url)
- test_audit.py: create new file with 4 stubs (viewer, no_doc_content, user_403, export_csv)
- test_security.py: create new file with 2 stubs (credentials_enc_not_in_response, delete_user_cleans_files)
- All stubs: xfail(strict=False), body is pytest.xfail("not implemented yet")
2026-05-25 18:25:18 +02:00