Exemplo n.º 1
0
def test_simple(mocker):
    mock_config(mocker)
    proxy, _, _, _ = mock_protocol_proxy(mocker)
    proxy.send_client_data("foobar")
    assert proxy.client_buffer == "foobar"
    proxy.send_server_data("barfoo")
    assert proxy.server_buffer == "barfoo"
Exemplo n.º 2
0
def test_simple(mocker):
    mock_config(mocker)
    proxy, _, _, _ = mock_protocol_proxy(mocker)
    proxy.send_client_data("foobar")
    assert proxy.client_buffer == "foobar"
    proxy.send_server_data("barfoo")
    assert proxy.server_buffer == "barfoo"
Exemplo n.º 3
0
def test_connect(mocker):
    mock_config(mocker)
    proxy, _, _, mock_make_proxied_connection = mock_protocol_proxy(mocker)
    proxy.send_client_data("foobar")
    proxy.send_server_data("barfoo")
    proxy.connect("fakehost", 1337, False)
    assert len(mock_make_proxied_connection.mock_calls) == 1
    callargs = mock_make_proxied_connection.mock_calls[0][1]
    assert callargs[1] == "fakehost"
    assert callargs[2] == 1337
    assert callargs[3] == False
Exemplo n.º 4
0
def test_connect(mocker):
    mock_config(mocker)
    proxy, _, _, mock_make_proxied_connection = mock_protocol_proxy(mocker)
    proxy.send_client_data("foobar")
    proxy.send_server_data("barfoo")
    proxy.connect("fakehost", 1337, False)
    assert len(mock_make_proxied_connection.mock_calls) == 1
    callargs = mock_make_proxied_connection.mock_calls[0][1]
    assert callargs[1] == "fakehost"
    assert callargs[2] == 1337
    assert callargs[3] == False
Exemplo n.º 5
0
def test_send_after_connect(mocker):
    mock_config(mocker)
    proxy, client_protocol, server_protocol, mock_make_proxied_connection = mock_protocol_proxy(mocker)

    proxy.connect("fakehost", 1337, False)

    proxy.client_connection_made(client_protocol)
    proxy.send_client_data("foobar")
    assert client_protocol.transport.pop_value() == 'foobar'

    proxy.server_connection_made(server_protocol)
    proxy.send_server_data("barfoo")
    assert server_protocol.transport.pop_value() == 'barfoo'
Exemplo n.º 6
0
def test_send_after_connect(mocker):
    mock_config(mocker)
    proxy, client_protocol, server_protocol, mock_make_proxied_connection = mock_protocol_proxy(
        mocker)

    proxy.connect("fakehost", 1337, False)

    proxy.client_connection_made(client_protocol)
    proxy.send_client_data("foobar")
    assert client_protocol.transport.pop_value() == 'foobar'

    proxy.server_connection_made(server_protocol)
    proxy.send_server_data("barfoo")
    assert server_protocol.transport.pop_value() == 'barfoo'