mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
commit
d133b8baee
@ -74,16 +74,6 @@ class Layer(_LayerCodeCompletion):
|
|||||||
"""
|
"""
|
||||||
return getattr(self.ctx, name)
|
return getattr(self.ctx, name)
|
||||||
|
|
||||||
@property
|
|
||||||
def layers(self):
|
|
||||||
"""
|
|
||||||
List of all layers, including the current layer (``[self, self.ctx, self.ctx.ctx, ...]``)
|
|
||||||
"""
|
|
||||||
return [self] + self.ctx.layers
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return type(self).__name__
|
|
||||||
|
|
||||||
|
|
||||||
class ServerConnectionMixin:
|
class ServerConnectionMixin:
|
||||||
|
|
||||||
|
@ -110,10 +110,3 @@ class RootContext:
|
|||||||
full_msg.append(" -> " + i)
|
full_msg.append(" -> " + i)
|
||||||
full_msg = "\n".join(full_msg)
|
full_msg = "\n".join(full_msg)
|
||||||
self.channel.tell("log", log.LogEntry(full_msg, level))
|
self.channel.tell("log", log.LogEntry(full_msg, level))
|
||||||
|
|
||||||
@property
|
|
||||||
def layers(self):
|
|
||||||
return []
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "RootContext"
|
|
||||||
|
@ -5,6 +5,7 @@ from mitmproxy.net import check
|
|||||||
|
|
||||||
def test_is_valid_host():
|
def test_is_valid_host():
|
||||||
assert not check.is_valid_host(b"")
|
assert not check.is_valid_host(b"")
|
||||||
|
assert not check.is_valid_host(b"xn--ke.ws")
|
||||||
assert check.is_valid_host(b"one.two")
|
assert check.is_valid_host(b"one.two")
|
||||||
assert not check.is_valid_host(b"one" * 255)
|
assert not check.is_valid_host(b"one" * 255)
|
||||||
assert check.is_valid_host(b"one.two.")
|
assert check.is_valid_host(b"one.two.")
|
||||||
|
@ -179,6 +179,13 @@ def test_message_ipv6():
|
|||||||
assert msg.addr.host == ipv6_addr
|
assert msg.addr.host == ipv6_addr
|
||||||
|
|
||||||
|
|
||||||
|
def test_message_invalid_host():
|
||||||
|
raw = tutils.treader(b"\xEE\x01\x00\x03\x0bexample@com\xDE\xAD\xBE\xEF")
|
||||||
|
with pytest.raises(socks.SocksError) as exc_info:
|
||||||
|
socks.Message.from_file(raw)
|
||||||
|
assert exc_info.match("Invalid hostname: b'example@com'")
|
||||||
|
|
||||||
|
|
||||||
def test_message_invalid_rsv():
|
def test_message_invalid_rsv():
|
||||||
raw = tutils.treader(b"\x05\x01\xFF\x01\x7f\x00\x00\x01\xDE\xAD\xBE\xEF")
|
raw = tutils.treader(b"\x05\x01\xFF\x01\x7f\x00\x00\x01\xDE\xAD\xBE\xEF")
|
||||||
with pytest.raises(socks.SocksError):
|
with pytest.raises(socks.SocksError):
|
||||||
|
@ -251,8 +251,19 @@ class TestSerialize:
|
|||||||
sio.write(b"bogus")
|
sio.write(b"bogus")
|
||||||
sio.seek(0)
|
sio.seek(0)
|
||||||
r = mitmproxy.io.FlowReader(sio)
|
r = mitmproxy.io.FlowReader(sio)
|
||||||
with pytest.raises(FlowReadException):
|
with pytest.raises(FlowReadException) as exc_info:
|
||||||
list(r.stream())
|
list(r.stream())
|
||||||
|
assert exc_info.match('Invalid data format')
|
||||||
|
|
||||||
|
sio = io.BytesIO()
|
||||||
|
f = tflow.tdummyflow()
|
||||||
|
w = mitmproxy.io.FlowWriter(sio)
|
||||||
|
w.add(f)
|
||||||
|
sio.seek(0)
|
||||||
|
r = mitmproxy.io.FlowReader(sio)
|
||||||
|
with pytest.raises(FlowReadException) as exc_info:
|
||||||
|
list(r.stream())
|
||||||
|
assert exc_info.match('Unknown flow type')
|
||||||
|
|
||||||
f = FlowReadException("foo")
|
f = FlowReadException("foo")
|
||||||
assert str(f) == "foo"
|
assert str(f) == "foo"
|
||||||
|
0
test/mitmproxy/types/__init__.py
Normal file
0
test/mitmproxy/types/__init__.py
Normal file
7
test/mitmproxy/types/test_basethread.py
Normal file
7
test/mitmproxy/types/test_basethread.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import re
|
||||||
|
from mitmproxy.types import basethread
|
||||||
|
|
||||||
|
|
||||||
|
def test_basethread():
|
||||||
|
t = basethread.BaseThread('foobar')
|
||||||
|
assert re.match('foobar - age: \d+s', t._threadinfo())
|
5
tox.ini
5
tox.ini
@ -14,16 +14,17 @@ commands =
|
|||||||
pytest --timeout 60 --cov-report='' --cov=mitmproxy --cov=pathod \
|
pytest --timeout 60 --cov-report='' --cov=mitmproxy --cov=pathod \
|
||||||
--full-cov=mitmproxy/addons/ \
|
--full-cov=mitmproxy/addons/ \
|
||||||
--full-cov=mitmproxy/contentviews/ --no-full-cov=mitmproxy/contentviews/__init__.py --no-full-cov=mitmproxy/contentviews/protobuf.py --no-full-cov=mitmproxy/contentviews/wbxml.py --no-full-cov=mitmproxy/contentviews/xml_html.py \
|
--full-cov=mitmproxy/contentviews/ --no-full-cov=mitmproxy/contentviews/__init__.py --no-full-cov=mitmproxy/contentviews/protobuf.py --no-full-cov=mitmproxy/contentviews/wbxml.py --no-full-cov=mitmproxy/contentviews/xml_html.py \
|
||||||
--full-cov=mitmproxy/net/ --no-full-cov=mitmproxy/net/check.py --no-full-cov=mitmproxy/net/socks.py --no-full-cov=mitmproxy/net/tcp.py --no-full-cov=mitmproxy/net/http/cookies.py --no-full-cov=mitmproxy/net/http/encoding.py --no-full-cov=mitmproxy/net/http/message.py --no-full-cov=mitmproxy/net/http/request.py --no-full-cov=mitmproxy/net/http/response.py --no-full-cov=mitmproxy/net/http/url.py \
|
--full-cov=mitmproxy/net/ --no-full-cov=mitmproxy/net/tcp.py --no-full-cov=mitmproxy/net/http/cookies.py --no-full-cov=mitmproxy/net/http/encoding.py --no-full-cov=mitmproxy/net/http/message.py --no-full-cov=mitmproxy/net/http/request.py --no-full-cov=mitmproxy/net/http/response.py --no-full-cov=mitmproxy/net/http/url.py \
|
||||||
--full-cov=mitmproxy/proxy/ --no-full-cov=mitmproxy/proxy/protocol/ --no-full-cov=mitmproxy/proxy/config.py --no-full-cov=mitmproxy/proxy/root_context.py --no-full-cov=mitmproxy/proxy/server.py \
|
--full-cov=mitmproxy/proxy/ --no-full-cov=mitmproxy/proxy/protocol/ --no-full-cov=mitmproxy/proxy/config.py --no-full-cov=mitmproxy/proxy/root_context.py --no-full-cov=mitmproxy/proxy/server.py \
|
||||||
--full-cov=mitmproxy/script/ \
|
--full-cov=mitmproxy/script/ \
|
||||||
--full-cov=mitmproxy/test/ \
|
--full-cov=mitmproxy/test/ \
|
||||||
--full-cov=mitmproxy/types/ --no-full-cov=mitmproxy/types/basethread.py \
|
--full-cov=mitmproxy/types/ \
|
||||||
--full-cov=mitmproxy/utils/ \
|
--full-cov=mitmproxy/utils/ \
|
||||||
--full-cov=mitmproxy/__init__.py \
|
--full-cov=mitmproxy/__init__.py \
|
||||||
--full-cov=mitmproxy/addonmanager.py \
|
--full-cov=mitmproxy/addonmanager.py \
|
||||||
--full-cov=mitmproxy/ctx.py \
|
--full-cov=mitmproxy/ctx.py \
|
||||||
--full-cov=mitmproxy/exceptions.py \
|
--full-cov=mitmproxy/exceptions.py \
|
||||||
|
--full-cov=mitmproxy/io.py \
|
||||||
--full-cov=mitmproxy/log.py \
|
--full-cov=mitmproxy/log.py \
|
||||||
--full-cov=mitmproxy/options.py \
|
--full-cov=mitmproxy/options.py \
|
||||||
--full-cov=pathod/ --no-full-cov=pathod/pathoc.py --no-full-cov=pathod/pathod.py --no-full-cov=pathod/test.py --no-full-cov=pathod/protocols/http2.py \
|
--full-cov=pathod/ --no-full-cov=pathod/pathoc.py --no-full-cov=pathod/pathod.py --no-full-cov=pathod/test.py --no-full-cov=pathod/protocols/http2.py \
|
||||||
|
Loading…
Reference in New Issue
Block a user