MCPcopy Create free account
hub / github.com/RustPython/RustPython / test_certificate_chain

Method test_certificate_chain

Lib/test/test_ssl.py:4870–4902  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4868 )
4869
4870 def test_certificate_chain(self):
4871 client_context, server_context, hostname = testing_context(
4872 server_chain=False
4873 )
4874 server = ThreadedEchoServer(context=server_context, chatty=False)
4875
4876 with open(SIGNING_CA) as f:
4877 expected_ca_cert = ssl.PEM_cert_to_DER_cert(f.read())
4878
4879 with open(SINGED_CERTFILE_ONLY) as f:
4880 expected_ee_cert = ssl.PEM_cert_to_DER_cert(f.read())
4881
4882 with server:
4883 with client_context.wrap_socket(
4884 socket.socket(),
4885 server_hostname=hostname
4886 ) as s:
4887 s.connect((HOST, server.port))
4888 vc = s.get_verified_chain()
4889 self.assertEqual(len(vc), 2)
4890
4891 ee, ca = vc
4892 self.assertIsInstance(ee, bytes)
4893 self.assertIsInstance(ca, bytes)
4894 self.assertEqual(expected_ca_cert, ca)
4895 self.assertEqual(expected_ee_cert, ee)
4896
4897 uvc = s.get_unverified_chain()
4898 self.assertEqual(len(uvc), 1)
4899 self.assertIsInstance(uvc[0], bytes)
4900
4901 self.assertEqual(ee, uvc[0])
4902 self.assertNotEqual(ee, ca)
4903
4904 def test_internal_chain_server(self):
4905 client_context, server_context, hostname = testing_context()

Callers

nothing calls this directly

Calls 13

testing_contextFunction · 0.85
ThreadedEchoServerClass · 0.85
lenFunction · 0.85
wrap_socketMethod · 0.80
socketMethod · 0.80
assertIsInstanceMethod · 0.80
assertNotEqualMethod · 0.80
openFunction · 0.50
readMethod · 0.45
connectMethod · 0.45
get_verified_chainMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected