fix: what bandit and the remaining lint rules found
- nosec for SHA512_password in the login payload (B105): it is a flag telling the gateway how Input_Passwd is encoded, not a password; a false positive. - A failed login raises ConnectionException from the underlying error, so the cause stays attached. - tests: pytest.raises instead of try / assert False / except, which python -O would have turned into tests that always pass.
This commit is contained in:
1 parent
f9fc4e3d06
commit
b306b64673
2 files changed
+7
-18
No files matched your search
+4
-16
@@ -146,11 +146,8 @@ class TestZyxelVMGDriver:
|
||||
sess = MagicMock()
|
||||
sess.get.side_effect = requests.ConnectionError("unreachable")
|
||||
mock_session.return_value = sess
|
||||
try:
|
||||
with pytest.raises(ConnectionException):
|
||||
self.driver.open()
|
||||
assert False, "Expected ConnectionException"
|
||||
except ConnectionException:
|
||||
pass
|
||||
|
||||
def test_close(self):
|
||||
self._setup_mocked_http()
|
||||
@@ -298,19 +295,13 @@ class TestZyxelVMGDriver:
|
||||
|
||||
def test_load_replace_candidate_raises(self):
|
||||
self._setup_mocked_http()
|
||||
try:
|
||||
with pytest.raises(NotImplementedError):
|
||||
self.driver.load_replace_candidate()
|
||||
assert False, "Expected NotImplementedError"
|
||||
except NotImplementedError:
|
||||
pass
|
||||
|
||||
def test_load_merge_candidate_raises(self):
|
||||
self._setup_mocked_http()
|
||||
try:
|
||||
with pytest.raises(NotImplementedError):
|
||||
self.driver.load_merge_candidate()
|
||||
assert False, "Expected NotImplementedError"
|
||||
except NotImplementedError:
|
||||
pass
|
||||
|
||||
def test_ping_not_implemented(self):
|
||||
self._setup_mocked_http()
|
||||
@@ -325,11 +316,8 @@ class TestZyxelVMGDriver:
|
||||
from napalm.base.exceptions import ConnectionClosedException
|
||||
|
||||
self.driver._session = None
|
||||
try:
|
||||
with pytest.raises(ConnectionClosedException):
|
||||
self.driver._dal_query("PINGTEST", {})
|
||||
assert False, "Expected ConnectionClosedException"
|
||||
except ConnectionClosedException:
|
||||
pass
|
||||
|
||||
def test_parse_port_forwards_dal(self):
|
||||
self._setup_mocked_http()
|
||||
|
||||
Reference in new issue
Block a user