summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-10-16 11:42:59 -0700
committerGuido van Rossum <guido@dropbox.com>2013-10-16 11:42:59 -0700
commit85d65e304a7aac1e49d9b9f0706e75cfbdfee034 (patch)
tree66b88949f938b440a40ab631832b3835955afb53
parent0acc9b0fe2269de8c165abe3e1602187ea4d7ea4 (diff)
downloadtrollius-85d65e304a7aac1e49d9b9f0706e75cfbdfee034.tar.gz
Make tests that connect to a dummy SSL server use a dumy certificate.
-rw-r--r--tests/events_test.py6
-rw-r--r--tests/streams_test.py3
-rw-r--r--tulip/test_utils.py7
3 files changed, 13 insertions, 3 deletions
diff --git a/tests/events_test.py b/tests/events_test.py
index 4969cea..3b667aa 100644
--- a/tests/events_test.py
+++ b/tests/events_test.py
@@ -510,7 +510,8 @@ class EventLoopTestsMixin:
def test_create_ssl_connection(self):
with test_utils.run_test_server(use_ssl=True) as httpd:
f = self.loop.create_connection(
- lambda: MyProto(loop=self.loop), *httpd.address, ssl=True)
+ lambda: MyProto(loop=self.loop), *httpd.address,
+ ssl=test_utils.dummy_ssl_context())
tr, pr = self.loop.run_until_complete(f)
self.assertTrue(isinstance(tr, transports.Transport))
self.assertTrue(isinstance(pr, protocols.Protocol))
@@ -613,7 +614,8 @@ class EventLoopTestsMixin:
host, port = sock.getsockname()
self.assertEqual(host, '127.0.0.1')
- f_c = self.loop.create_connection(ClientMyProto, host, port, ssl=True)
+ f_c = self.loop.create_connection(ClientMyProto, host, port,
+ ssl=test_utils.dummy_ssl_context())
client, pr = self.loop.run_until_complete(f_c)
client.write(b'xxx')
diff --git a/tests/streams_test.py b/tests/streams_test.py
index c8ad780..c5c2ff5 100644
--- a/tests/streams_test.py
+++ b/tests/streams_test.py
@@ -50,7 +50,8 @@ class StreamReaderTests(unittest.TestCase):
with test_utils.run_test_server(use_ssl=True) as httpd:
try:
events.set_event_loop(self.loop)
- f = streams.open_connection(*httpd.address, ssl=True)
+ f = streams.open_connection(*httpd.address,
+ ssl=test_utils.dummy_ssl_context())
reader, writer = self.loop.run_until_complete(f)
finally:
events.set_event_loop(None)
diff --git a/tulip/test_utils.py b/tulip/test_utils.py
index 6100116..6555142 100644
--- a/tulip/test_utils.py
+++ b/tulip/test_utils.py
@@ -27,6 +27,13 @@ else:
from socket import socketpair # pragma: no cover
+def dummy_ssl_context():
+ if ssl is None:
+ return None
+ else:
+ return ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+
+
def run_briefly(loop):
@tulip.coroutine
def once():