1212
1313
1414def test_load_ssl_config ():
15- ssl_config = SSLConfig ()
16- context = ssl_config .ssl_context
15+ context = httpx .create_ssl_context ()
1716 assert context .verify_mode == ssl .VerifyMode .CERT_REQUIRED
1817 assert context .check_hostname is True
1918
@@ -24,8 +23,7 @@ def test_load_ssl_config_verify_non_existing_path():
2423
2524
2625def test_load_ssl_config_verify_existing_file ():
27- ssl_config = SSLConfig (verify = certifi .where ())
28- context = ssl_config .ssl_context
26+ context = httpx .create_ssl_context (verify = certifi .where ())
2927 assert context .verify_mode == ssl .VerifyMode .CERT_REQUIRED
3028 assert context .check_hostname is True
3129
@@ -38,10 +36,11 @@ def test_load_ssl_config_verify_env_file(https_server, ca_cert_pem_file, config)
3836 else str (Path (ca_cert_pem_file ).parent )
3937 )
4038 ssl_config = SSLConfig (trust_env = True )
41- context = ssl_config .ssl_context
39+ assert ssl_config .verify == os .environ [config ]
40+
41+ context = httpx .create_ssl_context (trust_env = True )
4242 assert context .verify_mode == ssl .VerifyMode .CERT_REQUIRED
4343 assert context .check_hostname is True
44- assert ssl_config .verify == os .environ [config ]
4544
4645 # Skipping 'SSL_CERT_DIR' functional test for now because
4746 # we're unable to get the certificate within the directory to
@@ -56,15 +55,13 @@ def test_load_ssl_config_verify_env_file(https_server, ca_cert_pem_file, config)
5655
5756def test_load_ssl_config_verify_directory ():
5857 path = Path (certifi .where ()).parent
59- ssl_config = SSLConfig (verify = path )
60- context = ssl_config .ssl_context
58+ context = httpx .create_ssl_context (verify = path )
6159 assert context .verify_mode == ssl .VerifyMode .CERT_REQUIRED
6260 assert context .check_hostname is True
6361
6462
6563def test_load_ssl_config_cert_and_key (cert_pem_file , cert_private_key_file ):
66- ssl_config = SSLConfig (cert = (cert_pem_file , cert_private_key_file ))
67- context = ssl_config .ssl_context
64+ context = httpx .create_ssl_context (cert = (cert_pem_file , cert_private_key_file ))
6865 assert context .verify_mode == ssl .VerifyMode .CERT_REQUIRED
6966 assert context .check_hostname is True
7067
@@ -73,10 +70,9 @@ def test_load_ssl_config_cert_and_key(cert_pem_file, cert_private_key_file):
7370def test_load_ssl_config_cert_and_encrypted_key (
7471 cert_pem_file , cert_encrypted_private_key_file , password
7572):
76- ssl_config = SSLConfig (
73+ context = httpx . create_ssl_context (
7774 cert = (cert_pem_file , cert_encrypted_private_key_file , password )
7875 )
79- context = ssl_config .ssl_context
8076 assert context .verify_mode == ssl .VerifyMode .CERT_REQUIRED
8177 assert context .check_hostname is True
8278
@@ -94,17 +90,16 @@ def test_load_ssl_config_cert_without_key_raises(cert_pem_file):
9490
9591
9692def test_load_ssl_config_no_verify ():
97- ssl_config = SSLConfig (verify = False )
98- context = ssl_config .ssl_context
93+ context = httpx .create_ssl_context (verify = False )
9994 assert context .verify_mode == ssl .VerifyMode .CERT_NONE
10095 assert context .check_hostname is False
10196
10297
10398def test_load_ssl_context ():
10499 ssl_context = ssl .create_default_context ()
105- ssl_config = SSLConfig (verify = ssl_context )
100+ context = httpx . create_ssl_context (verify = ssl_context )
106101
107- assert ssl_config . ssl_context is ssl_context
102+ assert context is ssl_context
108103
109104
110105def test_ssl_repr ():
@@ -123,13 +118,6 @@ def test_create_ssl_context_with_get_request(server, cert_pem_file):
123118 assert response .status_code == 200
124119
125120
126- def test_create_ssl_context ():
127- context = httpx .create_ssl_context ()
128-
129- assert context .verify_mode == ssl .VerifyMode .CERT_REQUIRED
130- assert context .check_hostname is True
131-
132-
133121def test_limits_repr ():
134122 limits = httpx .PoolLimits (max_connections = 100 )
135123 assert repr (limits ) == "PoolLimits(max_keepalive=None, max_connections=100)"
@@ -203,22 +191,22 @@ def test_ssl_config_support_for_keylog_file(tmpdir, monkeypatch): # pragma: noc
203191 with monkeypatch .context () as m :
204192 m .delenv ("SSLKEYLOGFILE" , raising = False )
205193
206- ssl_config = SSLConfig (trust_env = True )
194+ context = httpx . create_ssl_context (trust_env = True )
207195
208- assert ssl_config . ssl_context .keylog_filename is None
196+ assert context .keylog_filename is None
209197
210198 filename = str (tmpdir .join ("test.log" ))
211199
212200 with monkeypatch .context () as m :
213201 m .setenv ("SSLKEYLOGFILE" , filename )
214202
215- ssl_config = SSLConfig (trust_env = True )
203+ context = httpx . create_ssl_context (trust_env = True )
216204
217- assert ssl_config . ssl_context .keylog_filename == filename
205+ assert context .keylog_filename == filename
218206
219- ssl_config = SSLConfig (trust_env = False )
207+ context = httpx . create_ssl_context (trust_env = False )
220208
221- assert ssl_config . ssl_context .keylog_filename is None
209+ assert context .keylog_filename is None
222210
223211
224212@pytest .mark .parametrize (
0 commit comments