Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gerrit] Use native ssh python library #59

Open
albertinisg opened this issue Sep 14, 2016 · 1 comment
Open

[gerrit] Use native ssh python library #59

albertinisg opened this issue Sep 14, 2016 · 1 comment

Comments

@albertinisg
Copy link
Contributor

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.

@sduenas sduenas added the gerrit label Sep 14, 2016
valeriocos pushed a commit to valeriocos/perceval that referenced this issue Dec 6, 2017
@valeriocos
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants