mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-28167: Remove platform.linux_distribution (GH-6871)
* test_ssl: Remove skip_if_broken_ubuntu_ssl We no longer support OpenSSL 0.9.8.15.15. * bpo-28167: Remove platform.linux_distribution
This commit is contained in:
parent
93f9a8a5af
commit
8b94b41ab7
5 changed files with 13 additions and 290 deletions
|
@ -181,22 +181,6 @@ def asn1time(cert_time):
|
|||
|
||||
return cert_time
|
||||
|
||||
# Issue #9415: Ubuntu hijacks their OpenSSL and forcefully disables SSLv2
|
||||
def skip_if_broken_ubuntu_ssl(func):
|
||||
if hasattr(ssl, 'PROTOCOL_SSLv2'):
|
||||
@functools.wraps(func)
|
||||
def f(*args, **kwargs):
|
||||
try:
|
||||
ssl.SSLContext(ssl.PROTOCOL_SSLv2)
|
||||
except ssl.SSLError:
|
||||
if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and
|
||||
platform.linux_distribution() == ('debian', 'squeeze/sid', '')):
|
||||
raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour")
|
||||
return func(*args, **kwargs)
|
||||
return f
|
||||
else:
|
||||
return func
|
||||
|
||||
needs_sni = unittest.skipUnless(ssl.HAS_SNI, "SNI support needed for this test")
|
||||
|
||||
|
||||
|
@ -975,7 +959,6 @@ class BasicSocketTests(unittest.TestCase):
|
|||
|
||||
class ContextTests(unittest.TestCase):
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
def test_constructor(self):
|
||||
for protocol in PROTOCOLS:
|
||||
ssl.SSLContext(protocol)
|
||||
|
@ -984,7 +967,6 @@ class ContextTests(unittest.TestCase):
|
|||
self.assertRaises(ValueError, ssl.SSLContext, -1)
|
||||
self.assertRaises(ValueError, ssl.SSLContext, 42)
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
def test_protocol(self):
|
||||
for proto in PROTOCOLS:
|
||||
ctx = ssl.SSLContext(proto)
|
||||
|
@ -1018,7 +1000,6 @@ class ContextTests(unittest.TestCase):
|
|||
self.assertIn('AES256-GCM-SHA384', names)
|
||||
self.assertIn('AES128-GCM-SHA256', names)
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
def test_options(self):
|
||||
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||
# OP_ALL | OP_NO_SSLv2 | OP_NO_SSLv3 is the default value
|
||||
|
@ -1333,7 +1314,6 @@ class ContextTests(unittest.TestCase):
|
|||
with self.assertRaises(ssl.SSLError) as cm:
|
||||
ctx.load_dh_params(CERTFILE)
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
def test_session_stats(self):
|
||||
for proto in PROTOCOLS:
|
||||
ctx = ssl.SSLContext(proto)
|
||||
|
@ -2554,7 +2534,6 @@ def try_protocol_combo(server_protocol, client_protocol, expect_success,
|
|||
|
||||
class ThreadedTests(unittest.TestCase):
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
def test_echo(self):
|
||||
"""Basic test of an SSL client connecting to a server"""
|
||||
if support.verbose:
|
||||
|
@ -2923,7 +2902,6 @@ class ThreadedTests(unittest.TestCase):
|
|||
self.assertIn(msg, repr(e))
|
||||
self.assertIn('certificate verify failed', repr(e))
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
@unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv2'),
|
||||
"OpenSSL is compiled without SSLv2 support")
|
||||
def test_protocol_sslv2(self):
|
||||
|
@ -2947,7 +2925,6 @@ class ThreadedTests(unittest.TestCase):
|
|||
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLS, False,
|
||||
client_options=ssl.OP_NO_TLSv1)
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
def test_PROTOCOL_TLS(self):
|
||||
"""Connecting to an SSLv23 server with various client options"""
|
||||
if support.verbose:
|
||||
|
@ -2987,7 +2964,6 @@ class ThreadedTests(unittest.TestCase):
|
|||
server_options=ssl.OP_NO_TLSv1)
|
||||
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
@unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv3'),
|
||||
"OpenSSL is compiled without SSLv3 support")
|
||||
def test_protocol_sslv3(self):
|
||||
|
@ -3007,7 +2983,6 @@ class ThreadedTests(unittest.TestCase):
|
|||
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLS,
|
||||
False, client_options=ssl.OP_NO_SSLv2)
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
def test_protocol_tlsv1(self):
|
||||
"""Connecting to a TLSv1 server with various client options"""
|
||||
if support.verbose:
|
||||
|
@ -3022,7 +2997,6 @@ class ThreadedTests(unittest.TestCase):
|
|||
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLS, False,
|
||||
client_options=ssl.OP_NO_TLSv1)
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
@unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_1"),
|
||||
"TLS version 1.1 not supported.")
|
||||
def test_protocol_tlsv1_1(self):
|
||||
|
@ -3042,7 +3016,6 @@ class ThreadedTests(unittest.TestCase):
|
|||
try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1, False)
|
||||
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1, False)
|
||||
|
||||
@skip_if_broken_ubuntu_ssl
|
||||
@unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_2"),
|
||||
"TLS version 1.2 not supported.")
|
||||
def test_protocol_tlsv1_2(self):
|
||||
|
@ -4087,24 +4060,16 @@ def test_main(verbose=False):
|
|||
if support.verbose:
|
||||
import warnings
|
||||
plats = {
|
||||
'Linux': platform.linux_distribution,
|
||||
'Mac': platform.mac_ver,
|
||||
'Windows': platform.win32_ver,
|
||||
}
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
r'dist\(\) and linux_distribution\(\) '
|
||||
'functions are deprecated .*',
|
||||
PendingDeprecationWarning,
|
||||
)
|
||||
for name, func in plats.items():
|
||||
plat = func()
|
||||
if plat and plat[0]:
|
||||
plat = '%s %r' % (name, plat)
|
||||
break
|
||||
else:
|
||||
plat = repr(platform.platform())
|
||||
for name, func in plats.items():
|
||||
plat = func()
|
||||
if plat and plat[0]:
|
||||
plat = '%s %r' % (name, plat)
|
||||
break
|
||||
else:
|
||||
plat = repr(platform.platform())
|
||||
print("test_ssl: testing with %r %r" %
|
||||
(ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
|
||||
print(" under %s" % plat)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue