diff options
-rw-r--r-- | test/mitmproxy/test_app.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_fuzzing.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_protocol_http1.py | 6 | ||||
-rw-r--r-- | test/mitmproxy/test_server.py | 54 | ||||
-rw-r--r-- | test/mitmproxy/tservers.py | 32 |
5 files changed, 48 insertions, 48 deletions
diff --git a/test/mitmproxy/test_app.py b/test/mitmproxy/test_app.py index 577a70a5..8d8ce271 100644 --- a/test/mitmproxy/test_app.py +++ b/test/mitmproxy/test_app.py @@ -1,7 +1,7 @@ from . import tutils, tservers -class TestApp(tservers.HTTPProxTest): +class TestApp(tservers.HTTPProxyTest): def test_basic(self): assert self.app("/").status_code == 200 diff --git a/test/mitmproxy/test_fuzzing.py b/test/mitmproxy/test_fuzzing.py index cec64f58..27ea36a6 100644 --- a/test/mitmproxy/test_fuzzing.py +++ b/test/mitmproxy/test_fuzzing.py @@ -6,7 +6,7 @@ from . import tservers """ -class TestFuzzy(tservers.HTTPProxTest): +class TestFuzzy(tservers.HTTPProxyTest): def test_idna_err(self): req = r'get:"http://localhost:%s":i10,"\xc6"' diff --git a/test/mitmproxy/test_protocol_http1.py b/test/mitmproxy/test_protocol_http1.py index 13e0eabe..e0a57b4e 100644 --- a/test/mitmproxy/test_protocol_http1.py +++ b/test/mitmproxy/test_protocol_http1.py @@ -11,7 +11,7 @@ class TestHTTPFlow(object): assert repr(f) -class TestInvalidRequests(tservers.HTTPProxTest): +class TestInvalidRequests(tservers.HTTPProxyTest): ssl = True def test_double_connect(self): @@ -28,7 +28,7 @@ class TestInvalidRequests(tservers.HTTPProxTest): assert "Invalid HTTP request form" in r.content -class TestExpectHeader(tservers.HTTPProxTest): +class TestExpectHeader(tservers.HTTPProxyTest): def test_simple(self): client = TCPClient(("127.0.0.1", self.proxy.port)) @@ -55,7 +55,7 @@ class TestExpectHeader(tservers.HTTPProxTest): client.finish() -class TestHeadContentLength(tservers.HTTPProxTest): +class TestHeadContentLength(tservers.HTTPProxyTest): def test_head_content_length(self): p = self.pathoc() diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py index 6d023b57..d7b23bbb 100644 --- a/test/mitmproxy/test_server.py +++ b/test/mitmproxy/test_server.py @@ -45,7 +45,7 @@ class CommonMixin: def test_replay(self): assert self.pathod("304").status_code == 304 - if isinstance(self, tservers.HTTPUpstreamProxTest) and self.ssl: + if isinstance(self, tservers.HTTPUpstreamProxyTest) and self.ssl: assert len(self.master.state.view) == 2 else: assert len(self.master.state.view) == 1 @@ -60,7 +60,7 @@ class CommonMixin: l.request.path = "/p/305:d0" rt = self.master.replay_request(l, block=True) assert not rt - if isinstance(self, tservers.HTTPUpstreamProxTest): + if isinstance(self, tservers.HTTPUpstreamProxyTest): assert l.response.status_code == 502 else: assert l.error @@ -72,7 +72,7 @@ class CommonMixin: # SSL with the upstream proxy. rt = self.master.replay_request(l, block=True) assert not rt - if isinstance(self, tservers.HTTPUpstreamProxTest): + if isinstance(self, tservers.HTTPUpstreamProxyTest): assert l.response.status_code == 502 else: assert l.error @@ -202,7 +202,7 @@ class AppMixin: assert "mitmproxy" in ret.content -class TestHTTP(tservers.HTTPProxTest, CommonMixin, AppMixin): +class TestHTTP(tservers.HTTPProxyTest, CommonMixin, AppMixin): def test_app_err(self): p = self.pathoc() @@ -292,7 +292,7 @@ class TestHTTP(tservers.HTTPProxTest, CommonMixin, AppMixin): self.master.unload_scripts() -class TestHTTPAuth(tservers.HTTPProxTest): +class TestHTTPAuth(tservers.HTTPProxyTest): authenticator = http.authentication.BasicProxyAuth( http.authentication.PassManSingleUser( "test", @@ -314,7 +314,7 @@ class TestHTTPAuth(tservers.HTTPProxTest): assert ret.status_code == 202 -class TestHTTPS(tservers.HTTPProxTest, CommonMixin, TcpMixin): +class TestHTTPS(tservers.HTTPProxyTest, CommonMixin, TcpMixin): ssl = True ssloptions = pathod.SSLOptions(request_client_cert=True) @@ -342,7 +342,7 @@ class TestHTTPS(tservers.HTTPProxTest, CommonMixin, TcpMixin): assert p.request("get:/:i0,'invalid\r\n\r\n'").status_code == 400 -class TestHTTPSCertfile(tservers.HTTPProxTest, CommonMixin): +class TestHTTPSCertfile(tservers.HTTPProxyTest, CommonMixin): ssl = True certfile = True @@ -350,7 +350,7 @@ class TestHTTPSCertfile(tservers.HTTPProxTest, CommonMixin): assert self.pathod("304") -class TestHTTPSUpstreamServerVerificationWTrustedCert(tservers.HTTPProxTest): +class TestHTTPSUpstreamServerVerificationWTrustedCert(tservers.HTTPProxyTest): """ Test upstream server certificate verification with a trusted server cert. @@ -377,7 +377,7 @@ class TestHTTPSUpstreamServerVerificationWTrustedCert(tservers.HTTPProxTest): self.pathoc() -class TestHTTPSUpstreamServerVerificationWBadCert(tservers.HTTPProxTest): +class TestHTTPSUpstreamServerVerificationWBadCert(tservers.HTTPProxyTest): """ Test upstream server certificate verification with an untrusted server cert. @@ -416,7 +416,7 @@ class TestHTTPSUpstreamServerVerificationWBadCert(tservers.HTTPProxTest): assert self._request().status_code == 502 -class TestHTTPSNoCommonName(tservers.HTTPProxTest): +class TestHTTPSNoCommonName(tservers.HTTPProxyTest): """ Test what happens if we get a cert without common name back. @@ -433,7 +433,7 @@ class TestHTTPSNoCommonName(tservers.HTTPProxTest): assert f.sslinfo.certchain[0].get_subject().CN == "127.0.0.1" -class TestReverse(tservers.ReverseProxTest, CommonMixin, TcpMixin): +class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin): reverse = True @@ -475,7 +475,7 @@ class TestSocks5(tservers.SocksModeTest): assert "SOCKS5 mode failure" in f.content -class TestHttps2Http(tservers.ReverseProxTest): +class TestHttps2Http(tservers.ReverseProxyTest): @classmethod def get_proxy_config(cls): @@ -507,7 +507,7 @@ class TestHttps2Http(tservers.ReverseProxTest): assert p.request("get:'/p/200'").status_code == 200 -class TestTransparent(tservers.TransparentProxTest, CommonMixin, TcpMixin): +class TestTransparent(tservers.TransparentProxyTest, CommonMixin, TcpMixin): ssl = False def test_tcp_stream_modify(self): @@ -523,7 +523,7 @@ class TestTransparent(tservers.TransparentProxTest, CommonMixin, TcpMixin): self.master.unload_scripts() -class TestTransparentSSL(tservers.TransparentProxTest, CommonMixin, TcpMixin): +class TestTransparentSSL(tservers.TransparentProxyTest, CommonMixin, TcpMixin): ssl = True def test_sslerr(self): @@ -533,7 +533,7 @@ class TestTransparentSSL(tservers.TransparentProxTest, CommonMixin, TcpMixin): assert r.status_code == 502 -class TestProxy(tservers.HTTPProxTest): +class TestProxy(tservers.HTTPProxyTest): def test_http(self): f = self.pathod("304") @@ -611,7 +611,7 @@ class TestProxy(tservers.HTTPProxTest): assert f.server_conn.address == ("127.0.0.1", self.server.port) -class TestProxySSL(tservers.HTTPProxTest): +class TestProxySSL(tservers.HTTPProxyTest): ssl = True def test_request_ssl_setup_timestamp_presence(self): @@ -644,7 +644,7 @@ class MasterRedirectRequest(tservers.TestMaster): super(MasterRedirectRequest, self).handle_response(f) -class TestRedirectRequest(tservers.HTTPProxTest): +class TestRedirectRequest(tservers.HTTPProxyTest): masterclass = MasterRedirectRequest ssl = True @@ -697,7 +697,7 @@ class MasterStreamRequest(tservers.TestMaster): f.reply() -class TestStreamRequest(tservers.HTTPProxTest): +class TestStreamRequest(tservers.HTTPProxyTest): masterclass = MasterStreamRequest def test_stream_simple(self): @@ -747,7 +747,7 @@ class MasterFakeResponse(tservers.TestMaster): f.reply(resp) -class TestFakeResponse(tservers.HTTPProxTest): +class TestFakeResponse(tservers.HTTPProxyTest): masterclass = MasterFakeResponse def test_fake(self): @@ -755,7 +755,7 @@ class TestFakeResponse(tservers.HTTPProxTest): assert "header-response" in f.headers -class TestServerConnect(tservers.HTTPProxTest): +class TestServerConnect(tservers.HTTPProxyTest): masterclass = MasterFakeResponse no_upstream_cert = True ssl = True @@ -773,7 +773,7 @@ class MasterKillRequest(tservers.TestMaster): f.reply(Kill) -class TestKillRequest(tservers.HTTPProxTest): +class TestKillRequest(tservers.HTTPProxyTest): masterclass = MasterKillRequest def test_kill(self): @@ -789,7 +789,7 @@ class MasterKillResponse(tservers.TestMaster): f.reply(Kill) -class TestKillResponse(tservers.HTTPProxTest): +class TestKillResponse(tservers.HTTPProxyTest): masterclass = MasterKillResponse def test_kill(self): @@ -805,7 +805,7 @@ class EResolver(tservers.TResolver): raise RuntimeError("Could not resolve original destination.") -class TestTransparentResolveError(tservers.TransparentProxTest): +class TestTransparentResolveError(tservers.TransparentProxyTest): resolver = EResolver def test_resolve_error(self): @@ -820,14 +820,14 @@ class MasterIncomplete(tservers.TestMaster): f.reply(resp) -class TestIncompleteResponse(tservers.HTTPProxTest): +class TestIncompleteResponse(tservers.HTTPProxyTest): masterclass = MasterIncomplete def test_incomplete(self): assert self.pathod("200").status_code == 502 -class TestUpstreamProxy(tservers.HTTPUpstreamProxTest, CommonMixin, AppMixin): +class TestUpstreamProxy(tservers.HTTPUpstreamProxyTest, CommonMixin, AppMixin): ssl = False def test_order(self): @@ -849,7 +849,7 @@ class TestUpstreamProxy(tservers.HTTPUpstreamProxTest, CommonMixin, AppMixin): class TestUpstreamProxySSL( - tservers.HTTPUpstreamProxTest, + tservers.HTTPUpstreamProxyTest, CommonMixin, TcpMixin): ssl = True @@ -918,7 +918,7 @@ class TestUpstreamProxySSL( assert self.chain[1].tmaster.state.flow_count() == 1 -class TestProxyChainingSSLReconnect(tservers.HTTPUpstreamProxTest): +class TestProxyChainingSSLReconnect(tservers.HTTPUpstreamProxyTest): ssl = True def test_reconnect(self): diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index 8ef554f8..b7b5de9e 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -79,7 +79,7 @@ class ProxyThread(threading.Thread): self.tmaster.shutdown() -class ProxTestBase(object): +class ProxyTestBase(object): # Test Configuration ssl = None ssloptions = False @@ -132,7 +132,7 @@ class ProxTestBase(object): ) -class HTTPProxTest(ProxTestBase): +class HTTPProxyTest(ProxyTestBase): def pathoc_raw(self): return pathod.pathoc.Pathoc(("127.0.0.1", self.proxy.port), fp=None) @@ -183,13 +183,13 @@ class TResolver: return ("127.0.0.1", self.port) -class TransparentProxTest(ProxTestBase): +class TransparentProxyTest(ProxyTestBase): ssl = None resolver = TResolver @classmethod def setup_class(cls): - super(TransparentProxTest, cls).setup_class() + super(TransparentProxyTest, cls).setup_class() cls._resolver = mock.patch( "mitmproxy.platform.resolver", @@ -200,11 +200,11 @@ class TransparentProxTest(ProxTestBase): @classmethod def teardown_class(cls): cls._resolver.stop() - super(TransparentProxTest, cls).teardown_class() + super(TransparentProxyTest, cls).teardown_class() @classmethod def get_proxy_config(cls): - d = ProxTestBase.get_proxy_config() + d = ProxyTestBase.get_proxy_config() d["mode"] = "transparent" return d @@ -231,12 +231,12 @@ class TransparentProxTest(ProxTestBase): return p -class ReverseProxTest(ProxTestBase): +class ReverseProxyTest(ProxyTestBase): ssl = None @classmethod def get_proxy_config(cls): - d = ProxTestBase.get_proxy_config() + d = ProxyTestBase.get_proxy_config() d["upstream_server"] = ( "https" if cls.ssl else "http", ("127.0.0.1", cls.server.port) @@ -267,16 +267,16 @@ class ReverseProxTest(ProxTestBase): return p.request(q) -class SocksModeTest(HTTPProxTest): +class SocksModeTest(HTTPProxyTest): @classmethod def get_proxy_config(cls): - d = ProxTestBase.get_proxy_config() + d = ProxyTestBase.get_proxy_config() d["mode"] = "socks5" return d -class ChainProxTest(ProxTestBase): +class ChainProxyTest(ProxyTestBase): """ Chain three instances of mitmproxy in a row to test upstream mode. @@ -290,7 +290,7 @@ class ChainProxTest(ProxTestBase): @classmethod def setup_class(cls): cls.chain = [] - super(ChainProxTest, cls).setup_class() + super(ChainProxyTest, cls).setup_class() for _ in range(cls.n): config = ProxyConfig(**cls.get_proxy_config()) tmaster = cls.masterclass(config) @@ -304,19 +304,19 @@ class ChainProxTest(ProxTestBase): @classmethod def teardown_class(cls): - super(ChainProxTest, cls).teardown_class() + super(ChainProxyTest, cls).teardown_class() for proxy in cls.chain: proxy.shutdown() def setup(self): - super(ChainProxTest, self).setup() + super(ChainProxyTest, self).setup() for proxy in self.chain: proxy.tmaster.clear_log() proxy.tmaster.state.clear() @classmethod def get_proxy_config(cls): - d = super(ChainProxTest, cls).get_proxy_config() + d = super(ChainProxyTest, cls).get_proxy_config() if cls.chain: # First proxy is in normal mode. d.update( mode="upstream", @@ -325,5 +325,5 @@ class ChainProxTest(ProxTestBase): return d -class HTTPUpstreamProxTest(ChainProxTest, HTTPProxTest): +class HTTPUpstreamProxyTest(ChainProxyTest, HTTPProxyTest): pass |