Exemplo n.º 1
0
def ua():
    return agent.Scenario([agent.ua()]).prepare()[0]
Exemplo n.º 2
0
def ua():
    return agent.Scenario([agent.ua()]).prepare()[0]
Exemplo n.º 3
0
    uac2 = agent.client(destaddr=remote_sock, scen_file=script)
    cmdstr = uac2.render()
    assert "-sn 'uac'" not in cmdstr
    assert "-sf '{}'".format(script) in cmdstr


def test_server():
    ua = agent.server()
    cmdstr = ua.render()
    assert "-sn 'uas'" in cmdstr
    assert not (ua.remote_host and ua.remote_port)


@pytest.mark.parametrize('ua, retcode, kwargs, exc', [
    # test unspecialized ua failure
    (agent.ua(), 255, {}, RuntimeError),

    # test client failure on bad remote destination
    (agent.client(destaddr=('99.99.99.99', 5060)), 1, {}, RuntimeError),

    # test if server times out it is signalled
    (agent.server(), 0, {'timeout': 1}, launch.TimeoutError)],
    ids=['ua', 'uac', 'uas'],
)
def test_failures(ua, retcode, kwargs, exc):
    """Test failure cases for all types of agents
    """
    # run it without raising
    runner = ua(raise_exc=False, **kwargs)
    cmds2procs = runner.get(timeout=0)
    assert not runner.is_alive()
Exemplo n.º 4
0
    assert "-sn 'uac'" not in cmdstr
    assert "-sf '{}'".format(script) in cmdstr


def test_server():
    ua = agent.server()
    cmdstr = ua.render()
    assert "-sn 'uas'" in cmdstr
    assert not (ua.remote_host and ua.remote_port)


@pytest.mark.parametrize(
    "ua, retcode, kwargs, exc",
    [
        # test unspecialized ua failure
        (agent.ua(), 255, {}, RuntimeError),
        # test client failure on bad remote destination
        (agent.client(destaddr=("99.99.99.99", 5060)), 1, {}, RuntimeError),
        # test if server times out it is signalled
        (agent.server(), 0, {
            "timeout": 1
        }, launch.TimeoutError),
    ],
    ids=["ua", "uac", "uas"],
)
def test_failures(ua, retcode, kwargs, exc):
    """Test failure cases for all types of agents"""
    # run it without raising
    runner = ua(raise_exc=False, **kwargs)
    cmds2procs = runner.get(timeout=0)
    assert not runner.is_alive()