diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_dump.py | 2 | ||||
-rw-r--r-- | test/test_examples.py | 17 | ||||
-rw-r--r-- | test/test_flow.py | 2 | ||||
-rw-r--r-- | test/test_protocol_http.py | 16 | ||||
-rw-r--r-- | test/test_proxy.py | 3 |
5 files changed, 30 insertions, 10 deletions
diff --git a/test/test_dump.py b/test/test_dump.py index 604bc542..6f70450f 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -30,7 +30,7 @@ class TestDumpMaster: m.handle_clientconnect(cc) sc = proxy.connection.ServerConnection((req.get_host(), req.get_port()), None) sc.reply = mock.MagicMock() - m.handle_serverconnection(sc) + m.handle_serverconnect(sc) m.handle_request(req) resp = tutils.tresp(req, content=content) f = m.handle_response(resp) diff --git a/test/test_examples.py b/test/test_examples.py index fa57b7eb..d18b5862 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -1,12 +1,17 @@ -from libmproxy import utils, script import glob +from libmproxy import utils, script from libmproxy.proxy import config import tservers -example_dir = utils.Data("libmproxy").path("../examples") -scripts = glob.glob("%s/*.py" % example_dir) -tmaster = tservers.TestMaster(config.ProxyConfig()) +def test_load_scripts(): + + example_dir = utils.Data("libmproxy").path("../examples") + scripts = glob.glob("%s/*.py" % example_dir) + + tmaster = tservers.TestMaster(config.ProxyConfig()) -for f in scripts: - script.Script(f, tmaster) # Loads the script file.
\ No newline at end of file + for f in scripts: + if "modify_response_body" in f: + f += " foo bar" # two arguments required + script.Script(f, tmaster) # Loads the script file.
\ No newline at end of file diff --git a/test/test_flow.py b/test/test_flow.py index 89013003..88e7b9d7 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -589,7 +589,7 @@ class TestFlowMaster: assert fm.scripts[0].ns["log"][-1] == "clientconnect" sc = ServerConnection((req.get_host(), req.get_port()), None) sc.reply = controller.DummyReply() - fm.handle_serverconnection(sc) + fm.handle_serverconnect(sc) assert fm.scripts[0].ns["log"][-1] == "serverconnect" f = fm.handle_request(req) assert fm.scripts[0].ns["log"][-1] == "request" diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py index 4026e79a..451b7b5d 100644 --- a/test/test_protocol_http.py +++ b/test/test_protocol_http.py @@ -54,7 +54,6 @@ class TestHTTPRequest: r = tutils.treq() tutils.raises("Invalid request form", r._assemble, "antiauthority") - def test_set_url(self): r = tutils.treq_absolute() r.set_url("https://otheraddress:42/ORLY") @@ -127,6 +126,21 @@ class TestProxyChainingSSL(tservers.HTTPChainProxyTest): # request from chain[1] to proxy assert self.proxy.tmaster.state.flow_count() == 1 # request from chain[0] (regular proxy doesn't store CONNECTs) + def test_closing_connect_response(self): + """ + https://github.com/mitmproxy/mitmproxy/issues/313 + """ + def handle_request(r): + r.httpversion = (1,0) + del r.headers["Content-Length"] + r.reply() + _handle_request = self.chain[0].tmaster.handle_request + self.chain[0].tmaster.handle_request = handle_request + try: + assert self.pathoc().request("get:/p/418").status_code == 418 + finally: + self.chain[0].tmaster.handle_request = _handle_request + class TestProxyChainingSSLReconnect(tservers.HTTPChainProxyTest): ssl = True diff --git a/test/test_proxy.py b/test/test_proxy.py index 0f438482..96279b9f 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -70,7 +70,8 @@ class TestProcessProxyOptions: self.assert_err("transparent mode not supported", "-T") @mock.patch("libmproxy.platform.resolver") - def test_transparent_reverse(self, o): + @mock.patch("libmproxy.platform.setup") + def test_transparent_reverse(self, _, __): self.assert_err("mutually exclusive", "-R", "http://localhost", "-T") self.assert_noerr("-T") self.assert_err("Invalid server specification", "-R", "reverse") |