Пример #1
0
def test_run_cmd(protocol_fake):
    # TODO this test should cover __init__ method
    s = Session('windows-host', auth=('john.smith', 'secret'))
    s.protocol = protocol_fake

    r = s.run_cmd('ipconfig', ['/all'])

    assert r.status_code == 0
    assert b'Windows IP Configuration' in r.std_out
    assert len(r.std_err) == 0
Пример #2
0
def test_run_cmd(protocol_fake):
    # TODO this test should cover __init__ method
    s = Session('windows-host', auth=('john.smith', 'secret'))
    s.protocol = protocol_fake

    r = s.run_cmd('ipconfig', ['/all'])

    assert r.status_code == 0
    assert 'Windows IP Configuration' in r.std_out
    assert len(r.std_err) == 0
Пример #3
0
def test_run_ps_with_error(protocol_fake):
    # TODO this test should cover __init__ method
    s = Session('windows-host', auth=('john.smith', 'secret'))
    s.protocol = protocol_fake

    r = s.run_ps('Write-Error "Error"')

    assert r.status_code == 1
    assert b'Write-Error "Error"' in r.std_err
    assert len(r.std_out) == 0
Пример #4
0
def test_run_ps(protocol_fake):
    s = Session('windows-host', auth=('john.smith', 'secret'))
    s.protocol = protocol_fake

    script = """
        $strComputer = $Host
        Clear
        $RAM = WmiObject Win32_ComputerSystem
        $MB = 1048576

        "Installed Memory: " + [int]($RAM.TotalPhysicalMemory /$MB) + " MB"
    """
    r = s.run_ps(script)

    assert r.status_code == 0
    assert b'Installed Memory: 2044 MB' in r.std_out
    assert len(r.std_err) == 0