fix(snmp): open the REST side session's SSH on port 22
configure_snmp_agent over the REST API opened its temporary SSH session on optional_args["port"], which names the REST API's port when REST is the transport. It now uses port 22, as the running-config fallback already did. The second finding of the issue, the unverified REST certificate, needs a decision and stays open. Refs #17
This commit is contained in:
1 parent
58428042f1
commit
874e25a1ce
3 files changed
+24
-6
No files matched your search
@@ -104,7 +104,7 @@ def test_the_config_fallback_checks_the_key_of_port_22():
|
||||
|
||||
def test_the_snmp_fix_over_rest_stops_at_a_changed_key():
|
||||
seen: list = []
|
||||
driver = _driver(seen, {"443": SshHostKey.of(OTHER_KEY).as_dict()}, port=443)
|
||||
driver = _driver(seen, {"22": SshHostKey.of(OTHER_KEY).as_dict()}, port=443)
|
||||
driver._transport = "api"
|
||||
driver._api = MagicMock()
|
||||
with patch(HANDLER, side_effect=_refuse) as handler:
|
||||
@@ -112,3 +112,16 @@ def test_the_snmp_fix_over_rest_stops_at_a_changed_key():
|
||||
assert result["success"] is False
|
||||
assert handler.call_count == 1
|
||||
assert "host key" in str(result)
|
||||
|
||||
|
||||
def test_the_snmp_fix_over_rest_opens_ssh_on_port_22_not_the_api_port():
|
||||
"""``port`` is the REST API's port when REST is the transport (#17)."""
|
||||
seen: list = []
|
||||
driver = _driver(seen, {"22": SshHostKey.of(SERVER_KEY).as_dict()}, port=443)
|
||||
driver._transport = "api"
|
||||
driver._api = MagicMock()
|
||||
with patch(HANDLER, return_value=_device()) as handler:
|
||||
driver.configure_snmp_agent({"community": "c0mm", "allowed_sources": []})
|
||||
assert handler.call_args.kwargs["port"] == 22
|
||||
assert handler.call_args.kwargs["ssh_strict"] is True
|
||||
assert (seen[0]["port"], seen[0]["accepted"]) == (22, True)
|
||||
Reference in new issue
Block a user