trustgraph/tests/unit/test_base
cybermaggedon d5f3b6d9f6
feat: add structured audit event system (#1027)
Add a complete audit event pipeline that emits structured, machine-
parseable events for every gateway request and IAM decision.

Schema and publisher:
- AuditEvent dataclass and notify-class queue (audit_events_queue)
- AuditPublisher utility: fire-and-forget emission with envelope
  (schema_version, event_id, event_type, timestamp, producer)
- New request_id and client_ip fields on IamRequest for correlation

Gateway (gateway.request events):
- aiohttp middleware assigns request_id, captures timing/status/sizes
  and emits an event after every HTTP request completes
- IamAuth.authenticate annotates the request with identity
- Main endpoint handlers annotate capability and workspace
- request_id and client_ip forwarded to IAM on authenticate/authorise

IAM service (iam.authenticate, iam.authorise, iam.management events):
- Emits iam.authenticate for resolve-api-key, login, anonymous auth
- Emits iam.authorise for authorise and authorise-many decisions
- Emits iam.management for user/workspace/key mutations
- All events include request_id for correlation with gateway events

Design: events land on a pub/sub notify topic — non-persistent,
per-subscriber delivery. If no audit consumer is deployed, events
are silently discarded. Storage, retention, and alerting are
consumer-side concerns outside this boundary.

Added unit tests for the publisher and gateway middleware, unit
tests for IAM audit emission, and a contract test for the AuditEvent
schema.

Tech spec: docs/tech-specs/audit-events.md
2026-07-06 10:47:49 +01:00
..
test_async_processor.py Fix tests (#593) 2025-12-19 08:53:21 +00:00
test_async_processor_config.py feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840) 2026-04-21 23:23:01 +01:00
test_audit_publisher.py feat: add structured audit event system (#1027) 2026-07-06 10:47:49 +01:00
test_cassandra_config.py fix: wire replication params through YAML/params path for Cassandra and Qdrant (#976) 2026-06-04 12:36:36 +01:00
test_document_embeddings_client.py feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840) 2026-04-21 23:23:01 +01:00
test_flow_base_modules.py feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840) 2026-04-21 23:23:01 +01:00
test_flow_parameter_specs.py feat: workspace-based multi-tenancy, replacing user as tenancy axis (#840) 2026-04-21 23:23:01 +01:00
test_flow_processor.py Per-workspace queue routing for workspace-scoped services (#862) 2026-05-04 10:30:03 +01:00
test_i18n.py Feat: TrustGraph i18n & Documentation Translation Updates (#781) 2026-04-14 12:08:32 +01:00
test_llm_service_parameters.py More LLM param test coverage (#535) 2025-09-26 01:00:30 +01:00
test_logging.py Fix tests broken by the recent RabbitMQ/Cassandra async fixes (#815) 2026-04-16 10:00:18 +01:00
test_metrics.py Fix test suite Prometheus registry pollution and remove default (#806) 2026-04-14 11:07:23 +01:00
test_prompt_client_streaming.py feat: replace LLM edge scoring with cross-encoder reranker in GraphRAG (#1005) 2026-06-30 14:36:37 +01:00
test_publisher_graceful_shutdown.py Fix tests (#593) 2025-12-19 08:53:21 +00:00
test_qdrant_config.py fix: wire replication params through YAML/params path for Cassandra and Qdrant (#976) 2026-06-04 12:36:36 +01:00
test_subscriber_graceful_shutdown.py Fix test suite Prometheus registry pollution and remove default (#806) 2026-04-14 11:07:23 +01:00
test_subscriber_readiness.py Fix RabbitMQ request/response race and chunker Flow API drift (#779) 2026-04-11 01:29:38 +01:00