aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_flow.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_flow.py')
-rw-r--r--test/test_flow.py64
1 files changed, 49 insertions, 15 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index 0c713c03..4ad692bc 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -223,16 +223,16 @@ class TestFlow:
f = tutils.tflow()
f.request = tutils.treq()
f.intercept()
- assert not f.request.acked
+ assert not f.request.reply.acked
f.kill(fm)
- assert f.request.acked
+ assert f.request.reply.acked
f.intercept()
f.response = tutils.tresp()
f.request = f.response.request
- f.request._ack()
- assert not f.response.acked
+ f.request.reply()
+ assert not f.response.reply.acked
f.kill(fm)
- assert f.response.acked
+ assert f.response.reply.acked
def test_killall(self):
s = flow.State()
@@ -245,25 +245,25 @@ class TestFlow:
fm.handle_request(r)
for i in s.view:
- assert not i.request.acked
+ assert not i.request.reply.acked
s.killall(fm)
for i in s.view:
- assert i.request.acked
+ assert i.request.reply.acked
def test_accept_intercept(self):
f = tutils.tflow()
f.request = tutils.treq()
f.intercept()
- assert not f.request.acked
+ assert not f.request.reply.acked
f.accept_intercept()
- assert f.request.acked
+ assert f.request.reply.acked
f.response = tutils.tresp()
f.request = f.response.request
f.intercept()
- f.request._ack()
- assert not f.response.acked
+ f.request.reply()
+ assert not f.response.reply.acked
f.accept_intercept()
- assert f.response.acked
+ assert f.response.reply.acked
def test_serialization(self):
f = flow.Flow(None)
@@ -498,6 +498,23 @@ class TestSerialize:
fm.load_flows(r)
assert len(s._flow_list) == 6
+ def test_filter(self):
+ sio = StringIO()
+ fl = filt.parse("~c 200")
+ w = flow.FilteredFlowWriter(sio, fl)
+
+ f = tutils.tflow_full()
+ f.response.code = 200
+ w.add(f)
+
+ f = tutils.tflow_full()
+ f.response.code = 201
+ w.add(f)
+
+ sio.seek(0)
+ r = flow.FlowReader(sio)
+ assert len(list(r.stream()))
+
def test_error(self):
sio = StringIO()
@@ -562,9 +579,11 @@ class TestFlowMaster:
fm.handle_response(resp)
assert fm.script.ns["log"][-1] == "response"
dc = flow.ClientDisconnect(req.client_conn)
+ dc.reply = controller.DummyReply()
fm.handle_clientdisconnect(dc)
assert fm.script.ns["log"][-1] == "clientdisconnect"
err = flow.Error(f.request, "msg")
+ err.reply = controller.DummyReply()
fm.handle_error(err)
assert fm.script.ns["log"][-1] == "error"
@@ -598,10 +617,12 @@ class TestFlowMaster:
assert not fm.handle_response(rx)
dc = flow.ClientDisconnect(req.client_conn)
+ dc.reply = controller.DummyReply()
req.client_conn.requestcount = 1
fm.handle_clientdisconnect(dc)
err = flow.Error(f.request, "msg")
+ err.reply = controller.DummyReply()
fm.handle_error(err)
fm.load_script(tutils.test_data.path("scripts/a.py"))
@@ -621,7 +642,9 @@ class TestFlowMaster:
fm.tick(q)
assert fm.state.flow_count()
- fm.handle_error(flow.Error(f.request, "error"))
+ err = flow.Error(f.request, "error")
+ err.reply = controller.DummyReply()
+ fm.handle_error(err)
def test_server_playback(self):
controller.should_exit = False
@@ -717,7 +740,7 @@ class TestFlowMaster:
fm = flow.FlowMaster(None, s)
tf = tutils.tflow_full()
- fm.start_stream(file(p, "ab"))
+ fm.start_stream(file(p, "ab"), None)
fm.handle_request(tf.request)
fm.handle_response(tf.response)
fm.stop_stream()
@@ -725,7 +748,7 @@ class TestFlowMaster:
assert r()[0].response
tf = tutils.tflow_full()
- fm.start_stream(file(p, "ab"))
+ fm.start_stream(file(p, "ab"), None)
fm.handle_request(tf.request)
fm.shutdown()
@@ -760,6 +783,17 @@ class TestRequest:
r.content = flow.CONTENT_MISSING
assert not r._assemble()
+ def test_get_url(self):
+ h = flow.ODictCaseless()
+ h["test"] = ["test"]
+ c = flow.ClientConnect(("addr", 2222))
+ r = flow.Request(c, (1, 1), "host", 22, "https", "GET", "/", h, "content")
+ assert r.get_url() == "https://host:22/"
+ assert r.get_url(hostheader=True) == "https://host:22/"
+ r.headers["Host"] = ["foo.com"]
+ assert r.get_url() == "https://host:22/"
+ assert r.get_url(hostheader=True) == "https://foo.com:22/"
+
def test_path_components(self):
h = flow.ODictCaseless()
c = flow.ClientConnect(("addr", 2222))