def test_bad_password(): try: cache = SSHNoConnectionCache("SSH uncached connections") session = client.NetconfSSHSession("127.0.0.1", password="******", port=nc_server.port, cache=cache) except ssh.AuthenticationException: pass else: logger.error("Unexpected success: %s", str(session)) assert False
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 session.chan.shutdown_write()
def test_multi_open_no_cache(): _test_multi_open(SSHNoConnectionCache())
def test_multi_open_no_cache(): _test_multi_open(SSHNoConnectionCache("SSH uncached connections"))
def test_server_close_no_cache(): _test_server_close(SSHNoConnectionCache())