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

Method test_sni_callback_raising

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

Source from the content-addressed store, hash-verified

4660 self.assertEqual(cm.exception.reason, 'TLSV1_ALERT_ACCESS_DENIED')
4661
4662 def test_sni_callback_raising(self):
4663 # Raising fails the connection with a TLS handshake failure alert.
4664 server_context, other_context, client_context = self.sni_contexts()
4665
4666 def cb_raising(ssl_sock, server_name, initial_context):
4667 1/0
4668 server_context.set_servername_callback(cb_raising)
4669
4670 with support.catch_unraisable_exception() as catch:
4671 with self.assertRaises(ssl.SSLError) as cm:
4672 stats = server_params_test(client_context, server_context,
4673 chatty=False,
4674 sni_name='supermessage')
4675
4676 # Allow for flexible libssl error messages.
4677 regex = "(SSLV3_ALERT_HANDSHAKE_FAILURE|NO_PRIVATE_VALUE)"
4678 self.assertRegex(cm.exception.reason, regex)
4679 self.assertEqual(catch.unraisable.exc_type, ZeroDivisionError)
4680
4681 def test_sni_callback_wrong_return_type(self):
4682 # Returning the wrong return type terminates the TLS connection

Callers

nothing calls this directly

Calls 6

sni_contextsMethod · 0.95
server_params_testFunction · 0.85
assertRegexMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected