fix(snmp): report no community instead of inventing "public"
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 56s
driver / test (3.12) (pull_request) Successful in 57s
driver / test (3.13) (pull_request) Successful in 51s
driver / lowest (pull_request) Successful in 25s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m28s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 56s
driver / test (3.12) (pull_request) Successful in 57s
driver / test (3.13) (pull_request) Successful in 51s
driver / lowest (pull_request) Successful in 25s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m28s
driver / publish (pull_request) Skipped
get_snmp_config started from community "public" and returned it with running=True when no row of the community table parsed. Without a listed community it now reports the agent as not running, as it already did for "no community entry exists". The issue's other two points were already fixed on main: the management VLAN is matched exactly sincec2f0f7c(_management_vlan, with the caller's listen address), and the floor on napalm-device-types is 4.21.1 with no requirements.txt since4e171bf. Closes #3
This commit is contained in:
1 parent
f515859472
commit
34f00f9f3a
4 files changed
+55
-16
No files matched your search
@@ -27,9 +27,7 @@
|
||||
"napalm_tplink_jetstream.tplink_jetstream"
|
||||
],
|
||||
"python_file_lines": {
|
||||
"napalm_tplink_jetstream/tplink_jetstream.py": 2027
|
||||
"napalm_tplink_jetstream/tplink_jetstream.py": 2024
|
||||
},
|
||||
"untyped_public": [
|
||||
"napalm_tplink_jetstream/tplink_jetstream.py::TPLinkJetstreamDriver.get_snmp_config"
|
||||
]
|
||||
"untyped_public": []
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
"""get_snmp_config reports the community the switch lists, never one it made up (#3).
|
||||
|
||||
It started from "public" and kept it when no table row parsed, so a switch
|
||||
whose community table could not be read reported a running agent with the
|
||||
community "public".
|
||||
"""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from napalm_tplink_jetstream.tplink_jetstream import TPLinkJetstreamDriver
|
||||
|
||||
|
||||
def _driver(output: str) -> TPLinkJetstreamDriver:
|
||||
driver = TPLinkJetstreamDriver("10.0.0.30", "admin", "pw")
|
||||
driver._send_command = MagicMock(return_value=output)
|
||||
return driver
|
||||
|
||||
|
||||
def test_the_listed_community_is_reported():
|
||||
out = "Index Community-Name Access\n----- -------------- ------\nc0mm read-only x\n"
|
||||
|
||||
config = _driver(out).get_snmp_config()
|
||||
|
||||
assert config == {"running": True, "community": "c0mm", "port": 161, "version": "2c"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"output",
|
||||
[
|
||||
"Index Community-Name Access\n----- -------------- ------\n",
|
||||
"Index Community-Name Access\n",
|
||||
"something the parser does not know\n",
|
||||
],
|
||||
)
|
||||
def test_without_a_listed_community_none_is_invented(output):
|
||||
config = _driver(output).get_snmp_config()
|
||||
|
||||
assert config is not None
|
||||
assert config["community"] != "public"
|
||||
assert config == {"running": False, "community": "", "port": 161, "version": "2c"}
|
||||
Reference in new issue
Block a user