Beispiel #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"
Beispiel #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"
Beispiel #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
Beispiel #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
Beispiel #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'
Beispiel #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'