Beispiel #1
0
def test_ssh_connection_with_key_string(ssh_mock):
    ssh_key = generate_ssh_key()

    ssh_resource = SSHResource(
        remote_host='remote_host',
        remote_port=12345,
        username='******',
        password=None,
        timeout=10,
        key_string=six.ensure_str(ssh_key),
        keepalive_interval=30,
        compress=True,
        no_host_key_check=False,
        allow_host_key_change=False,
        logger=logging.root.getChild('test_resources'),
    )

    with ssh_resource.get_connection():
        ssh_mock.return_value.connect.assert_called_once_with(
            hostname='remote_host',
            username='******',
            key_filename=None,
            pkey=key_from_str(ssh_key),
            timeout=10,
            compress=True,
            port=12345,
            sock=None,
        )
Beispiel #2
0
def test_tunnel_with_string_key(ssh_mock):
    ssh_key = generate_ssh_key()

    ssh_resource = SSHResource(
        remote_host='remote_host',
        remote_port=12345,
        username='******',
        password=None,
        timeout=10,
        key_string=six.ensure_str(ssh_key),
        keepalive_interval=30,
        compress=True,
        no_host_key_check=False,
        allow_host_key_change=False,
        logger=logging.root.getChild('test_resources'),
    )

    with ssh_resource.get_tunnel(1234):
        ssh_mock.assert_called_once_with(
            'remote_host',
            ssh_port=12345,
            ssh_username='******',
            ssh_pkey=key_from_str(ssh_key),
            ssh_proxy=None,
            local_bind_address=('localhost', ),
            remote_bind_address=('localhost', 1234),
            host_pkey_directories=[],
            logger=ssh_resource.log,
        )