aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_flow.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-03-04 13:08:43 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-03-04 13:08:43 +1300
commit96471fde1d8e860264d2b774775ca2a999d63eb8 (patch)
treea3fce40e71cc041d31a33fbd2c739a51a04fe719 /test/test_flow.py
parent2e492b8e94362dbd9380d1d3eb38b5abaa8f137d (diff)
downloadmitmproxy-96471fde1d8e860264d2b774775ca2a999d63eb8.tar.gz
mitmproxy-96471fde1d8e860264d2b774775ca2a999d63eb8.tar.bz2
mitmproxy-96471fde1d8e860264d2b774775ca2a999d63eb8.zip
Basic client playback state structure.
Diffstat (limited to 'test/test_flow.py')
-rw-r--r--test/test_flow.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index 10b445db..f9fb58e8 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -33,10 +33,32 @@ class uStickyCookieState(libpry.AutoTree):
assert "cookie" in f.request.headers
+class uClientPlaybackState(libpry.AutoTree):
+ def test_tick(self):
+ first = utils.tflow()
+ c = flow.ClientPlaybackState(
+ [first, utils.tflow()]
+ )
+ s = flow.State()
+ fm = flow.FlowMaster(None, s)
+ assert not s.flow_map
+ assert c.count() == 2
+ c.tick(fm, testing=True)
+ assert s.flow_map
+ assert c.count() == 1
+
+ c.tick(fm, testing=True)
+ assert c.count() == 1
+
+ c.clear(first)
+ c.tick(fm, testing=True)
+ assert c.count() == 0
+
+
class uServerPlaybackState(libpry.AutoTree):
def test_hash(self):
- s = flow.ServerPlaybackState(None)
+ s = flow.ServerPlaybackState(None, [])
r = utils.tflow()
r2 = utils.tflow()
@@ -48,7 +70,7 @@ class uServerPlaybackState(libpry.AutoTree):
assert s._hash(r) != s._hash(r2)
def test_headers(self):
- s = flow.ServerPlaybackState(["foo"])
+ s = flow.ServerPlaybackState(["foo"], [])
r = utils.tflow_full()
r.request.headers["foo"] = ["bar"]
r2 = utils.tflow_full()
@@ -63,14 +85,13 @@ class uServerPlaybackState(libpry.AutoTree):
assert s._hash(r) == s._hash(r2)
def test_load(self):
- s = flow.ServerPlaybackState(None)
r = utils.tflow_full()
r.request.headers["key"] = ["one"]
r2 = utils.tflow_full()
r2.request.headers["key"] = ["two"]
- s.load([r, r2])
+ s = flow.ServerPlaybackState(None, [r, r2])
assert s.count() == 2
assert len(s.fmap.keys()) == 1
@@ -398,6 +419,7 @@ class uFlowMaster(libpry.AutoTree):
tests = [
uStickyCookieState(),
uServerPlaybackState(),
+ uClientPlaybackState(),
uFlow(),
uState(),
uSerialize(),