From afbcd96fcca5aa4ccb72421d9660874586cbef4f Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Thu, 1 Jun 2017 12:42:35 -0700 Subject: Remove unused value from demo/test. Honestly not sure WTF --- tests/test_ssh_gss.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_ssh_gss.py b/tests/test_ssh_gss.py index e20d348f..967b3b81 100644 --- a/tests/test_ssh_gss.py +++ b/tests/test_ssh_gss.py @@ -43,9 +43,7 @@ class NullServer (paramiko.ServerInterface): return paramiko.AUTH_FAILED def enable_auth_gssapi(self): - UseGSSAPI = True - GSSAPICleanupCredentials = True - return UseGSSAPI + return True def check_channel_request(self, kind, chanid): return paramiko.OPEN_SUCCEEDED -- cgit v1.2.3 From 4d15d0e824d199b60f96b7ee5584d4cb5b23fc1a Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Thu, 1 Jun 2017 13:08:10 -0700 Subject: Test & impl for truly functional HostKeys.__delitem__ --- paramiko/hostkeys.py | 9 ++++++++- tests/test_hostkeys.py | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/paramiko/hostkeys.py b/paramiko/hostkeys.py index 4be3fd42..b72abe40 100644 --- a/paramiko/hostkeys.py +++ b/paramiko/hostkeys.py @@ -246,7 +246,14 @@ class HostKeys (MutableMapping): return ret def __delitem__(self, key): - pass # Needed for instantiating HostKeys. + index = None + for i, entry in enumerate(self._entries): + if self._hostname_matches(key, entry): + index = i + break + if i is None: + raise KeyError(key) + self._entries.pop(i) def __setitem__(self, hostname, entry): # don't use this please. diff --git a/tests/test_hostkeys.py b/tests/test_hostkeys.py index 2bdcad9c..2c7ceeb9 100644 --- a/tests/test_hostkeys.py +++ b/tests/test_hostkeys.py @@ -115,3 +115,15 @@ class HostKeysTest (unittest.TestCase): self.assertEqual(b'7EC91BB336CB6D810B124B1353C32396', fp) fp = hexlify(hostdict['secure.example.com']['ssh-dss'].get_fingerprint()).upper() self.assertEqual(b'4478F0B9A23CC5182009FF755BC1D26C', fp) + + def test_delitem(self): + hostdict = paramiko.HostKeys('hostfile.temp') + target = 'happy.example.com' + entry = hostdict[target] # will KeyError if not present + del hostdict[target] + try: + entry = hostdict[target] + except KeyError: + pass # Good + else: + assert False, "Entry was not deleted from HostKeys on delitem!" -- cgit v1.2.3