aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/console/test_flowlist.py16
-rw-r--r--test/mitmproxy/net/http/http1/test_read.py1
-rw-r--r--test/mitmproxy/utils/test_human.py7
3 files changed, 24 insertions, 0 deletions
diff --git a/test/mitmproxy/console/test_flowlist.py b/test/mitmproxy/console/test_flowlist.py
index 7c442b63..d63dab1c 100644
--- a/test/mitmproxy/console/test_flowlist.py
+++ b/test/mitmproxy/console/test_flowlist.py
@@ -1,4 +1,5 @@
from unittest import mock
+import urwid
import mitmproxy.tools.console.flowlist as flowlist
from mitmproxy.tools import console
@@ -19,3 +20,18 @@ class TestFlowlist:
with mock.patch('mitmproxy.tools.console.signals.status_message.send') as mock_thing:
x.new_request("nonexistent url", "GET")
mock_thing.assert_called_once_with(message="Invalid URL: No hostname given")
+
+ def test_logbuffer_set_focus(self):
+ m = self.mkmaster()
+ b = flowlist.LogBufferBox(m)
+ e = urwid.Text("Log message")
+ m.logbuffer.append(e)
+ m.logbuffer.append(e)
+
+ assert len(m.logbuffer) == 2
+ b.set_focus(0)
+ assert m.logbuffer.focus == 0
+ b.set_focus(1)
+ assert m.logbuffer.focus == 1
+ b.set_focus(2)
+ assert m.logbuffer.focus == 1
diff --git a/test/mitmproxy/net/http/http1/test_read.py b/test/mitmproxy/net/http/http1/test_read.py
index 642b91c0..b3589c92 100644
--- a/test/mitmproxy/net/http/http1/test_read.py
+++ b/test/mitmproxy/net/http/http1/test_read.py
@@ -243,6 +243,7 @@ def test_read_request_line():
def test_parse_authority_form():
assert _parse_authority_form(b"foo:42") == (b"foo", 42)
+ assert _parse_authority_form(b"[2001:db8:42::]:443") == (b"2001:db8:42::", 443)
with pytest.raises(exceptions.HttpSyntaxException):
_parse_authority_form(b"foo")
with pytest.raises(exceptions.HttpSyntaxException):
diff --git a/test/mitmproxy/utils/test_human.py b/test/mitmproxy/utils/test_human.py
index 3d65dfd1..76dc2f88 100644
--- a/test/mitmproxy/utils/test_human.py
+++ b/test/mitmproxy/utils/test_human.py
@@ -46,3 +46,10 @@ def test_pretty_duration():
assert human.pretty_duration(10000) == "10000s"
assert human.pretty_duration(1.123) == "1.12s"
assert human.pretty_duration(0.123) == "123ms"
+
+
+def test_format_address():
+ assert human.format_address(("::1", "54010", "0", "0")) == "[::1]:54010"
+ assert human.format_address(("::ffff:127.0.0.1", "54010", "0", "0")) == "127.0.0.1:54010"
+ assert human.format_address(("127.0.0.1", "54010")) == "127.0.0.1:54010"
+ assert human.format_address(("example.com", "54010")) == "example.com:54010"