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

Method test_echo

Lib/test/test_ssl.py:3106–3148  ·  view source on GitHub ↗

Basic test of an SSL client connecting to a server

(self)

Source from the content-addressed store, hash-verified

3104
3105 @support.requires_resource('walltime')
3106 def test_echo(self):
3107 """Basic test of an SSL client connecting to a server"""
3108 if support.verbose:
3109 sys.stdout.write("\n")
3110
3111 client_context, server_context, hostname = testing_context()
3112
3113 with self.subTest(client=ssl.PROTOCOL_TLS_CLIENT, server=ssl.PROTOCOL_TLS_SERVER):
3114 server_params_test(client_context=client_context,
3115 server_context=server_context,
3116 chatty=True, connectionchatty=True,
3117 sni_name=hostname)
3118
3119 client_context.check_hostname = False
3120 with self.subTest(client=ssl.PROTOCOL_TLS_SERVER, server=ssl.PROTOCOL_TLS_CLIENT):
3121 with self.assertRaises(ssl.SSLError) as e:
3122 server_params_test(client_context=server_context,
3123 server_context=client_context,
3124 chatty=True, connectionchatty=True,
3125 sni_name=hostname)
3126 self.assertIn(
3127 'Cannot create a client socket with a PROTOCOL_TLS_SERVER context',
3128 str(e.exception)
3129 )
3130
3131 with self.subTest(client=ssl.PROTOCOL_TLS_SERVER, server=ssl.PROTOCOL_TLS_SERVER):
3132 with self.assertRaises(ssl.SSLError) as e:
3133 server_params_test(client_context=server_context,
3134 server_context=server_context,
3135 chatty=True, connectionchatty=True)
3136 self.assertIn(
3137 'Cannot create a client socket with a PROTOCOL_TLS_SERVER context',
3138 str(e.exception)
3139 )
3140
3141 with self.subTest(client=ssl.PROTOCOL_TLS_CLIENT, server=ssl.PROTOCOL_TLS_CLIENT):
3142 with self.assertRaises(ssl.SSLError) as e:
3143 server_params_test(client_context=server_context,
3144 server_context=client_context,
3145 chatty=True, connectionchatty=True)
3146 self.assertIn(
3147 'Cannot create a client socket with a PROTOCOL_TLS_SERVER context',
3148 str(e.exception))
3149
3150 @unittest.skipUnless(support.Py_GIL_DISABLED, "test is only useful if the GIL is disabled")
3151 def test_ssl_in_multiple_threads(self):

Callers

nothing calls this directly

Calls 7

testing_contextFunction · 0.85
server_params_testFunction · 0.85
strFunction · 0.85
assertInMethod · 0.80
writeMethod · 0.45
subTestMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected