Skip to main content

Mock SSH server for testing purposes

Project description

mock-ssh-server packs a Python context manager that implements an SSH server for testing purposes. It is built on top of paramiko, so it does not need OpenSSH binaries to be installed.

Sample usage

As a py.test fixture:

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

def test_sftp_session(server):
    for uid in server.users:
        target_dir = tempfile.mkdtemp()
        target_fname = os.path.join(target_dir, "foo")
        assert not os.access(target_fname, os.F_OK)

        with server.client(uid) as c:
            sftp = c.open_sftp()
            sftp.put(__file__, target_fname, confirm=True)
            assert os.access(target_fname, os.F_OK)
https://travis-ci.org/carletes/mock-ssh-server.svg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mock-ssh-server-0.6.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

mock_ssh_server-0.6.0-py2-none-any.whl (12.5 kB view details)

Uploaded Python 2

File details

Details for the file mock-ssh-server-0.6.0.tar.gz.

File metadata

  • Download URL: mock-ssh-server-0.6.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.10

File hashes

Hashes for mock-ssh-server-0.6.0.tar.gz
Algorithm Hash digest
SHA256 c5c15a72d3184c801c416966c345a6afeb800011c7b07df3c824ea5a1d436dd2
MD5 856aa9fc6f1ef59dbf124f3e12db5f02
BLAKE2b-256 2a1bb8a6f205f6b17f6c772ec9034906051ef37def080e940bd94013e2cce41d

See more details on using hashes here.

File details

Details for the file mock_ssh_server-0.6.0-py2-none-any.whl.

File metadata

  • Download URL: mock_ssh_server-0.6.0-py2-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.10

File hashes

Hashes for mock_ssh_server-0.6.0-py2-none-any.whl
Algorithm Hash digest
SHA256 39f20b337b43c6e6ac6e38d64c3bb2b94bce57dc68ed9f8392147649a07563f7
MD5 213be4eeb593faaf94476499b6ca6e37
BLAKE2b-256 91db6d814a256b43f5a939fe9ded1eee6b9a01bc6450286d7df396e2f65b17e9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page