Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/niedbalski/ssh-exec-test

Library for testing SSH clients
https://github.com/niedbalski/ssh-exec-test

Last synced: about 1 month ago
JSON representation

Library for testing SSH clients

Awesome Lists containing this project

README

        

### Status
[![Build Status](https://travis-ci.org/niedbalski/ssh-exec-test.svg?branch=master)](https://github.com/niedbalski/ssh-exec-test)

SSH Exec test
=============

This is a library for testing software that makes use of paramiko, fabric
or any other component, that relies on SSH shell_exec method for executing
remote commands.

Usage
======

For more examples, please checkout the tests directory.

```bash
$ pip install ssh-exec-test
```

```python
from ssh_exec_test import (assert_ssh_exec, input)

with assert_ssh_exec(rules=[
input("sudo ls -lhR", output="foobar"),
input("sudo ls -lhRT", output="foobar1"),
]) as server:

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("127.0.0.1", 2022, "ubuntu", "ubuntu")
stdin, stdout, _ = ssh.exec_command("sudo ls -lhR")
ssh.close()

assert stdout.read() == "foobar"
```