diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2014-03-02 16:47:10 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2014-03-02 16:47:10 +1300 |
commit | e381c0366863ae412547e16d67860137a6b89a32 (patch) | |
tree | 5bb778e9b63472180a18f168166889bf56b9f2c7 /test/test_tcp.py | |
parent | 7788391903ef67ed1e779560936d60402159f8f5 (diff) | |
download | mitmproxy-e381c0366863ae412547e16d67860137a6b89a32.tar.gz mitmproxy-e381c0366863ae412547e16d67860137a6b89a32.tar.bz2 mitmproxy-e381c0366863ae412547e16d67860137a6b89a32.zip |
Cleanups, tests, and no-cover directives for code sections we can't test.
Diffstat (limited to 'test/test_tcp.py')
-rw-r--r-- | test/test_tcp.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_tcp.py b/test/test_tcp.py index 9c15e2eb..4e27a632 100644 --- a/test/test_tcp.py +++ b/test/test_tcp.py @@ -2,6 +2,7 @@ import cStringIO, Queue, time, socket, random from netlib import tcp, certutils, test import mock import tutils +from OpenSSL import SSL class SNIHandler(tcp.BaseHandler): sni = None @@ -435,3 +436,22 @@ class TestFileLike: s.readline() assert s.first_byte_timestamp == expected + def test_read_ssl_error(self): + s = cStringIO.StringIO("foobar\nfoobar") + s = mock.MagicMock() + s.read = mock.MagicMock(side_effect=SSL.Error()) + s = tcp.Reader(s) + tutils.raises(tcp.NetLibSSLError, s.read, 1) + + + +class TestAddress: + def test_simple(self): + a = tcp.Address("localhost", True) + assert a.use_ipv6 + b = tcp.Address("foo.com", True) + assert not a == b + c = tcp.Address("localhost", True) + assert a == c + + |