fix(ping): stop reporting every target alive
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m13s
driver / test (3.12) (pull_request) Successful in 4m9s
driver / test (3.13) (pull_request) Successful in 4m1s
driver / lowest (pull_request) Successful in 3m33s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m6s
CI / driver (pull_request) Successful in 5m49s
driver / publish (pull_request) Skipped

ping() returned three replies of 0 ms whenever the DAL accepted a
PINGTEST request, without reading any result, so a LAN scan through
this gateway marked every address alive. The DAL answer is only an
acknowledgement with no reply count, so ping() now returns NAPALM's
error reply without contacting the gateway and the driver opts out of
ping sweeps with SUPPORTS_PING = False.

Closes #2
This commit is contained in:
Christian Manivong committed 2026-11-01 21:56:45 +01:00
1 parent f7002114ae
commit fcee6d7ddd
4 files changed
+46 -23

No files matched your search

+28
View File
@@ -477,3 +477,31 @@ class TestEveryRequestHasATimeout:
driver._dal_query("LAN_HOSTS")
driver._fetch_page("Status.htm")
assert self._timeouts(session) == {7}
class TestPingReportsNoTargetAlive:
"""The DAL PINGTEST call only acknowledges the request; it carries no reply count."""
def _connected_driver(self):
driver = ZyxelVMGDriver("192.168.1.1", "admin", "password")
driver._session = MagicMock(spec=requests.Session)
driver._session.put.return_value = MockResponse({})
driver._sessionkey = "1"
driver._crypto = MagicMock()
driver._crypto.decrypt_response.return_value = {"result": "ZCFG_SUCCESS"}
return driver
def test_the_driver_opts_out_of_ping_sweeps(self):
assert ZyxelVMGDriver.supports_ping() is False
def test_an_accepted_request_is_not_a_reply(self):
driver = self._connected_driver()
reply = driver.ping("192.0.2.77")
assert "success" not in reply
assert reply["error"]
assert driver._parse_ping_reply("192.0.2.77", reply)["alive"] is False
def test_ping_starts_no_diagnostic_on_the_gateway(self):
driver = self._connected_driver()
driver.ping("192.0.2.77")
driver._session.put.assert_not_called()