mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 04:20:45 +08:00
Dedupe WebCRT command audit on double-fired Enter.
xterm and keydown can both emit carriage return for one keypress; skip duplicate Enter frames on the client and collapse identical audits within 450ms on the server. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7ca57278fe
commit
52424dce37
3 changed files with 58 additions and 1 deletions
|
|
@ -282,6 +282,30 @@ class SessionCommandAuditTests(unittest.TestCase):
|
|||
sess.write_stdin("\r", audit_line="AL5458-ACC-6120HS(config-if-loopback127)#")
|
||||
mock_audit.assert_not_called()
|
||||
|
||||
@patch("netx_api.webcrt_session_model._audit")
|
||||
def test_duplicate_enter_same_command_deduped(self, mock_audit: MagicMock) -> None:
|
||||
conn = MagicMock()
|
||||
conn.RETURN = "\n"
|
||||
conn.remote_conn = MagicMock(spec=["recv_ready", "recv", "exit_status_ready", "resize_pty"])
|
||||
del conn.remote_conn.send
|
||||
conn.write_channel = MagicMock()
|
||||
|
||||
sess = WebcrtSession(
|
||||
session_id="s-dedup",
|
||||
ne_id="ne1",
|
||||
ne_name="lab",
|
||||
ne_ip="1.2.3.4",
|
||||
protocol="ssh",
|
||||
cols=80,
|
||||
rows=24,
|
||||
cli_keymap=False,
|
||||
conn=conn,
|
||||
)
|
||||
line = "AL5458-ACC-6120HS(config)#intt"
|
||||
sess.write_stdin("\r", audit_line=line)
|
||||
sess.write_stdin("\r", audit_line=line)
|
||||
self.assertEqual(mock_audit.call_count, 1)
|
||||
|
||||
@patch("netx_api.webcrt_session_model._audit")
|
||||
def test_password_mode_redacts_command(self, mock_audit: MagicMock) -> None:
|
||||
conn = MagicMock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue