mock-ssh-server icon indicating copy to clipboard operation
mock-ssh-server copied to clipboard

Adds password support

Open ut-adamc opened this issue 2 years ago • 5 comments

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.

ut-adamc avatar Aug 26 '22 21:08 ut-adamc

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.

Spitfire1900 avatar Jun 04 '23 03:06 Spitfire1900

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())

b3n4kh avatar Apr 10 '24 12:04 b3n4kh

@ut-adamc , I don't see any stand-out issues with the implementation. Can you please update README.rst to include a password example?

Spitfire1900 avatar Jun 19 '24 15:06 Spitfire1900