Open albertinisg opened 8 years ago
A new python library that mocks a ssh server could come in handy: https://github.com/carletes/mock-ssh-server
import os
from pytest import yield_fixture
import mockssh
@yield_fixture()
def server():
users = {
"sample-user": "/path/to/user-private-key,
}
with mockssh.Server(users) as s:
yield s
def test_ssh_session(server):
for uid in server.users:
with server.client(uid) as c:
_, stdout, _ = c.exec_command("ls /")
assert stdout.read()
Actually we are doing requests against Gerrit using sub-processes, forcing the user to add private keys manually in the host.
Using a library like paramiko would allow us to add the key as a parameter for the back-end, and automatize the process.