MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_https_sni

Method test_https_sni

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

Source from the content-addressed store, hash-verified

580
581
582 def test_https_sni(self):
583 if ssl is None:
584 self.skipTest("ssl module required")
585 if not ssl.HAS_SNI:
586 self.skipTest("SNI support required in OpenSSL")
587 sni_name = None
588 def cb_sni(ssl_sock, server_name, initial_context):
589 nonlocal sni_name
590 sni_name = server_name
591 context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
592 context.set_servername_callback(cb_sni)
593 handler = self.start_https_server(context=context, certfile=CERT_localhost)
594 context = ssl.create_default_context(cafile=CERT_localhost)
595 self.urlopen("https://localhost:%s" % handler.port, context=context)
596 self.assertEqual(sni_name, "localhost")
597
598
599 def test_sending_headers(self):

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