aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_flow.py
diff options
context:
space:
mode:
authorMarcelo Glezer <mg@tekii.com.ar>2014-12-11 14:54:14 -0300
committerMarcelo Glezer <mg@tekii.com.ar>2014-12-11 14:54:14 -0300
commit4952643a0d76eb1e9bd51cbbe95c565ae48b97a2 (patch)
treef43fc647bdfabb522bdef32e21ea4a36404cc311 /test/test_flow.py
parent83b1d4e0e0490e5be05943da459c925a3ee3ff14 (diff)
parentffb95a1db742d71d7671f9e9c6db552774bb0ead (diff)
downloadmitmproxy-4952643a0d76eb1e9bd51cbbe95c565ae48b97a2.tar.gz
mitmproxy-4952643a0d76eb1e9bd51cbbe95c565ae48b97a2.tar.bz2
mitmproxy-4952643a0d76eb1e9bd51cbbe95c565ae48b97a2.zip
Merge remote-tracking branch 'base/master'
Diffstat (limited to 'test/test_flow.py')
-rw-r--r--test/test_flow.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index b74119dd..22abb4d4 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -5,8 +5,10 @@ import mock
from libmproxy import filt, protocol, controller, utils, tnetstring, flow
from libmproxy.protocol.primitives import Error, Flow
from libmproxy.protocol.http import decoded, CONTENT_MISSING
-from libmproxy.proxy.connection import ClientConnection, ServerConnection
-from netlib import tcp
+from libmproxy.proxy.config import HostMatcher
+from libmproxy.proxy import ProxyConfig
+from libmproxy.proxy.server import DummyServer
+from libmproxy.proxy.connection import ClientConnection
import tutils
@@ -84,19 +86,20 @@ class TestClientPlaybackState:
fm = flow.FlowMaster(None, s)
fm.start_client_playback([first, tutils.tflow()], True)
c = fm.client_playback
+ c.testing = True
assert not c.done()
assert not s.flow_count()
assert c.count() == 2
- c.tick(fm, testing=True)
+ c.tick(fm)
assert s.flow_count()
assert c.count() == 1
- c.tick(fm, testing=True)
+ c.tick(fm)
assert c.count() == 1
c.clear(c.current)
- c.tick(fm, testing=True)
+ c.tick(fm)
assert c.count() == 0
c.clear(c.current)
assert c.done()
@@ -531,6 +534,14 @@ class TestSerialize:
fm.load_flows(r)
assert len(s._flow_list) == 6
+ def test_load_flows_reverse(self):
+ r = self._treader()
+ s = flow.State()
+ conf = ProxyConfig(mode="reverse", upstream_server=[True,True,"use-this-domain",80])
+ fm = flow.FlowMaster(DummyServer(conf), s)
+ fm.load_flows(r)
+ assert s._flow_list[0].request.host == "use-this-domain"
+
def test_filter(self):
sio = StringIO()
fl = filt.parse("~c 200")
@@ -584,11 +595,11 @@ class TestFlowMaster:
def test_getset_ignore(self):
p = mock.Mock()
- p.config.ignore = []
+ p.config.check_ignore = HostMatcher()
fm = flow.FlowMaster(p, flow.State())
- assert not fm.get_ignore()
- fm.set_ignore(["^apple\.com:", ":443$"])
- assert fm.get_ignore()
+ assert not fm.get_ignore_filter()
+ fm.set_ignore_filter(["^apple\.com:", ":443$"])
+ assert fm.get_ignore_filter()
def test_replay(self):
s = flow.State()
@@ -600,6 +611,9 @@ class TestFlowMaster:
f.intercepting = True
assert "intercepting" in fm.replay_request(f)
+ f.live = True
+ assert "live" in fm.replay_request(f)
+
def test_script_reqerr(self):
s = flow.State()
fm = flow.FlowMaster(None, s)
@@ -679,9 +693,11 @@ class TestFlowMaster:
f = tutils.tflow(resp=True)
pb = [tutils.tflow(resp=True), f]
- fm = flow.FlowMaster(None, s)
+
+ fm = flow.FlowMaster(DummyServer(ProxyConfig()), s)
assert not fm.start_server_playback(pb, False, [], False, False, None, False)
assert not fm.start_client_playback(pb, False)
+ fm.client_playback.testing = True
q = Queue.Queue()
assert not fm.state.flow_count()