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)
Project details
Release history Release notifications | RSS feed
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.9.1.tar.gz
(12.8 kB
view hashes)
Built Distribution
Close
Hashes for mock_ssh_server-0.9.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ec42bfb8ba11c9249ce47b80acd01de3e9ee109b7a8d7161a37bd3924806a27 |
|
MD5 | 6a49d769385469cdac0ce17ec0f2b879 |
|
BLAKE2b-256 | 258e10b75e759440b221d8fa0f9a39c8d3a73d573e9ca1b7317c573c97d5d34b |