mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 23:09:44 +00:00
coverage++
This commit is contained in:
parent
79aa994275
commit
bcaaa2f40b
@ -30,7 +30,7 @@ class Socks5Proxy(protocol.Layer, protocol.ServerConnectionMixin):
|
||||
if connect_request.msg != socks.CMD.CONNECT:
|
||||
raise socks.SocksError(
|
||||
socks.REP.COMMAND_NOT_SUPPORTED,
|
||||
"mitmproxy only supports SOCKS5 CONNECT."
|
||||
"mitmproxy only supports SOCKS5 CONNECT"
|
||||
)
|
||||
|
||||
# We always connect lazily, but we need to pretend to the client that we connected.
|
||||
|
@ -503,6 +503,7 @@ class TestSocks5(tservers.SocksModeTest):
|
||||
f = p.request("get:/p/200")
|
||||
assert f.status_code == 502
|
||||
assert b"SOCKS5 mode failure" in f.content
|
||||
assert b"Invalid SOCKS version. Expected 0x05, got 0x47" in f.content
|
||||
|
||||
def test_no_connect(self):
|
||||
"""
|
||||
@ -526,6 +527,27 @@ class TestSocks5(tservers.SocksModeTest):
|
||||
f = p.request("get:/p/200") # the request doesn't matter, error response from handshake will be read anyway.
|
||||
assert f.status_code == 502
|
||||
assert b"SOCKS5 mode failure" in f.content
|
||||
assert b"mitmproxy only supports SOCKS5 CONNECT" in f.content
|
||||
|
||||
def test_with_authentication(self):
|
||||
p = self.pathoc()
|
||||
with p.connect():
|
||||
socks.ClientGreeting(
|
||||
socks.VERSION.SOCKS5,
|
||||
[socks.METHOD.USERNAME_PASSWORD]
|
||||
).to_file(p.wfile)
|
||||
socks.Message(
|
||||
socks.VERSION.SOCKS5,
|
||||
socks.CMD.BIND,
|
||||
socks.ATYP.DOMAINNAME,
|
||||
("example.com", 8080)
|
||||
).to_file(p.wfile)
|
||||
|
||||
p.wfile.flush()
|
||||
f = p.request("get:/p/200") # the request doesn't matter, error response from handshake will be read anyway.
|
||||
assert f.status_code == 502
|
||||
assert b"SOCKS5 mode failure" in f.content
|
||||
assert b"mitmproxy only supports SOCKS without authentication" in f.content
|
||||
|
||||
|
||||
class TestSocks5SSL(tservers.SocksModeTest):
|
||||
|
2
tox.ini
2
tox.ini
@ -15,7 +15,7 @@ commands =
|
||||
--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/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/proxy/ --no-full-cov=mitmproxy/proxy/protocol/ --no-full-cov=mitmproxy/proxy/modes/socks_proxy.py --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/test/ \
|
||||
--full-cov=mitmproxy/types/ --no-full-cov=mitmproxy/types/basethread.py \
|
||||
|
Loading…
Reference in New Issue
Block a user