driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 19s
driver / types (pull_request) Successful in 1m9s
driver / test (3.13) (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m7s
driver / lowest (pull_request) Successful in 28s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Successful in 2m25s
driver / publish (pull_request) Skipped
The switch offers diffie-hellman-group14-sha256 and group16-sha512 only, and paramiko picks group16. On an SG2210P with firmware 5.30 that 4096-bit exchange takes 9 to 16 seconds, against netmiko's 10-second conn_timeout: paramiko then tries to log in on a transport whose key exchange has not finished and fails with "No existing session", so every other poll failed and netOrk flapped the switch between online and offline. group14 takes 1.5 seconds. group16 is now disabled by default; a disabled_algorithms passed in optional_args still wins. The netmiko arguments move into _ssh.py, so tplink_jetstream.py keeps its recorded length.
27 lines
956 B
Python
27 lines
956 B
Python
"""open() keeps the switch off the 4096-bit DH group, whose key exchange outlasts conn_timeout."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from napalm_tplink_jetstream.tplink_jetstream import TPLinkJetstreamDriver
|
|
|
|
HANDLER = "napalm_tplink_jetstream.tplink_jetstream.ConnectHandler"
|
|
|
|
|
|
def _connect_kwargs(optional_args: dict | None = None) -> dict:
|
|
with patch(HANDLER, return_value=MagicMock()) as handler:
|
|
TPLinkJetstreamDriver("10.0.0.8", "admin", "s3cret", optional_args=optional_args).open()
|
|
return handler.call_args.kwargs
|
|
|
|
|
|
def test_group16_is_disabled_by_default():
|
|
kwargs = _connect_kwargs()
|
|
assert kwargs["disabled_algorithms"] == {"kex": ["diffie-hellman-group16-sha512"]}
|
|
|
|
|
|
def test_disabled_algorithms_from_the_caller_win():
|
|
own = {"kex": [], "ciphers": ["3des-cbc"]}
|
|
kwargs = _connect_kwargs({"disabled_algorithms": own})
|
|
assert kwargs["disabled_algorithms"] == own
|