mock-ssh-server
mock-ssh-server copied to clipboard
Adds password support
Useful for those of us who sometimes have password credentials.
I don't know how close this would be to a viable solution, but I wanted to run it by you and get feedback. It works in local testing. It relies on changing the data structure for users to accommodate having more than one kind of credential. See the doc string for UserData in mockssh.server.
For the purposes of using this with a mock server password credentials seems irrelevant; instead create a set of credentials just for running the tests against, through either or fixture or as a command you invoke via tox prior to running pytest.
Is there a reason as not to merge this? I would be really interested in this feature as well!
I just checked and saw the tests failing right now but the fix for them to pass again is very straight forward:
diff --git a/mockssh/test_server.py b/mockssh/test_server.py
index 15108b7..1740f53 100644
--- a/mockssh/test_server.py
+++ b/mockssh/test_server.py
@@ -104,6 +104,8 @@ def test_overwrite_handler(server: Server, monkeypatch: MonkeyPatch):
if username == "foo" and password == "bar":
return paramiko.AUTH_SUCCESSFUL
return paramiko.AUTH_FAILED
+ def get_allowed_auths(self, username):
+ return "password"
monkeypatch.setattr(server, 'handler_cls', MyHandler)
with paramiko.SSHClient() as client:
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@ut-adamc , I don't see any stand-out issues with the implementation. Can you please update README.rst to include a password example?