mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
100% test coverage
This commit is contained in:
parent
6fbe3006af
commit
7f7ccd3a18
@ -302,7 +302,7 @@ class _Connection(object):
|
|||||||
self.connection.shutdown()
|
self.connection.shutdown()
|
||||||
except SSL.Error:
|
except SSL.Error:
|
||||||
pass
|
pass
|
||||||
except KeyError as e:
|
except KeyError as e: # pragma: no cover
|
||||||
# Workaround for https://github.com/pyca/pyopenssl/pull/183
|
# Workaround for https://github.com/pyca/pyopenssl/pull/183
|
||||||
if OpenSSL.__version__ != "0.14":
|
if OpenSSL.__version__ != "0.14":
|
||||||
raise e
|
raise e
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import cStringIO, Queue, time, socket, random
|
import cStringIO, Queue, time, socket, random
|
||||||
import os
|
import os
|
||||||
from netlib import tcp, certutils, test, certffi
|
from netlib import tcp, certutils, test, certffi
|
||||||
|
import threading
|
||||||
import mock
|
import mock
|
||||||
import tutils
|
import tutils
|
||||||
from OpenSSL import SSL
|
from OpenSSL import SSL
|
||||||
@ -39,6 +40,15 @@ class TestServer(test.ServerTestBase):
|
|||||||
c.wfile.flush()
|
c.wfile.flush()
|
||||||
assert c.rfile.readline() == testval
|
assert c.rfile.readline() == testval
|
||||||
|
|
||||||
|
def test_thread_start_error(self):
|
||||||
|
with mock.patch.object(threading.Thread, "start", side_effect=threading.ThreadError("nonewthread")) as m:
|
||||||
|
c = tcp.TCPClient(("127.0.0.1", self.port))
|
||||||
|
c.connect()
|
||||||
|
assert not c.rfile.read(1)
|
||||||
|
assert m.called
|
||||||
|
assert "nonewthread" in self.q.get_nowait()
|
||||||
|
self.test_echo()
|
||||||
|
|
||||||
|
|
||||||
class TestServerBind(test.ServerTestBase):
|
class TestServerBind(test.ServerTestBase):
|
||||||
class handler(tcp.BaseHandler):
|
class handler(tcp.BaseHandler):
|
||||||
@ -72,7 +82,7 @@ class TestServerIPv6(test.ServerTestBase):
|
|||||||
assert c.rfile.readline() == testval
|
assert c.rfile.readline() == testval
|
||||||
|
|
||||||
|
|
||||||
class TestDisconnect(test.ServerTestBase):
|
class TestEcho(test.ServerTestBase):
|
||||||
handler = EchoHandler
|
handler = EchoHandler
|
||||||
def test_echo(self):
|
def test_echo(self):
|
||||||
testval = "echo!\n"
|
testval = "echo!\n"
|
||||||
@ -553,17 +563,6 @@ class TestAddress:
|
|||||||
assert repr(a)
|
assert repr(a)
|
||||||
|
|
||||||
|
|
||||||
class TestServer(test.ServerTestBase):
|
|
||||||
handler = EchoHandler
|
|
||||||
def test_echo(self):
|
|
||||||
testval = "echo!\n"
|
|
||||||
c = tcp.TCPClient(("127.0.0.1", self.port))
|
|
||||||
c.connect()
|
|
||||||
c.wfile.write(testval)
|
|
||||||
c.wfile.flush()
|
|
||||||
assert c.rfile.readline() == testval
|
|
||||||
|
|
||||||
|
|
||||||
class TestSSLKeyLogger(test.ServerTestBase):
|
class TestSSLKeyLogger(test.ServerTestBase):
|
||||||
handler = EchoHandler
|
handler = EchoHandler
|
||||||
ssl = dict(
|
ssl = dict(
|
||||||
|
Loading…
Reference in New Issue
Block a user