fix: RDG event label and prefix type filter (0.3.2)
Use event 302/303 instead of Win302 in RDG titles. Match event types by prefix in events list (e.g. rdg.connection). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""Tests for GET /api/v1/events filters."""
|
||||
|
||||
import uuid
|
||||
|
||||
VALID_RDG = {
|
||||
"schema_version": "1.0",
|
||||
"occurred_at": "2026-05-27T10:00:00+03:00",
|
||||
"source": {"product": "rdp-login-monitor", "product_version": "1.2.3-SAC"},
|
||||
"host": {"hostname": "gw-filter-test", "os_family": "windows"},
|
||||
"category": "auth",
|
||||
"severity": "info",
|
||||
"title": "RDG",
|
||||
"summary": "pytest",
|
||||
}
|
||||
|
||||
|
||||
def _ingest(client, auth_headers, *, event_type: str) -> str:
|
||||
event_id = str(uuid.uuid4())
|
||||
payload = {**VALID_RDG, "event_id": event_id, "type": event_type}
|
||||
assert client.post("/api/v1/events", json=payload, headers=auth_headers).status_code == 201
|
||||
return event_id
|
||||
|
||||
|
||||
def test_events_type_filter_prefix(client, auth_headers, jwt_headers):
|
||||
success_id = _ingest(client, auth_headers, event_type="rdg.connection.success")
|
||||
disconnected_id = _ingest(client, auth_headers, event_type="rdg.connection.disconnected")
|
||||
other_id = _ingest(client, auth_headers, event_type="rdp.login.success")
|
||||
|
||||
listed = client.get(
|
||||
"/api/v1/events",
|
||||
headers=jwt_headers,
|
||||
params={"type": "rdg.connection", "hostname": "gw-filter-test", "page_size": 50},
|
||||
)
|
||||
assert listed.status_code == 200
|
||||
body = listed.json()
|
||||
ids = {row["event_id"] for row in body["items"]}
|
||||
assert success_id in ids
|
||||
assert disconnected_id in ids
|
||||
assert other_id not in ids
|
||||
|
||||
|
||||
def test_events_type_filter_exact_still_works(client, auth_headers, jwt_headers):
|
||||
success_id = _ingest(client, auth_headers, event_type="rdg.connection.success")
|
||||
disconnected_id = _ingest(client, auth_headers, event_type="rdg.connection.disconnected")
|
||||
|
||||
listed = client.get(
|
||||
"/api/v1/events",
|
||||
headers=jwt_headers,
|
||||
params={"type": "rdg.connection.success", "hostname": "gw-filter-test", "page_size": 50},
|
||||
)
|
||||
assert listed.status_code == 200
|
||||
ids = {row["event_id"] for row in listed.json()["items"]}
|
||||
assert success_id in ids
|
||||
assert disconnected_id not in ids
|
||||
@@ -4,6 +4,6 @@ from app.version import APP_NAME, APP_VERSION, APP_VERSION_LABEL
|
||||
|
||||
|
||||
def test_version_constants():
|
||||
assert APP_VERSION == "0.3.1"
|
||||
assert APP_VERSION == "0.3.2"
|
||||
assert APP_NAME == "Security Alert Center"
|
||||
assert APP_VERSION_LABEL == "Security Alert Center v.0.3.1"
|
||||
assert APP_VERSION_LABEL == "Security Alert Center v.0.3.2"
|
||||
|
||||
@@ -85,6 +85,7 @@ def test_build_rdg_display_title_and_path(db_session, monkeypatch):
|
||||
assert display.qwinsta_enabled is True
|
||||
assert "papatramp" in display.summary
|
||||
assert "шлюз K6A-DC3" in display.summary
|
||||
assert "event 302" in display.title
|
||||
|
||||
|
||||
def test_event_to_summary_enriches_rdg(db_session, monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user