mirror of
https://github.com/hansjone/netx.git
synced 2026-10-10 12:40:44 +08:00
Fix Huawei WebCRT hop login echo doubling and safer Change-now handling.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
cacd8c7b75
commit
0a550abcb0
9 changed files with 498 additions and 77 deletions
|
|
@ -131,6 +131,30 @@ class HuaweiStelnetAuthTests(unittest.TestCase):
|
|||
sent = [c.args[1] for c in mock_send.call_args_list]
|
||||
self.assertEqual(sent, ["ipran", "Y", "N", "secret"])
|
||||
|
||||
@patch("netx_api.ne_session_connect._read_channel")
|
||||
@patch("netx_api.ne_session_connect._send_line")
|
||||
def test_answers_password_change_after_login(
|
||||
self,
|
||||
mock_send: MagicMock,
|
||||
mock_read: MagicMock,
|
||||
) -> None:
|
||||
"""Huawei ``Change now? [Y/N]:`` after password must not hang auth until timeout."""
|
||||
chunks = [
|
||||
"Please input the username:",
|
||||
"Enter password:",
|
||||
"Change now? [Y/N]:",
|
||||
"<HW-TARGET>\n",
|
||||
]
|
||||
mock_read.side_effect = lambda *_a, **_k: chunks.pop(0) if chunks else ""
|
||||
conn = MagicMock()
|
||||
seen: list[str] = []
|
||||
_interactive_target_auth(conn, "admin", "secret", progress_cb=seen.append)
|
||||
self.assertEqual(
|
||||
[c.args[1] for c in mock_send.call_args_list],
|
||||
["admin", "secret", "N"],
|
||||
)
|
||||
self.assertTrue(any("password-change" in p for p in seen))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue