mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
asyncio: fix a few remaining issues in proxy/test_server.py
This commit is contained in:
parent
3cc5d81a4a
commit
28a8ddc0e8
@ -987,7 +987,7 @@ class TestUpstreamProxySSL(
|
|||||||
Client <- HTTPS -> Proxy <- HTTP -> Proxy <- HTTPS -> Server
|
Client <- HTTPS -> Proxy <- HTTP -> Proxy <- HTTPS -> Server
|
||||||
"""
|
"""
|
||||||
self.set_addons(RewriteToHttp())
|
self.set_addons(RewriteToHttp())
|
||||||
self.set_addons(RewriteToHttps())
|
self.chain[1].set_addons(RewriteToHttps())
|
||||||
p = self.pathoc()
|
p = self.pathoc()
|
||||||
with p.connect():
|
with p.connect():
|
||||||
resp = p.request("get:'/p/418'")
|
resp = p.request("get:'/p/418'")
|
||||||
|
@ -117,6 +117,11 @@ class ProxyThread(threading.Thread):
|
|||||||
)
|
)
|
||||||
self.tmaster.run()
|
self.tmaster.run()
|
||||||
|
|
||||||
|
def set_addons(self, *addons):
|
||||||
|
self.tmaster.reset(addons)
|
||||||
|
self.tmaster.addons.trigger("tick")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyTestBase:
|
class ProxyTestBase:
|
||||||
# Test Configuration
|
# Test Configuration
|
||||||
@ -180,8 +185,7 @@ class ProxyTestBase:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def set_addons(self, *addons):
|
def set_addons(self, *addons):
|
||||||
self.proxy.tmaster.reset(addons)
|
self.proxy.set_addons(*addons)
|
||||||
self.proxy.tmaster.addons.trigger("tick")
|
|
||||||
|
|
||||||
def addons(self):
|
def addons(self):
|
||||||
"""
|
"""
|
||||||
@ -337,8 +341,7 @@ class SocksModeTest(HTTPProxyTest):
|
|||||||
return opts
|
return opts
|
||||||
|
|
||||||
|
|
||||||
class ChainProxyTest(ProxyTestBase):
|
class HTTPUpstreamProxyTest(HTTPProxyTest):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Chain three instances of mitmproxy in a row to test upstream mode.
|
Chain three instances of mitmproxy in a row to test upstream mode.
|
||||||
Proxy order is cls.proxy -> cls.chain[0] -> cls.chain[1]
|
Proxy order is cls.proxy -> cls.chain[0] -> cls.chain[1]
|
||||||
@ -357,6 +360,12 @@ class ChainProxyTest(ProxyTestBase):
|
|||||||
proxy = ProxyThread(cls.masterclass, opts)
|
proxy = ProxyThread(cls.masterclass, opts)
|
||||||
proxy.start()
|
proxy.start()
|
||||||
cls.chain.insert(0, proxy)
|
cls.chain.insert(0, proxy)
|
||||||
|
while 1:
|
||||||
|
if(
|
||||||
|
proxy.event_loop and
|
||||||
|
proxy.event_loop.is_running()
|
||||||
|
):
|
||||||
|
break
|
||||||
|
|
||||||
super().setup_class()
|
super().setup_class()
|
||||||
|
|
||||||
@ -380,7 +389,3 @@ class ChainProxyTest(ProxyTestBase):
|
|||||||
mode="upstream:" + s,
|
mode="upstream:" + s,
|
||||||
)
|
)
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
|
|
||||||
class HTTPUpstreamProxyTest(ChainProxyTest, HTTPProxyTest):
|
|
||||||
pass
|
|
||||||
|
Loading…
Reference in New Issue
Block a user