test(AUDIT-WP-0008): exercise T02 driver over HTTP
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02991-be07-7bb3-8b6d-e9701b5621de
This commit is contained in:
parent
88b1adeabc
commit
83637965fd
2 changed files with 42 additions and 0 deletions
|
|
@ -1,9 +1,15 @@
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import sys
|
import sys
|
||||||
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from wsgiref.simple_server import WSGIRequestHandler, make_server
|
||||||
|
|
||||||
import pytest
|
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"
|
SCRIPT = Path(__file__).parents[1] / "scripts" / "t02_synthetic_load_driver.py"
|
||||||
SPEC = importlib.util.spec_from_file_location("t02_synthetic_load_driver", SCRIPT)
|
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"}
|
env = {"AUDIT_T02_FIXTURE_ID": "audit-t02-recovery-20260822"}
|
||||||
with pytest.raises(DRIVER.DriverError, match="not approved"):
|
with pytest.raises(DRIVER.DriverError, match="not approved"):
|
||||||
DRIVER.run_phase("cleanup", "some-other-contract", env=env)
|
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)
|
||||||
|
|
|
||||||
|
|
@ -561,6 +561,11 @@ Candidate receipt `7879bf65-06b7-4d0c-bbd1-873b6d20b7fc` pins driver revision
|
||||||
`sha256:941ba251f638869626b06e9cbf430c70188c0bdf4715e3eff9c7610366f68662`;
|
`sha256:941ba251f638869626b06e9cbf430c70188c0bdf4715e3eff9c7610366f68662`;
|
||||||
registration did not execute traffic or observe a secret. Live use still needs
|
registration did not execute traffic or observe a secret. Live use still needs
|
||||||
the separately approved sender identity, attended window, and abort operator.
|
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
|
```task
|
||||||
id: AUDIT-WP-0008-T08
|
id: AUDIT-WP-0008-T08
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue