def test_parse_inventory(workspace_manager_fixture, test_workspace, mocker): mock_os = mocker.patch.object(issh, "os") ssh_cmd_str = " ".join([ "ssh -i /some_key_path", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /some_another_key_path ttest@tthost\"", " -p 33 -t [email protected]" ]) issh.ssh_to_host("test_host") mock_os.system.assert_called_with(ssh_cmd_str) ssh_cmd_str = " ".join([ "ssh -i /some_key_path", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /some_another_key_path ttest@tthost\"", " -p 33 -t [email protected] \"some cmd line\"" ]) issh.ssh_to_host("test_host", "some cmd line") mock_os.system.assert_called_with(ssh_cmd_str)
def test_parse_inventory(workspace_manager_fixture, test_workspace, mocker): import os mocker.patch("os.system") ssh_cmd_str = " ".join([ "ssh -i /dev/null", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /dev/null ttest@tthost\"", " -p 33 -t [email protected]" ]) issh.ssh_to_host("test_host") # make sure we aren't calling ssh more than once os.system.assert_called_once_with(ssh_cmd_str) ssh_cmd_str = " ".join([ "ssh -i /dev/null", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /dev/null ttest@tthost\"", " -p 33 -t [email protected] \"some cmd line\"" ]) issh.ssh_to_host("test_host", "some cmd line") os.system.assert_called_with(ssh_cmd_str)
def spec_handler(self, parser, args): """Handles the ssh command :param parser: the infrared parser object. :param args: the list of arguments received from cli. """ pargs = parser.parse_args(args) interactive_ssh.ssh_to_host(pargs.node_name, remote_command=pargs.remote_command)
def spec_handler(self, parser, args): """Handles the ssh command :param parser: the infrared parser object. :param args: the list of arguments received from cli. """ pargs = parser.parse_args(args) interactive_ssh.ssh_to_host(pargs.node_name, remote_command=pargs.remote_command)
def test_parse_inventory(workspace_manager_fixture, test_workspace, mocker): import os mocker.patch("os.system") ssh_cmd_str = " ".join([ "ssh -i /dev/null", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /dev/null ttest@tthost\"", " -p 33 -t [email protected]" ]) issh.ssh_to_host("test_host") # make sure we aren't calling ssh more than once os.system.assert_called_once_with(ssh_cmd_str) ssh_cmd_str = " ".join([ "ssh -i /dev/null", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /dev/null ttest@tthost\"", " -p 33 -t [email protected] \"some cmd line\"" ]) issh.ssh_to_host("test_host", "some cmd line") os.system.assert_called_with(ssh_cmd_str)
def test_parse_inventory(workspace_manager_fixture, test_workspace, mocker): mock_os = mocker.patch.object(issh, "os") ssh_cmd_str = " ".join([ "ssh -i /some_key_path", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /some_another_key_path ttest@tthost\"", " -p 33 -t [email protected]" ]) issh.ssh_to_host("test_host") mock_os.system.assert_called_with(ssh_cmd_str) ssh_cmd_str = " ".join([ "ssh -i /some_key_path", " -o ForwardAgent=yes", "-o ServerAliveInterval=30", "-o ControlMaster=auto", "-o ControlPersist=30m", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-o ProxyCommand=\"ssh", "-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null", "-W %h:%p -i /some_another_key_path ttest@tthost\"", " -p 33 -t [email protected] \"some cmd line\"" ]) issh.ssh_to_host("test_host", "some cmd line") mock_os.system.assert_called_with(ssh_cmd_str)
def test_wrong_connection_type_exception(workspace_manager_fixture, test_workspace): with pytest.raises(exceptions.IRSshException): issh.ssh_to_host("localhost")
def test_wrong_host_exception(workspace_manager_fixture, test_workspace): with pytest.raises(exceptions.IRSshException): issh.ssh_to_host("wrong_host")
def test_wrong_connection_type_exception(workspace_manager_fixture, test_workspace): with pytest.raises(exceptions.IRSshException): issh.ssh_to_host("localhost")
def test_wrong_host_exception(workspace_manager_fixture, test_workspace): with pytest.raises(exceptions.IRSshException): issh.ssh_to_host("wrong_host")