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

Function testing_context

Lib/test/test_ssl.py:286–317  ·  view source on GitHub ↗

Create context client_context, server_context, hostname = testing_context()

(server_cert=SIGNED_CERTFILE, *, server_chain=True)

Source from the content-addressed store, hash-verified

284_TEST_CONTEXT = None
285
286def testing_context(server_cert=SIGNED_CERTFILE, *, server_chain=True):
287 """Create context
288
289 client_context, server_context, hostname = testing_context()
290 """
291 global _TEST_CONTEXT
292 if USE_SAME_TEST_CONTEXT:
293 if _TEST_CONTEXT is not None:
294 return _TEST_CONTEXT
295
296 if server_cert == SIGNED_CERTFILE:
297 hostname = SIGNED_CERTFILE_HOSTNAME
298 elif server_cert == SIGNED_CERTFILE2:
299 hostname = SIGNED_CERTFILE2_HOSTNAME
300 elif server_cert == NOSANFILE:
301 hostname = NOSAN_HOSTNAME
302 else:
303 raise ValueError(server_cert)
304
305 client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
306 client_context.load_verify_locations(SIGNING_CA)
307
308 server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
309 server_context.load_cert_chain(server_cert)
310 if server_chain:
311 server_context.load_verify_locations(SIGNING_CA)
312
313 if USE_SAME_TEST_CONTEXT:
314 if _TEST_CONTEXT is not None:
315 _TEST_CONTEXT = client_context, server_context, hostname
316
317 return client_context, server_context, hostname
318
319
320class BasicSocketTests(unittest.TestCase):

Callers 15

test_read_write_zeroMethod · 0.85
test_unwrapMethod · 0.85
test_transport_eofMethod · 0.85
test_echoMethod · 0.85
test_getpeercertMethod · 0.85
test_crl_checkMethod · 0.85
test_check_hostnameMethod · 0.85
test_wrong_cert_tls12Method · 0.85
test_wrong_cert_tls13Method · 0.85
test_server_acceptMethod · 0.85

Calls 2

load_verify_locationsMethod · 0.45
load_cert_chainMethod · 0.45

Tested by

no test coverage detected