Harden production workflows and agent admission

This commit is contained in:
Stanislav Rossovskii
2026-05-28 14:19:27 +04:00
parent a2e88b4e76
commit 37b1a1d6d6
109 changed files with 4927 additions and 894 deletions

View File

@@ -0,0 +1,35 @@
import pytest
from ._helpers import make_event, register_agent
@pytest.mark.asyncio
async def test_system_summary_aggregate(app_client, ui_auth_headers):
auth_headers = await register_agent(app_client, ui_auth_headers, "agent-1")
await register_agent(app_client, ui_auth_headers, "agent-2")
ev = make_event(check_id="c1", status="critical", exit_code=2)
await app_client.post(
"/api/v1/events",
json={"agent_id": "agent-1", "events": [ev]},
headers=auth_headers,
)
r = await app_client.get("/api/v1/system-summary", headers=ui_auth_headers)
assert r.status_code == 200
body = r.json()
assert body["agents_online"] == 2
assert body["agents_offline"] == 0
assert body["checks_critical"] >= 1
assert "generated_at" in body
@pytest.mark.asyncio
async def test_system_summary_requires_auth(app_client):
r = await app_client.get("/api/v1/system-summary")
assert r.status_code == 401
@pytest.mark.asyncio
async def test_outbox_invalid_state_400(app_client, ui_auth_headers):
r = await app_client.get("/api/v1/notifiers/outbox?state=bogus", headers=ui_auth_headers)
assert r.status_code == 400