Mock SSH server for testing purposes
Project description
mock-ssh-server is a 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 from mockssh import Server @yield_fixture(scope="function") def server(): users = { "sample-user": "/path/to/user-private-key, } with 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.1.0.tar.gz
(9.4 kB
view details)
File details
Details for the file mock-ssh-server-0.1.0.tar.gz
.
File metadata
- Download URL: mock-ssh-server-0.1.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0414ce59751a8c54aa5139966675455af524f4c3dc3c3202a73fc991710126d4 |
|
MD5 | 5e2e1de58d19a9ef86c3fb1062b2e6c2 |
|
BLAKE2b-256 | f8bc6c8389d8c3e27e8b8bf3768554eba1563be5618ba7e23b90be36d1acf23c |