コード例 #1
0
 def test_get_ssh_options_private_key_flag_not_added_when_ssh_private_file_string_empty(
         self):
     test_host_vars = {'ansible_ssh_private_key_file': ''}
     test_ssh_connection_command = SSHConnectionCommand(
         'test_hostname', test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     self.assertNotIn('-i', result_ssh_options)
コード例 #2
0
 def test_get_ssh_options_port_flag_with_ansible_cfg_remote_port_is_used(
         self):
     test_host_vars = {'remote_port': '2222'}
     test_ssh_connection_command = SSHConnectionCommand(
         'test_hostname', test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     self.assertIn('-p 2222', result_ssh_options)
コード例 #3
0
 def test_get_ssh_options_private_key_flag_added_when_ssh_private_file_string_not_empty(
         self):
     test_host_vars = {'ansible_ssh_private_key_file': 'test/file.pem'}
     test_ssh_connection_command = SSHConnectionCommand(test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     expected_private_key_option = '-i test/file.pem'
     self.assertIn(expected_private_key_option, result_ssh_options)
コード例 #4
0
 def test_get_ssh_options_private_key_flag_added_with_ansible_cfg_private_key_option(
         self):
     test_host_vars = {'private_key_file': 'test/file.pem'}
     test_ssh_connection_command = SSHConnectionCommand(
         'test_hostname', test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     expected_private_key_option = '-i test/file.pem'
     self.assertIn(expected_private_key_option, result_ssh_options)
コード例 #5
0
 def test_get_ssh_options_option_for_no_host_key_checking_when_it_is_selected(
         self):
     test_host_vars = {'ansible_host_key_checking': False}
     test_ssh_connection_command = SSHConnectionCommand(test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     self.assertIn(
         '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no',
         result_ssh_options)
コード例 #6
0
 def test_get_ssh_options_no_options_for_no_host_key_checking_when_it_is_not_selected(
         self):
     test_host_vars = {}
     test_ssh_connection_command = SSHConnectionCommand(
         'test_hostname', test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     self.assertNotIn(
         '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no',
         result_ssh_options)
コード例 #7
0
 def test_get_ssh_options_no_port_flag_when_port_variable_is_not_set(self):
     test_host_vars = {}
     test_ssh_connection_command = SSHConnectionCommand(
         'test_hostname', test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     self.assertNotIn('-p 2222', result_ssh_options)
コード例 #8
0
 def test_get_ssh_options_port_flag_when_port_variable_is_not_none(self):
     test_host_vars = {'ansible_port': '2222'}
     test_ssh_connection_command = SSHConnectionCommand(test_host_vars)
     result_ssh_options = test_ssh_connection_command._get_ssh_options()
     self.assertIn('-p 2222', result_ssh_options)