diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-11-23 23:04:34 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-11-23 23:04:34 (GMT) |
commit | 7243b574e5fc6f9ae68dc5ebd8252047b8e78e3b (patch) | |
tree | 4cd25f9fde37754132337eebdd1b1e958bf979f4 /Lib/test | |
parent | 378e15d7abedb4a1990230d5e3c74d2390be96c4 (diff) | |
download | cpython-7243b574e5fc6f9ae68dc5ebd8252047b8e78e3b.zip cpython-7243b574e5fc6f9ae68dc5ebd8252047b8e78e3b.tar.gz cpython-7243b574e5fc6f9ae68dc5ebd8252047b8e78e3b.tar.bz2 |
don't require OpenSSL SNI to pass hostname to ssl functions (#22921)
Patch by Donald Stufft.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_events.py | 8 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_selector_events.py | 2 | ||||
-rw-r--r-- | Lib/test/test_ftplib.py | 4 | ||||
-rw-r--r-- | Lib/test/test_imaplib.py | 4 | ||||
-rw-r--r-- | Lib/test/test_poplib.py | 4 | ||||
-rw-r--r-- | Lib/test/test_ssl.py | 8 |
6 files changed, 3 insertions, 27 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index fab3259..ea657fd 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -12,9 +12,6 @@ try: import ssl except ImportError: ssl = None - HAS_SNI = False -else: - from ssl import HAS_SNI import subprocess import sys import threading @@ -857,7 +854,6 @@ class EventLoopTestsMixin: server.close() @unittest.skipIf(ssl is None, 'No ssl module') - @unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module') def test_create_server_ssl_verify_failed(self): proto = MyProto(loop=self.loop) server, host, port = self._make_ssl_server( @@ -882,7 +878,6 @@ class EventLoopTestsMixin: server.close() @unittest.skipIf(ssl is None, 'No ssl module') - @unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module') @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets') def test_create_unix_server_ssl_verify_failed(self): proto = MyProto(loop=self.loop) @@ -909,7 +904,6 @@ class EventLoopTestsMixin: server.close() @unittest.skipIf(ssl is None, 'No ssl module') - @unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module') def test_create_server_ssl_match_failed(self): proto = MyProto(loop=self.loop) server, host, port = self._make_ssl_server( @@ -937,7 +931,6 @@ class EventLoopTestsMixin: server.close() @unittest.skipIf(ssl is None, 'No ssl module') - @unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module') @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets') def test_create_unix_server_ssl_verified(self): proto = MyProto(loop=self.loop) @@ -963,7 +956,6 @@ class EventLoopTestsMixin: server.close() @unittest.skipIf(ssl is None, 'No ssl module') - @unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module') def test_create_server_ssl_verified(self): proto = MyProto(loop=self.loop) server, host, port = self._make_ssl_server( diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py index 528da39..8eba56c 100644 --- a/Lib/test/test_asyncio/test_selector_events.py +++ b/Lib/test/test_asyncio/test_selector_events.py @@ -1408,7 +1408,7 @@ class SelectorSslTransportTests(test_utils.TestCase): self.assertEqual(tr._conn_lost, 1) self.assertEqual(1, self.loop.remove_reader_count[1]) - @unittest.skipIf(ssl is None or not ssl.HAS_SNI, 'No SNI support') + @unittest.skipIf(ssl is None, 'No SSL support') def test_server_hostname(self): _SelectorSslTransport( self.loop, self.sock, self.protocol, self.sslcontext, diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index a9bf30b..fa9c6f4 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -15,9 +15,6 @@ try: import ssl except ImportError: ssl = None - HAS_SNI = False -else: - from ssl import HAS_SNI from unittest import TestCase, skipUnless from test import support @@ -927,7 +924,6 @@ class TestTLS_FTPClass(TestCase): self.client.ccc() self.assertRaises(ValueError, self.client.sock.unwrap) - @skipUnless(HAS_SNI, 'No SNI support in ssl module') def test_check_hostname(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index a6d83d4..b34e652 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -18,9 +18,6 @@ try: import ssl except ImportError: ssl = None - HAS_SNI = False -else: - from ssl import HAS_SNI CERTFILE = None CAFILE = None @@ -352,7 +349,6 @@ class ThreadedNetworkedTestsSSL(BaseThreadedNetworkedTests): imap_class = IMAP4_SSL @reap_threads - @unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module') def test_ssl_verified(self): ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ssl_context.verify_mode = ssl.CERT_REQUIRED diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index d076fc1..8a3c9f4 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -21,13 +21,10 @@ PORT = 0 SUPPORTS_SSL = False if hasattr(poplib, 'POP3_SSL'): import ssl - from ssl import HAS_SNI SUPPORTS_SSL = True CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem") CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem") -else: - HAS_SNI = False requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported') @@ -334,7 +331,6 @@ class TestPOP3Class(TestCase): self.assertEqual(resp, expected) @requires_ssl - @skipUnless(HAS_SNI, 'No SNI support in ssl module') def test_stls_context(self): expected = b'+OK Begin TLS negotiation' ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 7f1f405..928f5e6 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1281,11 +1281,8 @@ class NetworkedTests(unittest.TestCase): # Same with a server hostname s = ctx.wrap_socket(socket.socket(socket.AF_INET), server_hostname="svn.python.org") - if ssl.HAS_SNI: - s.connect(("svn.python.org", 443)) - s.close() - else: - self.assertRaises(ValueError, s.connect, ("svn.python.org", 443)) + s.connect(("svn.python.org", 443)) + s.close() # This should fail because we have no verification certs ctx.verify_mode = ssl.CERT_REQUIRED s = ctx.wrap_socket(socket.socket(socket.AF_INET)) @@ -2038,7 +2035,6 @@ else: cert = s.getpeercert() self.assertTrue(cert, "Can't get peer certificate.") - @needs_sni def test_check_hostname(self): if support.verbose: sys.stdout.write("\n") |