aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorThomas Kriechbaumer <thomas@kriechbaumer.name>2017-02-04 13:34:50 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2017-02-04 13:48:55 +0100
commit966ffaa3d602b10e1716824087cd1a80e85bfc2c (patch)
tree83b66050c2234415efa6d0022c9f29b563fa73c2 /test
parent53f298ac41ff812ca69a8220862746f55c1505b8 (diff)
downloadmitmproxy-966ffaa3d602b10e1716824087cd1a80e85bfc2c.tar.gz
mitmproxy-966ffaa3d602b10e1716824087cd1a80e85bfc2c.tar.bz2
mitmproxy-966ffaa3d602b10e1716824087cd1a80e85bfc2c.zip
coverage++
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/net/test_check.py1
-rw-r--r--test/mitmproxy/net/test_socks.py7
-rw-r--r--test/mitmproxy/test_flow.py13
-rw-r--r--test/mitmproxy/types/__init__.py0
-rw-r--r--test/mitmproxy/types/test_basethread.py7
-rw-r--r--test/mitmproxy/types/test_bidi.py (renamed from test/mitmproxy/test_types_bidi.py)0
-rw-r--r--test/mitmproxy/types/test_multidict.py (renamed from test/mitmproxy/test_types_multidict.py)0
-rw-r--r--test/mitmproxy/types/test_serializable.py (renamed from test/mitmproxy/test_types_serializable.py)0
8 files changed, 27 insertions, 1 deletions
diff --git a/test/mitmproxy/net/test_check.py b/test/mitmproxy/net/test_check.py
index 36dca168..9dbc02e0 100644
--- a/test/mitmproxy/net/test_check.py
+++ b/test/mitmproxy/net/test_check.py
@@ -5,6 +5,7 @@ from mitmproxy.net import check
def test_is_valid_host():
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 not check.is_valid_host(b"one" * 255)
assert check.is_valid_host(b"one.two.")
diff --git a/test/mitmproxy/net/test_socks.py b/test/mitmproxy/net/test_socks.py
index 9b746b92..c1bd0603 100644
--- a/test/mitmproxy/net/test_socks.py
+++ b/test/mitmproxy/net/test_socks.py
@@ -179,6 +179,13 @@ def test_message_ipv6():
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():
raw = tutils.treader(b"\x05\x01\xFF\x01\x7f\x00\x00\x01\xDE\xAD\xBE\xEF")
with pytest.raises(socks.SocksError):
diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py
index 102a714d..f546d61b 100644
--- a/test/mitmproxy/test_flow.py
+++ b/test/mitmproxy/test_flow.py
@@ -251,8 +251,19 @@ class TestSerialize:
sio.write(b"bogus")
sio.seek(0)
r = mitmproxy.io.FlowReader(sio)
- with pytest.raises(FlowReadException):
+ with pytest.raises(FlowReadException) as exc_info:
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")
assert str(f) == "foo"
diff --git a/test/mitmproxy/types/__init__.py b/test/mitmproxy/types/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/mitmproxy/types/__init__.py
diff --git a/test/mitmproxy/types/test_basethread.py b/test/mitmproxy/types/test_basethread.py
new file mode 100644
index 00000000..a91588eb
--- /dev/null
+++ b/test/mitmproxy/types/test_basethread.py
@@ -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())
diff --git a/test/mitmproxy/test_types_bidi.py b/test/mitmproxy/types/test_bidi.py
index e3a259fd..e3a259fd 100644
--- a/test/mitmproxy/test_types_bidi.py
+++ b/test/mitmproxy/types/test_bidi.py
diff --git a/test/mitmproxy/test_types_multidict.py b/test/mitmproxy/types/test_multidict.py
index 9b13c5cd..9b13c5cd 100644
--- a/test/mitmproxy/test_types_multidict.py
+++ b/test/mitmproxy/types/test_multidict.py
diff --git a/test/mitmproxy/test_types_serializable.py b/test/mitmproxy/types/test_serializable.py
index dd4a3778..dd4a3778 100644
--- a/test/mitmproxy/test_types_serializable.py
+++ b/test/mitmproxy/types/test_serializable.py