mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Test a difficult-to-trigger IOError, fix cert generation in test suite.
This commit is contained in:
parent
51de9f9fdf
commit
64285140f9
@ -1,4 +1,5 @@
|
|||||||
import socket, time
|
import socket, time
|
||||||
|
import mock
|
||||||
from netlib import tcp
|
from netlib import tcp
|
||||||
from libpathod import pathoc
|
from libpathod import pathoc
|
||||||
import tutils, tservers
|
import tutils, tservers
|
||||||
@ -97,6 +98,14 @@ class TestHTTP(tservers.HTTPProxTest, SanityMixin):
|
|||||||
assert p.request("get:'%s':h'Connection'='close'"%response)
|
assert p.request("get:'%s':h'Connection'='close'"%response)
|
||||||
tutils.raises("disconnect", p.request, "get:'%s'"%response)
|
tutils.raises("disconnect", p.request, "get:'%s'"%response)
|
||||||
|
|
||||||
|
def test_proxy_ioerror(self):
|
||||||
|
# Tests a difficult-to-trigger condition, where an IOError is raised
|
||||||
|
# within our read loop.
|
||||||
|
with mock.patch("libmproxy.proxy.ProxyHandler.read_request") as m:
|
||||||
|
m.side_effect = IOError("error!")
|
||||||
|
tutils.raises("empty reply", self.pathod, "304")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestHTTPS(tservers.HTTPProxTest, SanityMixin):
|
class TestHTTPS(tservers.HTTPProxTest, SanityMixin):
|
||||||
ssl = True
|
ssl = True
|
||||||
|
@ -63,7 +63,7 @@ class ProxTestBase:
|
|||||||
cls.server = libpathod.test.Daemon(ssl=cls.ssl)
|
cls.server = libpathod.test.Daemon(ssl=cls.ssl)
|
||||||
pconf = cls.get_proxy_config()
|
pconf = cls.get_proxy_config()
|
||||||
config = proxy.ProxyConfig(
|
config = proxy.ProxyConfig(
|
||||||
certfile=tutils.test_data.path("data/testkey.pem"),
|
cacert = tutils.test_data.path("data/serverkey.pem"),
|
||||||
**pconf
|
**pconf
|
||||||
)
|
)
|
||||||
tmaster = cls.masterclass(cls.tqueue, config)
|
tmaster = cls.masterclass(cls.tqueue, config)
|
||||||
|
Loading…
Reference in New Issue
Block a user