Add actor-aware Butler activity log (tests/test_app.py)
This commit is contained in:
parent
ef4fd59197
commit
6620384dc4
1 changed files with 33 additions and 0 deletions
|
|
@ -266,6 +266,39 @@ def test_audit_persists_and_redacts_secrets(tmp_path, monkeypatch):
|
||||||
assert entry["detail"].count("[REDACTED]") == 3
|
assert entry["detail"].count("[REDACTED]") == 3
|
||||||
|
|
||||||
|
|
||||||
|
def test_audit_records_ai_and_web_ui_actor(tmp_path, monkeypatch):
|
||||||
|
db = tmp_path / "audit.sqlite3"
|
||||||
|
monkeypatch.setattr(app, "AUDIT_DB_PATH", str(db))
|
||||||
|
|
||||||
|
async def empty_status():
|
||||||
|
return {}
|
||||||
|
|
||||||
|
monkeypatch.setattr(app, "_collect_service_status", empty_status)
|
||||||
|
app._ui_sessions.clear()
|
||||||
|
with TestClient(app.app) as client:
|
||||||
|
ai = client.get(
|
||||||
|
"/status",
|
||||||
|
headers={"Authorization": "Bearer test-token", "X-Butler-Actor": "Trulla"},
|
||||||
|
)
|
||||||
|
assert ai.status_code == 200
|
||||||
|
|
||||||
|
client.headers.pop("Authorization", None)
|
||||||
|
client.get("/ui/session")
|
||||||
|
web = client.get("/status")
|
||||||
|
assert web.status_code == 200
|
||||||
|
|
||||||
|
entries = client.get("/audit").json()
|
||||||
|
|
||||||
|
assert [item["actor"] for item in entries[:2]] == ["Weboberfläche", "Trulla"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_ui_audit_has_actor_column_and_filter():
|
||||||
|
with TestClient(app.app) as client:
|
||||||
|
response = client.get("/ui")
|
||||||
|
assert '<th>Akteur</th>' in response.text
|
||||||
|
assert 'id="audit-actor"' in response.text
|
||||||
|
|
||||||
|
|
||||||
def test_wireguard_status_returns_redacted_live_state(monkeypatch):
|
def test_wireguard_status_returns_redacted_live_state(monkeypatch):
|
||||||
payload = {
|
payload = {
|
||||||
"interface": "wg0",
|
"interface": "wg0",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue