Commit e8a257cd authored by Christian Heimes's avatar Christian Heimes

test_poplib: skip stls_context test when SNI is not available

parent cd81520e
...@@ -21,10 +21,14 @@ PORT = 0 ...@@ -21,10 +21,14 @@ PORT = 0
SUPPORTS_SSL = False SUPPORTS_SSL = False
if hasattr(poplib, 'POP3_SSL'): if hasattr(poplib, 'POP3_SSL'):
import ssl import ssl
from ssl import HAS_SNI
SUPPORTS_SSL = True SUPPORTS_SSL = True
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem") 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") 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') requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported')
# the dummy data returned by server when LIST and RETR commands are issued # the dummy data returned by server when LIST and RETR commands are issued
...@@ -330,6 +334,7 @@ class TestPOP3Class(TestCase): ...@@ -330,6 +334,7 @@ class TestPOP3Class(TestCase):
self.assertEqual(resp, expected) self.assertEqual(resp, expected)
@requires_ssl @requires_ssl
@skipUnless(HAS_SNI, 'No SNI support in ssl module')
def test_stls_context(self): def test_stls_context(self):
expected = b'+OK Begin TLS negotiation' expected = b'+OK Begin TLS negotiation'
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment