Example #1
0
 def test_compatibility_default_tls_not_available(self):
     restore_func = compatibility.ssl
     try:
         compatibility.ssl = SslTLSNone
         self.assertIsNone(compatibility.get_default_ssl_version())
     finally:
         compatibility.ssl = restore_func
Example #2
0
 def test_compatibility_default_ssl_none(self):
     restore_func = compatibility.ssl
     try:
         compatibility.ssl = None
         self.assertIsNone(compatibility.get_default_ssl_version())
     finally:
         compatibility.ssl = restore_func
Example #3
0
 def test_compatibility_default_tls_1(self):
     restore_func = compatibility.ssl
     try:
         compatibility.ssl = SslTLSv1
         self.assertEqual(compatibility.get_default_ssl_version(), 3)
     finally:
         compatibility.ssl = restore_func
Example #4
0
 def test_compatibility_only_tls_v1_supported(self):
     """This tests mimics the behavior of Python 2.7.8 or earlier that
     only supported TLS v1 and SSLv23.
     """
     restore_tls_v1_2 = sys.modules['ssl'].PROTOCOL_TLSv1_2
     restore_tls_v1 = sys.modules['ssl'].PROTOCOL_TLSv1_1
     try:
         del sys.modules['ssl'].PROTOCOL_TLSv1_2
         del sys.modules['ssl'].PROTOCOL_TLSv1_1
         imp.reload(compatibility)
         self.assertEqual(compatibility.get_default_ssl_version(),
                          ssl.PROTOCOL_TLSv1)
     finally:
         sys.modules['ssl'].PROTOCOL_TLSv1_2 = restore_tls_v1_2
         sys.modules['ssl'].PROTOCOL_TLSv1_1 = restore_tls_v1
         imp.reload(compatibility)