feat: host session list/terminate and event session actions (0.20.28)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,6 @@ from app.version import APP_NAME, APP_VERSION, APP_VERSION_LABEL
|
||||
|
||||
|
||||
def test_version_constants():
|
||||
assert APP_VERSION == "0.20.27"
|
||||
assert APP_VERSION == "0.20.28"
|
||||
assert APP_NAME == "Security Alert Center"
|
||||
assert APP_VERSION_LABEL == "Security Alert Center v.0.20.27"
|
||||
assert APP_VERSION_LABEL == "Security Alert Center v.0.20.28"
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Tests for host session list/parse helpers."""
|
||||
|
||||
from app.services.host_sessions import (
|
||||
event_supports_session_terminate,
|
||||
parse_loginctl_sessions,
|
||||
parse_qwinsta_sessions,
|
||||
)
|
||||
|
||||
|
||||
def test_parse_loginctl_sessions():
|
||||
stdout = "c1 1000 alice seat0 pts/0 active -\n 2 1001 bob - tty2 active -\n"
|
||||
rows = parse_loginctl_sessions(stdout)
|
||||
assert len(rows) == 2
|
||||
assert rows[0].session_id == "c1"
|
||||
assert rows[0].user == "alice"
|
||||
assert rows[0].tty == "pts/0"
|
||||
|
||||
|
||||
def test_parse_qwinsta_sessions_filters_user():
|
||||
stdout = """SESSIONNAME USERNAME ID STATE
|
||||
console Administrator 1 Active
|
||||
rdp-tcp#0 B26\\alice 2 Active
|
||||
"""
|
||||
all_rows = parse_qwinsta_sessions(stdout)
|
||||
assert len(all_rows) == 2
|
||||
filtered = parse_qwinsta_sessions(stdout, filter_user="alice")
|
||||
assert len(filtered) == 1
|
||||
assert filtered[0].session_id == "2"
|
||||
|
||||
|
||||
def test_event_supports_session_terminate_types():
|
||||
class HostStub:
|
||||
os_family = "linux"
|
||||
product = "ssh-monitor"
|
||||
|
||||
class EventStub:
|
||||
def __init__(self, event_type: str):
|
||||
self.type = event_type
|
||||
self.host = HostStub()
|
||||
|
||||
assert event_supports_session_terminate(EventStub("ssh.login.success")) is True
|
||||
Reference in New Issue
Block a user