Exemple #1
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'
Exemple #2
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'
Exemple #3
0
def test_start_maybe_tls_before_connect(mocker):
    mock_config(mocker)
    proxy, client_protocol, server_protocol, mock_make_proxied_connection = mock_protocol_proxy(
        mocker)
    mock_maybe_tls = mocker.patch("pappyproxy.proxy.start_maybe_tls")
    client_protocol.transport.startTLS = mock.MagicMock()
    server_protocol.transport.startTLS = mock.MagicMock()

    client_protocol.transport.startTLS.assert_not_called()
    proxy.connect("fakehost", 1337, False)
    client_protocol.transport.startTLS.assert_not_called()

    proxy.client_connection_made(client_protocol)
    proxy.start_client_maybe_tls("fakehost")
    client_protocol.transport.startTLS.assert_not_called()
    assert len(mock_maybe_tls.mock_calls) == 1

    callargs = mock_maybe_tls.mock_calls[0][2]
    assert callargs['tls_host'] == 'fakehost'
    assert callargs['start_tls_callback'] == proxy.start_server_tls
Exemple #4
0
def test_start_maybe_tls_before_connect(mocker):
    mock_config(mocker)
    proxy, client_protocol, server_protocol, mock_make_proxied_connection = mock_protocol_proxy(mocker)
    mock_maybe_tls = mocker.patch("pappyproxy.proxy.start_maybe_tls")
    client_protocol.transport.startTLS = mock.MagicMock()
    server_protocol.transport.startTLS = mock.MagicMock()


    client_protocol.transport.startTLS.assert_not_called()
    proxy.connect("fakehost", 1337, False)
    client_protocol.transport.startTLS.assert_not_called()

    proxy.client_connection_made(client_protocol)
    proxy.start_client_maybe_tls("fakehost")
    client_protocol.transport.startTLS.assert_not_called()
    assert len(mock_maybe_tls.mock_calls) == 1

    callargs = mock_maybe_tls.mock_calls[0][2]
    assert callargs['tls_host'] == 'fakehost'
    assert callargs['start_tls_callback'] == proxy.start_server_tls
Exemple #5
0
def test_start_tls_after_connect(mocker):
    mock_config(mocker)
    proxy, client_protocol, server_protocol, mock_make_proxied_connection = mock_protocol_proxy(mocker)
    client_protocol.transport.startTLS = mock.MagicMock()
    server_protocol.transport.startTLS = mock.MagicMock()

    server_protocol.transport.startTLS.assert_not_called()
    client_protocol.transport.startTLS.assert_not_called()

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

    server_protocol.transport.startTLS.assert_not_called()
    client_protocol.transport.startTLS.assert_not_called()

    proxy.server_connection_made(server_protocol)
    proxy.start_server_tls()
    assert len(server_protocol.transport.startTLS.mock_calls) == 1

    proxy.client_connection_made(client_protocol)
    proxy.start_client_tls("fakehost")
    assert len(client_protocol.transport.startTLS.mock_calls) == 1
Exemple #6
0
def test_start_tls_after_connect(mocker):
    mock_config(mocker)
    proxy, client_protocol, server_protocol, mock_make_proxied_connection = mock_protocol_proxy(
        mocker)
    client_protocol.transport.startTLS = mock.MagicMock()
    server_protocol.transport.startTLS = mock.MagicMock()

    server_protocol.transport.startTLS.assert_not_called()
    client_protocol.transport.startTLS.assert_not_called()

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

    server_protocol.transport.startTLS.assert_not_called()
    client_protocol.transport.startTLS.assert_not_called()

    proxy.server_connection_made(server_protocol)
    proxy.start_server_tls()
    assert len(server_protocol.transport.startTLS.mock_calls) == 1

    proxy.client_connection_made(client_protocol)
    proxy.start_client_tls("fakehost")
    assert len(client_protocol.transport.startTLS.mock_calls) == 1