From 83637965fdf6d819f1e9e496d6beda479c69889a Mon Sep 17 00:00:00 2001 From: tegwick Date: Sat, 22 Aug 2026 16:55:37 +0200 Subject: [PATCH] test(AUDIT-WP-0008): exercise T02 driver over HTTP Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02991-be07-7bb3-8b6d-e9701b5621de --- tests/test_t02_synthetic_load_driver.py | 37 +++++++++++++++++++ ...AUDIT-WP-0008-tenancy-posture-alignment.md | 5 +++ 2 files changed, 42 insertions(+) diff --git a/tests/test_t02_synthetic_load_driver.py b/tests/test_t02_synthetic_load_driver.py index 4120214..8185d65 100644 --- a/tests/test_t02_synthetic_load_driver.py +++ b/tests/test_t02_synthetic_load_driver.py @@ -1,9 +1,15 @@ import importlib.util import sys +import threading from pathlib import Path +from wsgiref.simple_server import WSGIRequestHandler, make_server import pytest +from audit_core.ingestion import IngestionApplication +from audit_core.senders import SenderIdentity, SenderRegistry +from audit_core.sqlite_backend import SQLiteAuditBackend + SCRIPT = Path(__file__).parents[1] / "scripts" / "t02_synthetic_load_driver.py" SPEC = importlib.util.spec_from_file_location("t02_synthetic_load_driver", SCRIPT) @@ -127,3 +133,34 @@ def test_wrong_contract_is_refused_without_reading_token(tmp_path): env = {"AUDIT_T02_FIXTURE_ID": "audit-t02-recovery-20260822"} with pytest.raises(DRIVER.DriverError, match="not approved"): DRIVER.run_phase("cleanup", "some-other-contract", env=env) + + +class QuietHandler(WSGIRequestHandler): + def log_message(self, format, *args): + pass + + +def test_real_receiver_accepts_then_reconciles_the_same_fixture(tmp_path): + env = environment(tmp_path) + registry = SenderRegistry([ + SenderIdentity( + name="t02-recovery", + tokens=("opaque-test-value",), + sources=frozenset({env["AUDIT_T02_SOURCE"]}), + tenants=frozenset({env["AUDIT_T02_TENANT"]}), + ) + ]) + app = IngestionApplication( + SQLiteAuditBackend(str(tmp_path / "events.db")), registry + ) + server = make_server("127.0.0.1", 0, app, handler_class=QuietHandler) + worker = threading.Thread(target=server.serve_forever, daemon=True) + worker.start() + env["AUDIT_T02_BASE_URL"] = f"http://127.0.0.1:{server.server_port}" + try: + config = DRIVER.load_config(env) + assert DRIVER.request_event(config) == (202, "accepted") + assert DRIVER.request_event(config) == (200, "duplicate") + finally: + server.shutdown() + worker.join(timeout=5) diff --git a/workplans/AUDIT-WP-0008-tenancy-posture-alignment.md b/workplans/AUDIT-WP-0008-tenancy-posture-alignment.md index 1232ee3..306991c 100644 --- a/workplans/AUDIT-WP-0008-tenancy-posture-alignment.md +++ b/workplans/AUDIT-WP-0008-tenancy-posture-alignment.md @@ -561,6 +561,11 @@ Candidate receipt `7879bf65-06b7-4d0c-bbd1-873b6d20b7fc` pins driver revision `sha256:941ba251f638869626b06e9cbf430c70188c0bdf4715e3eff9c7610366f68662`; registration did not execute traffic or observe a secret. Live use still needs the separately approved sender identity, attended window, and abort operator. +The unchanged registered driver subsequently passed a real local HTTP round +trip through audit-core with a dedicated scoped identity: the fixture returned +202 `accepted`, then 200 `duplicate` under the same idempotency key. The focused +driver suite is now 12 passing tests; a native full run passed 119 with 24 +environment-dependent skips. ```task id: AUDIT-WP-0008-T08