diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/scripts/all.py | 4 | ||||
-rw-r--r-- | test/scripts/concurrent_decorator.py | 23 | ||||
-rw-r--r-- | test/test_dump.py | 4 | ||||
-rw-r--r-- | test/test_flow.py | 6 | ||||
-rw-r--r-- | test/test_script.py | 10 |
5 files changed, 30 insertions, 17 deletions
diff --git a/test/scripts/all.py b/test/scripts/all.py index e6da7e51..7d30d757 100644 --- a/test/scripts/all.py +++ b/test/scripts/all.py @@ -3,6 +3,10 @@ def clientconnect(ctx, cc): ctx.log("XCLIENTCONNECT") log.append("clientconnect") +def serverconnect(ctx, cc): + ctx.log("XSERVERCONNECT") + log.append("serverconnect") + def request(ctx, r): ctx.log("XREQUEST") log.append("request") diff --git a/test/scripts/concurrent_decorator.py b/test/scripts/concurrent_decorator.py index c1c2651e..8e132006 100644 --- a/test/scripts/concurrent_decorator.py +++ b/test/scripts/concurrent_decorator.py @@ -1,6 +1,17 @@ import time from libmproxy.script import concurrent + +@concurrent +def clientconnect(context, cc): + context.log("clientconnect") + + +@concurrent +def serverconnect(context, sc): + context.log("serverconnect") + + @concurrent def request(context, flow): time.sleep(0.1) @@ -17,15 +28,5 @@ def error(context, err): @concurrent -def clientconnect(context, cc): - context.log("clientconnect") - - -@concurrent def clientdisconnect(context, dc): - context.log("clientdisconnect") - - -@concurrent -def serverconnect(context, sc): - context.log("serverconnect")
\ No newline at end of file + context.log("clientdisconnect")
\ No newline at end of file diff --git a/test/test_dump.py b/test/test_dump.py index 3b79c721..3d375f16 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -30,6 +30,9 @@ class TestDumpMaster: resp = tutils.tresp(req) resp.content = content m.handle_clientconnect(cc) + sc = proxy.ServerConnection(m.o, req.scheme, req.host, req.port, None) + sc.reply = mock.MagicMock() + m.handle_serverconnection(sc) m.handle_request(req) f = m.handle_response(resp) cd = flow.ClientDisconnect(cc) @@ -153,6 +156,7 @@ class TestDumpMaster: scripts=[[tutils.test_data.path("scripts/all.py")]], verbosity=0, eventlog=True ) assert "XCLIENTCONNECT" in ret + assert "XSERVERCONNECT" in ret assert "XREQUEST" in ret assert "XRESPONSE" in ret assert "XCLIENTDISCONNECT" in ret diff --git a/test/test_flow.py b/test/test_flow.py index 9844e0fd..c614960b 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -1,7 +1,7 @@ import Queue, time, os.path from cStringIO import StringIO import email.utils -from libmproxy import filt, flow, controller, utils, tnetstring +from libmproxy import filt, flow, controller, utils, tnetstring, proxy import tutils @@ -575,6 +575,10 @@ class TestFlowMaster: req = tutils.treq() fm.handle_clientconnect(req.client_conn) assert fm.scripts[0].ns["log"][-1] == "clientconnect" + sc = proxy.ServerConnection(None, req.scheme, req.host, req.port, None) + sc.reply = controller.DummyReply() + fm.handle_serverconnection(sc) + assert fm.scripts[0].ns["log"][-1] == "serverconnect" f = fm.handle_request(req) assert fm.scripts[0].ns["log"][-1] == "request" resp = tutils.tresp(req) diff --git a/test/test_script.py b/test/test_script.py index 766cfb8c..ad2296ef 100644 --- a/test/test_script.py +++ b/test/test_script.py @@ -103,11 +103,11 @@ class TestScript: f.error = tutils.terr(f.request) f.reply = f.request.reply - print s.run("response", f) - print s.run("error", f) - print s.run("clientconnect", f) - print s.run("clientdisconnect", f) - print s.run("serverconnect", f) + s.run("clientconnect", f) + s.run("serverconnect", f) + s.run("response", f) + s.run("error", f) + s.run("clientdisconnect", f) time.sleep(0.1) assert ctx.count == 5 |