MCPcopy Index your code
hub / github.com/python/cpython / test_https_sni

Method test_https_sni

Lib/test/test_urllib2_localnet.py:572–586  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

570 self.assertEqual(data, b"we care a bit")
571
572 def test_https_sni(self):
573 if ssl is None:
574 self.skipTest("ssl module required")
575 if not ssl.HAS_SNI:
576 self.skipTest("SNI support required in OpenSSL")
577 sni_name = None
578 def cb_sni(ssl_sock, server_name, initial_context):
579 nonlocal sni_name
580 sni_name = server_name
581 context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
582 context.set_servername_callback(cb_sni)
583 handler = self.start_https_server(context=context, certfile=CERT_localhost)
584 context = ssl.create_default_context(cafile=CERT_localhost)
585 self.urlopen("https://localhost:%s" % handler.port, context=context)
586 self.assertEqual(sni_name, "localhost")
587
588 def test_sending_headers(self):
589 handler = self.start_server()

Callers

nothing calls this directly

Calls 5

start_https_serverMethod · 0.95
urlopenMethod · 0.95
skipTestMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected