Harden production workflows and agent admission
This commit is contained in:
35
server/tests/test_system_summary.py
Normal file
35
server/tests/test_system_summary.py
Normal 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
|
||||
Reference in New Issue
Block a user