from __future__ import absolute_import, division, unicode_literals, print_function, nested_scopes import pytest from sshutil.cache import SSHConnectionCache, SSHNoConnectionCache from sshutil.conn import SSHCommandSession proxy = "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null localhost /bin/nc %h %p" def setup_module(module): del module # unused from sshutil.cache import _setup_travis _setup_travis() @pytest.mark.parametrize("cache", [ SSHConnectionCache("SSH Session cache"), SSHNoConnectionCache("SSH Session no cache"), None ]) @pytest.mark.parametrize("proxycmd", [None, proxy]) @pytest.mark.parametrize("debug", [False, True]) def test_command_session(cache, proxycmd, debug): session = SSHCommandSession("localhost", 22, "cat", debug=debug, cache=cache, proxycmd=proxycmd) s = "foobar\n" session.sendall(s) s2 = session.recv(len(s)).decode('utf-8') assert s == s2
def test_multi_open_cache(): _test_multi_open( SSHConnectionCache("test multi open cache", max_channels=50))
def test_server_close_cache(): _test_server_close(SSHConnectionCache("test multi open cache"))
def test_multi_open_cache(): _test_multi_open(SSHConnectionCache("test multi open cache"))
def test_multi_open_cache(): from sshutil.cache import SSHConnectionCache _test_multi_open(SSHConnectionCache("test multi open cache"))