From 5c1157ddaf01b9245519d176469587aa6539ac5d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 24 Jul 2013 10:32:56 +1200 Subject: Move app instantiation out of proxy.py. --- test/test_dump.py | 6 ++++++ test/tservers.py | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test_dump.py b/test/test_dump.py index 6a35cdec..b195d5f0 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -106,6 +106,12 @@ class TestDumpMaster: def test_filter(self): assert not "GET" in self._dummy_cycle(1, "~u foo", "", verbosity=1) + def test_app(self): + o = dump.Options(app=True) + s = mock.MagicMock() + m = dump.DumpMaster(s, o, None) + assert s.apps.add.call_count == 2 + def test_replacements(self): o = dump.Options(replacements=[(".*", "content", "foo")]) m = dump.DumpMaster(None, o, None) diff --git a/test/tservers.py b/test/tservers.py index 1197fb69..0606bd9c 100644 --- a/test/tservers.py +++ b/test/tservers.py @@ -4,6 +4,9 @@ import libpathod.test, libpathod.pathoc from libmproxy import proxy, flow, controller import tutils +APP_DOMAIN = "mitm" +APP_IP = "1.1.1.1" + testapp = flask.Flask(__name__) @testapp.route("/") @@ -28,6 +31,7 @@ class TestMaster(flow.FlowMaster): flow.FlowMaster.__init__(self, s, state) self.testq = testq self.clear_log() + self.start_app(APP_DOMAIN, APP_IP) def handle_request(self, m): flow.FlowMaster.handle_request(self, m) @@ -85,7 +89,6 @@ class ProxTestBase: no_upstream_cert = cls.no_upstream_cert, cacert = tutils.test_data.path("data/serverkey.pem"), authenticator = cls.authenticator, - app = True, **pconf ) tmaster = cls.masterclass(cls.tqueue, config) @@ -162,12 +165,12 @@ class HTTPProxTest(ProxTestBase): if self.ssl: p = libpathod.pathoc.Pathoc("127.0.0.1", self.proxy.port, True) print "PRE" - p.connect((proxy.APP_IP, 80)) + p.connect((APP_IP, 80)) print "POST" return p.request("get:'/%s'"%page) else: p = self.pathoc() - return p.request("get:'http://%s/%s'"%(proxy.APP_DOMAIN, page)) + return p.request("get:'http://%s/%s'"%(APP_DOMAIN, page)) class TResolver: -- cgit v1.2.3 From 10a9e3365fbfc0b0b789385a3a212ca01d332ab1 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 28 Jul 2013 18:00:49 +1200 Subject: Some refactoring of the console inteface. Reduce some state duplication, by removing currentflow variable. Fixes #141 --- test/test_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_flow.py b/test/test_flow.py index 977cdd4e..32cfb0ca 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -591,7 +591,7 @@ class TestFlowMaster: s = flow.State() fm = flow.FlowMaster(None, s) f = tutils.tflow_full() - fm.load_flow(f) + f = fm.load_flow(f) assert s.flow_count() == 1 f2 = fm.duplicate_flow(f) assert f2.response -- cgit v1.2.3 From 439d9a294c7df4d45b133e42edb3521901628daa Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 30 Jul 2013 09:42:29 +1200 Subject: Make use of a change to netlib.tcp that clarifies error conditions for flush and close. Should fix #144. --- test/test_proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_proxy.py b/test/test_proxy.py index 5828d077..c5640d8a 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -56,7 +56,7 @@ class TestServerConnection: sc = proxy.ServerConnection(proxy.ProxyConfig(), "http", self.d.IFACE, self.d.port, "host.com") sc.connect() sc.connection = mock.Mock() - sc.connection.close = mock.Mock(side_effect=IOError) + sc.connection.flush = mock.Mock(side_effect=tcp.NetLibDisconnect) sc.terminate() -- cgit v1.2.3 From f850bdd8483907b297804ab0f8d07ff1cb456ff5 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 12 Aug 2013 16:04:02 +1200 Subject: Revamp dummy cert store We no longer keep these on disk. This is for a number of reasons, including some race conditions and the fact that some valid IDNA-encoded domain names are not valid file names on Windows. --- test/test_proxy.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'test') diff --git a/test/test_proxy.py b/test/test_proxy.py index c5640d8a..85be82cb 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -116,9 +116,6 @@ class TestProcessProxyOptions: self.assert_noerr("--client-certs", confdir) self.assert_err("directory does not exist", "--client-certs", "nonexistent") - self.assert_noerr("--dummy-certs", confdir) - self.assert_err("directory does not exist", "--dummy-certs", "nonexistent") - def test_auth(self): p = self.assert_noerr("--nonanonymous") assert p.authenticator -- cgit v1.2.3