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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mock-ssh-server-0.9.1.tar.gz.
File metadata
- Download URL: mock-ssh-server-0.9.1.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
720f18440dad67b0b4b23fac2a54e3bd020245876836b16a8dfedec6a6ea8598
|
|
| MD5 |
58cd8cc92ee51959462c490e70ea8336
|
|
| BLAKE2b-256 |
ff454b88dab25108c1d061a6fe8e0a0eb4b4c4b925d65b4b6eef55cdf0e249ab
|
File details
Details for the file mock_ssh_server-0.9.1-py3-none-any.whl.
File metadata
- Download URL: mock_ssh_server-0.9.1-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ec42bfb8ba11c9249ce47b80acd01de3e9ee109b7a8d7161a37bd3924806a27
|
|
| MD5 |
6a49d769385469cdac0ce17ec0f2b879
|
|
| BLAKE2b-256 |
258e10b75e759440b221d8fa0f9a39c8d3a73d573e9ca1b7317c573c97d5d34b
|