def test_connect_with_bastion(self): hosts = ['localhost', '127.0.0.1'] client = ParallelSSHClient(hosts=hosts, user='******', pkey_file='~/.ssh/id_rsa', bastion_host='testing_bastion_host', connect=False) client.connect() for host in hosts: hostname, _ = client._get_host_port_info(host) self.assertEqual(client._hosts_client[hostname].bastion_host, 'testing_bastion_host')
def test_connect_with_bastion(self): hosts = ["localhost", "127.0.0.1"] client = ParallelSSHClient( hosts=hosts, user="******", pkey_file="~/.ssh/id_rsa", bastion_host="testing_bastion_host", connect=False, ) client.connect() for host in hosts: hostname, _ = client._get_host_port_info(host) self.assertEqual(client._hosts_client[hostname].bastion_host, "testing_bastion_host")
def test_connect_with_password(self): hosts = ['localhost', '127.0.0.1'] client = ParallelSSHClient(hosts=hosts, user='******', password='******', connect=False) client.connect() expected_conn = { 'allow_agent': False, 'look_for_keys': False, 'password': '******', 'username': '******', 'timeout': 60, 'port': 22 } for host in hosts: expected_conn['hostname'] = host client._hosts_client[host].client.connect.assert_called_once_with(**expected_conn)
def test_connect_with_password(self): hosts = ["localhost", "127.0.0.1"] client = ParallelSSHClient(hosts=hosts, user="******", password="******", connect=False) client.connect() expected_conn = { "allow_agent": False, "look_for_keys": False, "password": "******", "username": "******", "timeout": 60, "port": 22, } for host in hosts: expected_conn["hostname"] = host client._hosts_client[host].client.connect.assert_called_once_with( **expected_conn)
def test_connect_with_key(self): hosts = ['localhost', '127.0.0.1', 'st2build001'] client = ParallelSSHClient(hosts=hosts, user='******', pkey_file='~/.ssh/id_rsa', connect=False) client.connect() expected_conn = { 'allow_agent': False, 'look_for_keys': False, 'key_filename': '~/.ssh/id_rsa', 'username': '******', 'timeout': 60, 'port': 22 } for host in hosts: hostname, port = client._get_host_port_info(host) expected_conn['hostname'] = hostname expected_conn['port'] = port client._hosts_client[hostname].client.connect.assert_called_once_with(**expected_conn)
def test_connect_with_key(self): hosts = ["localhost", "127.0.0.1", "st2build001"] client = ParallelSSHClient(hosts=hosts, user="******", pkey_file="~/.ssh/id_rsa", connect=False) client.connect() expected_conn = { "allow_agent": False, "look_for_keys": False, "key_filename": "~/.ssh/id_rsa", "username": "******", "timeout": 60, "port": 22, } for host in hosts: hostname, port = client._get_host_port_info(host) expected_conn["hostname"] = hostname expected_conn["port"] = port client._hosts_client[ hostname].client.connect.assert_called_once_with( **expected_conn)