diff options
-rw-r--r-- | paramiko/agent.py | 3 | ||||
-rw-r--r-- | sites/www/changelog.rst | 2 | ||||
-rw-r--r-- | tests/agent.py | 24 |
3 files changed, 28 insertions, 1 deletions
diff --git a/paramiko/agent.py b/paramiko/agent.py index 2171ff71..8486d6ca 100644 --- a/paramiko/agent.py +++ b/paramiko/agent.py @@ -475,7 +475,8 @@ class AgentKey(PKey): @property def _fields(self): - raise NotImplementedError + fallback = [self.get_name(), self.blob] + return self.inner_key._fields if self.inner_key else fallback def sign_ssh_data(self, data, algorithm=None): msg = Message() diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index 43f81115..5f085131 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,8 @@ Changelog ========= +- :feature:`-` Implement ``_fields()`` on `~paramiko.agent.AgentKey` so that it + may be compared (via ``==``) with other `~paramiko.pkey.PKey` instances. - :bug:`23 major` Since its inception, Paramiko has (for reasons lost to time) implemented authentication as a side effect of handling affirmative replies to ``MSG_SERVICE_REQUEST`` protocol messages. What this means is Paramiko diff --git a/tests/agent.py b/tests/agent.py new file mode 100644 index 00000000..18ece7a9 --- /dev/null +++ b/tests/agent.py @@ -0,0 +1,24 @@ +from paramiko import AgentKey + + +class AgentKey_: + class fields: + """ + _fields + """ + + def defaults_to_get_name_and_blob(self): + # Manually construct a 'failed to get inner_key' obj + class FallbackAgentKey(AgentKey): + def __init__(self, name, blob): + self.name = name + self.blob = blob + self.inner_key = None + + key = FallbackAgentKey(name="lol", blob=b"lmao") + assert key._fields == ["lol", b"lmao"] + + def defers_to_inner_key_when_present(self, keys): + key = AgentKey(agent=None, blob=keys.pkey.asbytes()) + assert key._fields == keys.pkey._fields + assert key == keys.pkey |