diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-05 21:40:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-05 21:40:07 (GMT) |
commit | 04f6a32dff60d6f22b56b887338dd6ebbdc68dfe (patch) | |
tree | 1a8163e2cb9880e4502ac3dbbda2cdcd9e0d0e3a /Lib/test/test_ssl.py | |
parent | c50846aaef3e38d466ac9a0a87f72f09238e2061 (diff) | |
download | cpython-04f6a32dff60d6f22b56b887338dd6ebbdc68dfe.zip cpython-04f6a32dff60d6f22b56b887338dd6ebbdc68dfe.tar.gz cpython-04f6a32dff60d6f22b56b887338dd6ebbdc68dfe.tar.bz2 |
Merged revisions 79812 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79812 | antoine.pitrou | 2010-04-05 23:35:07 +0200 (lun., 05 avril 2010) | 5 lines
Issue #8321: Give access to OpenSSL version numbers from the `ssl` module,
using the new attributes `ssl.OPENSSL_VERSION`, `ssl.OPENSSL_VERSION_INFO`
and `ssl.OPENSSL_VERSION_NUMBER`.
........
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r-- | Lib/test/test_ssl.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 8d6d742..1804fcd 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -94,6 +94,34 @@ class BasicTests(unittest.TestCase): if (d1 != d2): raise support.TestFailed("PEM-to-DER or DER-to-PEM translation failed") + def test_openssl_version(self): + n = ssl.OPENSSL_VERSION_NUMBER + t = ssl.OPENSSL_VERSION_INFO + s = ssl.OPENSSL_VERSION + self.assertIsInstance(n, int) + self.assertIsInstance(t, tuple) + self.assertIsInstance(s, str) + # Some sanity checks follow + # >= 0.9 + self.assertGreaterEqual(n, 0x900000) + # < 2.0 + self.assertLess(n, 0x20000000) + major, minor, fix, patch, status = t + self.assertGreaterEqual(major, 0) + self.assertLess(major, 2) + self.assertGreaterEqual(minor, 0) + self.assertLess(minor, 256) + self.assertGreaterEqual(fix, 0) + self.assertLess(fix, 256) + self.assertGreaterEqual(patch, 0) + self.assertLessEqual(patch, 26) + self.assertGreaterEqual(status, 0) + self.assertLessEqual(status, 15) + # Version string as returned by OpenSSL, the format might change + self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)), + (s, t)) + + class NetworkedTests(unittest.TestCase): def testConnect(self): |