mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 16:17:49 +00:00
100% test coverage.
This commit is contained in:
parent
43314c77c8
commit
e26aac1d3c
@ -65,8 +65,10 @@ class Pathoc(tcp.TCPClient):
|
|||||||
return
|
return
|
||||||
except tcp.NetLibTimeout:
|
except tcp.NetLibTimeout:
|
||||||
print >> fp, "<<", "Timeout"
|
print >> fp, "<<", "Timeout"
|
||||||
except tcp.NetLibDisconnect:
|
return
|
||||||
|
except tcp.NetLibDisconnect: # pragma: nocover
|
||||||
print >> fp, "<<", "Disconnect"
|
print >> fp, "<<", "Disconnect"
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
if respdump:
|
if respdump:
|
||||||
print_full(fp, *resp)
|
print_full(fp, *resp)
|
||||||
|
@ -9,9 +9,6 @@ class PathodError(Exception): pass
|
|||||||
class PathodHandler(tcp.BaseHandler):
|
class PathodHandler(tcp.BaseHandler):
|
||||||
wbufsize = 0
|
wbufsize = 0
|
||||||
sni = None
|
sni = None
|
||||||
def debug(self, s):
|
|
||||||
logging.debug("%s:%s: %s"%(self.client_address[0], self.client_address[1], str(s)))
|
|
||||||
|
|
||||||
def info(self, s):
|
def info(self, s):
|
||||||
logging.info("%s:%s: %s"%(self.client_address[0], self.client_address[1], str(s)))
|
logging.info("%s:%s: %s"%(self.client_address[0], self.client_address[1], str(s)))
|
||||||
|
|
||||||
|
@ -57,3 +57,4 @@ class TestDaemon:
|
|||||||
d = tutils.test_data.path("data/request")
|
d = tutils.test_data.path("data/request")
|
||||||
assert "foo" in self.tval(["+%s"%d])
|
assert "foo" in self.tval(["+%s"%d])
|
||||||
assert "File" in self.tval(["+/nonexistent"])
|
assert "File" in self.tval(["+/nonexistent"])
|
||||||
|
|
||||||
|
@ -107,6 +107,12 @@ class CommonTests(tutils.DaemonTests):
|
|||||||
assert l["type"] == "error"
|
assert l["type"] == "error"
|
||||||
assert "Invalid" in l["msg"]
|
assert "Invalid" in l["msg"]
|
||||||
|
|
||||||
|
def test_invalid_headers(self):
|
||||||
|
tutils.raises(http.HttpError, self.pathoc, "get:/:h'\t'='foo'")
|
||||||
|
l = self.d.log()[0]
|
||||||
|
assert l["type"] == "error"
|
||||||
|
assert "Invalid headers" in l["msg"]
|
||||||
|
|
||||||
def test_access_denied(self):
|
def test_access_denied(self):
|
||||||
rsp = self.get("=nonexistent")
|
rsp = self.get("=nonexistent")
|
||||||
assert rsp.status_code == 800
|
assert rsp.status_code == 800
|
||||||
|
Loading…
Reference in New Issue
Block a user