fix(sre): close durable audit and telegram receipt races
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 6m36s
CD Pipeline / build-and-deploy (push) Successful in 15m16s
CD Pipeline / post-deploy-checks (push) Failing after 10m29s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 30s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Failing after 12m42s
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 6m36s
CD Pipeline / build-and-deploy (push) Successful in 15m16s
CD Pipeline / post-deploy-checks (push) Failing after 10m29s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 30s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Failing after 12m42s
This commit is contained in:
@@ -28,15 +28,19 @@ class _CaptureDb:
|
||||
self.calls.append((statement, params))
|
||||
|
||||
|
||||
def _assert_jsonb_bind_contract(db: _CaptureDb) -> None:
|
||||
def _assert_immutable_audit_jsonb_bind_contract(db: _CaptureDb) -> None:
|
||||
assert len(db.calls) == 1
|
||||
statement, params = db.calls[0]
|
||||
normalized_sql = " ".join(str(statement).split())
|
||||
assert ":details::jsonb" not in normalized_sql
|
||||
assert "CAST(:details AS JSONB)" in normalized_sql
|
||||
assert "details" in statement._bindparams
|
||||
assert "detail" not in statement._bindparams
|
||||
assert json.loads(params["details"])["result"] == "verified"
|
||||
assert "INSERT INTO alert_operation_log" in normalized_sql
|
||||
assert "INSERT INTO audit_logs" not in normalized_sql
|
||||
assert ":context::jsonb" not in normalized_sql
|
||||
assert "CAST(:context AS JSONB)" in normalized_sql
|
||||
assert "context" in statement._bindparams
|
||||
assert "details" not in statement._bindparams
|
||||
context = json.loads(params["context"])
|
||||
assert context["schema_version"] == "awooop_sanitized_audit_v1"
|
||||
assert context["details"]["result"] == "verified"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -62,7 +66,7 @@ async def test_audit_sink_uses_asyncpg_safe_jsonb_bind(
|
||||
trace_id="trace-1",
|
||||
)
|
||||
|
||||
_assert_jsonb_bind_contract(db)
|
||||
_assert_immutable_audit_jsonb_bind_contract(db)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -86,4 +90,4 @@ async def test_contract_service_uses_asyncpg_safe_jsonb_bind(
|
||||
details={"result": "verified"},
|
||||
)
|
||||
|
||||
_assert_jsonb_bind_contract(db)
|
||||
_assert_immutable_audit_jsonb_bind_contract(db)
|
||||
|
||||
Reference in New Issue
Block a user