Prevent duplicate default SSLContext instances (#105348)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
vexofp 2023-12-09 16:30:12 -05:00 committed by GitHub
parent a090bcb8a5
commit 885410bcfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 12 deletions

View file

@ -51,3 +51,12 @@ def test_no_verify_ssl_context(mock_sslcontext) -> None:
mock_sslcontext.set_ciphers.assert_called_with(
SSL_CIPHER_LISTS[SSLCipherList.INTERMEDIATE]
)
def test_ssl_context_caching() -> None:
"""Test that SSLContext instances are cached correctly."""
assert client_context() is client_context(SSLCipherList.PYTHON_DEFAULT)
assert create_no_verify_ssl_context() is create_no_verify_ssl_context(
SSLCipherList.PYTHON_DEFAULT
)