Audit trail

This commit is contained in:
2026-08-26 19:52:22 +02:00
parent ed76b35600
commit 314959c7bf
10 changed files with 103 additions and 13 deletions
+20
View File
@@ -266,6 +266,26 @@ def test_admin_can_reset_another_users_otp():
assert client.post('/api/admin/users/missing-user/otp/reset', headers=admin_headers).status_code == 404
def test_security_audit_events_are_append_only_and_do_not_store_secrets():
admin_headers = login_headers()
response = client.put('/api/admin/themes', headers=admin_headers, json={'themes': ['plain-day']})
assert response.status_code == 200
with get_connection() as conn:
event = conn.execute(
'''SELECT actor_id, action, target_type, outcome, details
FROM security_audit_events
WHERE action = 'themes_updated'
ORDER BY created_at DESC, rowid DESC LIMIT 1''',
).fetchone()
assert event is not None
assert event['actor_id'] == 'user-1'
assert event['target_type'] == 'application'
assert event['outcome'] == 'success'
assert 'password' not in event['details'].lower()
assert 'token' not in event['details'].lower()
assert 'secret' not in event['details'].lower()
def test_new_user_must_verify_email_before_login():
headers = login_headers()
username = f'unverified-{uuid4().hex}'