diff options
author | Christian Heimes <christian@cheimes.de> | 2013-11-22 00:51:30 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-11-22 00:51:30 (GMT) |
commit | 44109d7de7f24b681c973880aa3e1d39042078fd (patch) | |
tree | fb012b20f74b2bd6898154bf2055e355b4b85a2d /Lib/test/test_ssl.py | |
parent | d06289254280f55536a765b1b5c36e6160b6c8e6 (diff) | |
download | cpython-44109d7de7f24b681c973880aa3e1d39042078fd.zip cpython-44109d7de7f24b681c973880aa3e1d39042078fd.tar.gz cpython-44109d7de7f24b681c973880aa3e1d39042078fd.tar.bz2 |
Issue #17134: Finalize interface to Windows' certificate store. Cert and
CRL enumeration are now two functions. enum_certificates() also returns
purpose flags as set of OIDs.
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r-- | Lib/test/test_ssl.py | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 9996ff1..2190d9f 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -528,29 +528,44 @@ class BasicSocketTests(unittest.TestCase): self.assertEqual(paths.cafile, CERTFILE) self.assertEqual(paths.capath, CAPATH) - @unittest.skipUnless(sys.platform == "win32", "Windows specific") - def test_enum_cert_store(self): - self.assertEqual(ssl.X509_ASN_ENCODING, 1) - self.assertEqual(ssl.PKCS_7_ASN_ENCODING, 0x00010000) - - self.assertEqual(ssl.enum_cert_store("CA"), - ssl.enum_cert_store("CA", "certificate")) - ssl.enum_cert_store("CA", "crl") - self.assertEqual(ssl.enum_cert_store("ROOT"), - ssl.enum_cert_store("ROOT", "certificate")) - ssl.enum_cert_store("ROOT", "crl") - - self.assertRaises(TypeError, ssl.enum_cert_store) - self.assertRaises(WindowsError, ssl.enum_cert_store, "") - self.assertRaises(ValueError, ssl.enum_cert_store, "CA", "wrong") - - ca = ssl.enum_cert_store("CA") + def test_enum_certificates(self): + self.assertTrue(ssl.enum_certificates("CA")) + self.assertTrue(ssl.enum_certificates("ROOT")) + + self.assertRaises(TypeError, ssl.enum_certificates) + self.assertRaises(WindowsError, ssl.enum_certificates, "") + + names = set() + ca = ssl.enum_certificates("CA") self.assertIsInstance(ca, list) - self.assertIsInstance(ca[0], tuple) - self.assertEqual(len(ca[0]), 2) - self.assertIsInstance(ca[0][0], bytes) - self.assertIsInstance(ca[0][1], int) + for element in ca: + self.assertIsInstance(element, tuple) + self.assertEqual(len(element), 3) + cert, enc, trust = element + self.assertIsInstance(cert, bytes) + self.assertIn(enc, {"x509_asn", "pkcs_7_asn"}) + self.assertIsInstance(trust, (set, bool)) + if isinstance(trust, set): + names.update(trust) + + serverAuth = "1.3.6.1.5.5.7.3.1" + self.assertIn(serverAuth, names) + + @unittest.skipUnless(sys.platform == "win32", "Windows specific") + def test_enum_crls(self): + self.assertTrue(ssl.enum_crls("CA")) + self.assertRaises(TypeError, ssl.enum_crls) + self.assertRaises(WindowsError, ssl.enum_crls, "") + + crls = ssl.enum_crls("CA") + self.assertIsInstance(crls, list) + for element in crls: + self.assertIsInstance(element, tuple) + self.assertEqual(len(element), 2) + self.assertIsInstance(element[0], bytes) + self.assertIn(element[1], {"x509_asn", "pkcs_7_asn"}) + def test_asn1object(self): expected = (129, 'serverAuth', 'TLS Web Server Authentication', |