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

Function testing_context

Lib/test/test_ssl.py:349–385  ·  view source on GitHub ↗

Create context client_context, server_context, hostname = testing_context()

(server_cert=SIGNED_CERTFILE, *, server_chain=True,
                    client_cert=None)

Source from the content-addressed store, hash-verified

347_TEST_CONTEXT = None
348
349def testing_context(server_cert=SIGNED_CERTFILE, *, server_chain=True,
350 client_cert=None):
351 """Create context
352
353 client_context, server_context, hostname = testing_context()
354 """
355 global _TEST_CONTEXT
356 if USE_SAME_TEST_CONTEXT:
357 if _TEST_CONTEXT is not None:
358 return _TEST_CONTEXT
359
360 if server_cert == SIGNED_CERTFILE:
361 hostname = SIGNED_CERTFILE_HOSTNAME
362 elif server_cert == SIGNED_CERTFILE2:
363 hostname = SIGNED_CERTFILE2_HOSTNAME
364 elif server_cert == NOSANFILE:
365 hostname = NOSAN_HOSTNAME
366 else:
367 raise ValueError(server_cert)
368
369 client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
370 client_context.load_verify_locations(SIGNING_CA)
371
372 server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
373 server_context.load_cert_chain(server_cert)
374 if server_chain:
375 server_context.load_verify_locations(SIGNING_CA)
376
377 if client_cert:
378 client_context.load_cert_chain(client_cert)
379 server_context.verify_mode = ssl.CERT_REQUIRED
380
381 if USE_SAME_TEST_CONTEXT:
382 if _TEST_CONTEXT is not None:
383 _TEST_CONTEXT = client_context, server_context, hostname
384
385 return client_context, server_context, hostname
386
387
388def do_ssl_object_handshake(sslobject, outgoing, max_retry=25):

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

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…