umbau 1.0
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
import aiosqlite
|
||||
|
||||
@ -50,6 +52,37 @@ async def test_tamper_detected_after_direct_update():
|
||||
await conn.close()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_chain_intact_after_concurrent_writes():
|
||||
"""E1 (Umsetzungsauftrag_Sonnet5.md Teil E.1): mehrere gleichzeitig
|
||||
laufende Aufrufe (z.B. Sitzungsstart/-ende zweier Benutzer im selben
|
||||
Moment) duerfen den prev_hash niemals doppelt vergeben -- sonst bricht
|
||||
die Kette dauerhaft ab (audit_log erlaubt kein UPDATE/DELETE)."""
|
||||
conn = await _fresh_db()
|
||||
|
||||
n = 40
|
||||
|
||||
async def _write(i: int) -> None:
|
||||
await write_audit_event(
|
||||
conn,
|
||||
event_type="test_event",
|
||||
user_id=None,
|
||||
client_ip="127.0.0.1",
|
||||
details={"i": i},
|
||||
)
|
||||
|
||||
await asyncio.gather(*(_write(i) for i in range(n)))
|
||||
|
||||
cursor = await conn.execute("SELECT COUNT(*) FROM audit_log")
|
||||
(count,) = await cursor.fetchone()
|
||||
assert count == n
|
||||
|
||||
intact, broken_at = await verify_chain(conn)
|
||||
assert intact is True
|
||||
assert broken_at is None
|
||||
await conn.close()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_append_only_trigger_blocks_update():
|
||||
conn = await _fresh_db()
|
||||
|
||||
Reference in New Issue
Block a user