How to use the moler.cmd.unix.sudo.Sudo function in moler

To help you get started, we’ve selected a few moler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_calling_by_command_object(buffer_connection, command_output_and_expected_result):
    command_output, expected_result = command_output_and_expected_result
    buffer_connection.remote_inject_response([command_output])

    cmd_pwd = Pwd(connection=buffer_connection.moler_connection)
    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, password="pass", cmd_object=cmd_pwd)
    assert "sudo pwd" == cmd_sudo.command_string
    result = cmd_sudo()
    assert result == expected_result
github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_command_not_found(buffer_connection, command_output_command_not_found):
    command_output = command_output_command_not_found
    buffer_connection.remote_inject_response([command_output])
    cmd_pwd = Pwd(connection=buffer_connection.moler_connection)
    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, password="pass", cmd_object=cmd_pwd)
    with pytest.raises(CommandFailure):
        cmd_sudo()
github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_failing_with_embedded_command_fails(buffer_connection, command_output_cp_fails):
    command_output = command_output_cp_fails
    buffer_connection.remote_inject_response([command_output])
    cmd_cp = Cp(connection=buffer_connection.moler_connection, src="src.txt", dst="dst.txt", prompt="ute@debdev:")
    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, password="pass", cmd_object=cmd_cp)
    with pytest.raises(CommandFailure):
        abc = cmd_sudo()
        print("abc '{}'".format(abc))
github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_failing_with_both_parameters(buffer_connection, command_output_cp_fails):
    command_output = command_output_cp_fails
    buffer_connection.remote_inject_response([command_output])
    cmd_cp = Cp(connection=buffer_connection.moler_connection, src="src.txt", dst="dst.txt")
    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, cmd_class_name="moler.cmd.unix.cp.Cp",
                    cmd_object=cmd_cp, password="pass")
    with pytest.raises(CommandFailure):
        cmd_sudo(timeout=0.2)
github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_failing_with_bit_fails(buffer_connection, command_output_cp_bit_fails):
    command_output = command_output_cp_bit_fails
    buffer_connection.remote_inject_response([command_output])
    cmd_cp = Cp(connection=buffer_connection.moler_connection, src="src.txt", dst="dst.txt")
    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, password="pass", cmd_object=cmd_cp)
    with pytest.raises(CommandFailure):
        cmd_sudo()
github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_failing_with_timeout(buffer_connection, command_output_and_expected_result_timeout):
    command_output = command_output_and_expected_result_timeout
    buffer_connection.remote_inject_response([command_output])
    cmd_pwd = Pwd(connection=buffer_connection.moler_connection)
    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, password="pass", cmd_object=cmd_pwd)
    with pytest.raises(CommandTimeout):
        cmd_sudo(timeout=0.1)
github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_calling_by_command_class(buffer_connection, command_output_and_expected_result):
    command_output, expected_result = command_output_and_expected_result
    buffer_connection.remote_inject_response([command_output])

    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, password="pass",
                    cmd_class_name="moler.cmd.unix.pwd.Pwd")
    assert "sudo pwd" == cmd_sudo.command_string
    result = cmd_sudo()
    assert "sudo pwd" == cmd_sudo.command_string
    assert result == expected_result
github nokia / moler / test / cmd / unix / test_cmd_sudo.py View on Github external
def test_sudo_with_parameter_i(buffer_connection):
    command_output = """sudo -i
root@host#"""
    buffer_connection.remote_inject_response([command_output])
    cmd_sudo = Sudo(connection=buffer_connection.moler_connection, password="pass",
                    sudo_params='-i', prompt="moler_bash#", expected_prompt="root@host.*#")
    assert "sudo -i" == cmd_sudo.command_string
    cmd_sudo(timeout=0.1)
github nokia / moler / moler / cmd / unix / sudo.py View on Github external
def _get_wrong_password_regex(self):
        return Sudo._re_sudo_sorry_try_again
github nokia / moler / moler / cmd / unix / sudo.py View on Github external
def _get_password_regex(self):
        return Sudo._re_sudo_password