feat: background remote agent updates survive SAC navigation (0.20.19)

This commit is contained in:
PTah
2026-06-21 11:01:26 +10:00
parent d7bbcc5337
commit 5635be1322
16 changed files with 642 additions and 161 deletions
+7 -4
View File
@@ -3,6 +3,8 @@
from datetime import datetime, timezone
from unittest.mock import patch
from sqlalchemy import inspect as sa_inspect
from app.models import Event, Host
from app.services.winrm_connect import WinRmCmdResult
@@ -47,6 +49,7 @@ def test_qwinsta_via_winrm_on_client_host(jwt_headers, client, db_session, monke
gw = Host(hostname="K6A-DC3", os_family="windows", product="rdp-login-monitor", ipv4="192.168.160.40")
db_session.add_all([ws, gw])
db_session.commit()
ws_id = ws.id
event = _flap_event(db_session, gw=gw, ws=ws)
qwinsta_out = " SESSIONNAME USERNAME ID STATE\r\n rdp-tcp#0 B26\\papatramp 2 Active\r\n"
@@ -63,6 +66,10 @@ def test_qwinsta_via_winrm_on_client_host(jwt_headers, client, db_session, monke
["Andrisonova-PC=OK"],
)
response = client.post(f"/api/v1/events/{event.id}/actions/qwinsta", headers=jwt_headers)
mock_run.assert_called_once()
called_identity = sa_inspect(mock_run.call_args.args[0]).identity
assert called_identity is not None
assert called_identity[0] == ws_id
assert response.status_code == 200
body = response.json()
@@ -71,10 +78,6 @@ def test_qwinsta_via_winrm_on_client_host(jwt_headers, client, db_session, monke
assert body["target"] == "Andrisonova-PC"
assert "papatramp" in (body["result_stdout"] or "")
mock_run.assert_called_once()
called_host = mock_run.call_args.args[0]
assert called_host.hostname == "Andrisonova-PC"
def test_qwinsta_client_not_in_hosts(jwt_headers, client, db_session, monkeypatch):
monkeypatch.setenv("SAC_WIN_ADMIN_USER", r"B26\admin")