]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Minor config cleanup (#621)
authorTom Christie <tom@tomchristie.com>
Mon, 9 Dec 2019 10:59:55 +0000 (10:59 +0000)
committerGitHub <noreply@github.com>
Mon, 9 Dec 2019 10:59:55 +0000 (10:59 +0000)
httpx/config.py
tests/test_config.py

index 34c3ad04f51dc0588bf5631ee62738e2a799a49d..294c1ab709c369b8b0a5ccd73b52854d6f942dcf 100644 (file)
@@ -50,6 +50,8 @@ class SSLConfig:
     SSL Configuration.
     """
 
+    DEFAULT_CA_BUNDLE_PATH = Path(certifi.where())
+
     def __init__(
         self,
         *,
@@ -129,7 +131,7 @@ class SSLConfig:
                 self.verify = ca_bundle  # type: ignore
 
         if isinstance(self.verify, bool):
-            ca_bundle_path = DEFAULT_CA_BUNDLE_PATH
+            ca_bundle_path = self.DEFAULT_CA_BUNDLE_PATH
         elif Path(self.verify).exists():
             ca_bundle_path = Path(self.verify)
         else:
@@ -321,8 +323,6 @@ class PoolLimits:
 TimeoutConfig = Timeout  # Synonym for backwards compat
 
 
-DEFAULT_SSL_CONFIG = SSLConfig(cert=None, verify=True)
 DEFAULT_TIMEOUT_CONFIG = Timeout(timeout=5.0)
 DEFAULT_POOL_LIMITS = PoolLimits(soft_limit=10, hard_limit=100)
-DEFAULT_CA_BUNDLE_PATH = Path(certifi.where())
 DEFAULT_MAX_REDIRECTS = 20
index f97680c452200df68e58ae677c9632b64e1d1237..c2701c085ddabc9801b6487f399e9b166bb18746 100644 (file)
@@ -4,6 +4,7 @@ import ssl
 import sys
 from pathlib import Path
 
+import certifi
 import pytest
 
 import httpx
@@ -24,7 +25,7 @@ def test_load_ssl_config_verify_non_existing_path():
 
 
 def test_load_ssl_config_verify_existing_file():
-    ssl_config = SSLConfig(verify=httpx.config.DEFAULT_CA_BUNDLE_PATH)
+    ssl_config = SSLConfig(verify=certifi.where())
     context = ssl_config.load_ssl_context()
     assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED
     assert context.check_hostname is True
@@ -55,7 +56,7 @@ def test_load_ssl_config_verify_env_file(https_server, ca_cert_pem_file, config)
 
 
 def test_load_ssl_config_verify_directory():
-    path = httpx.config.DEFAULT_CA_BUNDLE_PATH.parent
+    path = Path(certifi.where()).parent
     ssl_config = SSLConfig(verify=path)
     context = ssl_config.load_ssl_context()
     assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED