Skip to content
Myr

test_config.py

This file

Path

tests/test_config.py

133 lines · 4.0 KiB · Python

Last changed by

Accept SSLContext into SSLConfig(verify=...) (#215)Seth Michael Larsonbefore adoptiondf8874b

History of this file

Take it

The walk stopped after 200 commits: lines older than bb3d452 point at it.

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 1–4why, one step back
1import ssl
23import pytest4

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 5why, one step back
5import httpx

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 6–7why, one step back
6
7

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 8why, one step back
8def test_load_ssl_config():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 9why, one step back
9 ssl_config = httpx.SSLConfig()

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 10why, one step back
10 context = ssl_config.load_ssl_context()

Finessing interfaceTom Christiebefore adoptiond7619a9

line 11why, one step back
11 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

line 12why, one step back
12 assert context.check_hostname is True

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

lines 13–14why, one step back
13
14

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 15why, one step back
15def test_load_ssl_config_verify_non_existing_path():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 16why, one step back
16 ssl_config = httpx.SSLConfig(verify="/path/to/nowhere")

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

line 17why, one step back
17 with pytest.raises(IOError):

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 18why, one step back
18 ssl_config.load_ssl_context()

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

lines 19–20why, one step back
19
20

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 21why, one step back
21def test_load_ssl_config_verify_existing_file():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 22why, one step back
22 ssl_config = httpx.SSLConfig(verify=httpx.config.DEFAULT_CA_BUNDLE_PATH)

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 23why, one step back
23 context = ssl_config.load_ssl_context()

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

line 24why, one step back
24 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

line 25why, one step back
25 assert context.check_hostname is True

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

lines 26–27why, one step back
26
27

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 28why, one step back
28def test_load_ssl_config_verify_directory():

Use pathlib.Path instead of os.path functions (#188)Stephen Brown IIbefore adoptionfde30b8

line 29why, one step back
29 path = httpx.config.DEFAULT_CA_BUNDLE_PATH.parent

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 30why, one step back
30 ssl_config = httpx.SSLConfig(verify=path)

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 31why, one step back
31 context = ssl_config.load_ssl_context()

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

line 32why, one step back
32 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

line 33why, one step back
33 assert context.check_hostname is True

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

lines 34–35why, one step back
34
35

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 36why, one step back
36def test_load_ssl_config_cert_and_key(cert_pem_file, cert_private_key_file):

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 37why, one step back
37 ssl_config = httpx.SSLConfig(cert=(cert_pem_file, cert_private_key_file))

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 38why, one step back
38 context = ssl_config.load_ssl_context()

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

line 39why, one step back
39 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

line 40why, one step back
40 assert context.check_hostname is True

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

lines 41–42why, one step back
41
42

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

line 43why, one step back
43@pytest.mark.parametrize("password", [b"password", "password"])

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 44why, one step back
44def test_load_ssl_config_cert_and_encrypted_key(

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

lines 45–46why, one step back
45 cert_pem_file, cert_encrypted_private_key_file, password
46):

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 47why, one step back
47 ssl_config = httpx.SSLConfig(

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

lines 48–49why, one step back
48 cert=(cert_pem_file, cert_encrypted_private_key_file, password)
49 )

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 50why, one step back
50 context = ssl_config.load_ssl_context()

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

lines 51–54why, one step back
51 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED
52 assert context.check_hostname is True5354

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 55why, one step back
55def test_load_ssl_config_cert_and_key_invalid_password(

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

lines 56–57why, one step back
56 cert_pem_file, cert_encrypted_private_key_file
57):

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 58why, one step back
58 ssl_config = httpx.SSLConfig(

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

lines 59–61why, one step back
59 cert=(cert_pem_file, cert_encrypted_private_key_file, "password1")
60 )61

Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8

line 62why, one step back
62 with pytest.raises(ssl.SSLError):

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 63why, one step back
63 ssl_config.load_ssl_context()

Finessing interfaceTom Christiebefore adoptiond7619a9

lines 64–65why, one step back
64
65

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 66why, one step back
66def test_load_ssl_config_cert_without_key_raises(cert_pem_file):

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 67why, one step back
67 ssl_config = httpx.SSLConfig(cert=cert_pem_file)

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

line 68why, one step back
68 with pytest.raises(ssl.SSLError):

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 69why, one step back
69 ssl_config.load_ssl_context()

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

lines 70–71why, one step back
70
71

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 72why, one step back
72def test_load_ssl_config_no_verify():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 73why, one step back
73 ssl_config = httpx.SSLConfig(verify=False)

Run SSLConfig cert loading in threadpool (#209)Can Sarıgölbefore adoptionc5248e6

line 74why, one step back
74 context = ssl_config.load_ssl_context()

Finessing interfaceTom Christiebefore adoptiond7619a9

line 75why, one step back
75 assert context.verify_mode == ssl.VerifyMode.CERT_NONE

Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29

line 76why, one step back
76 assert context.check_hostname is False

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 77–78why, one step back
77
78

Accept SSLContext into SSLConfig(verify=...) (#215)Seth Michael Larsonbefore adoptiondf8874b

lines 79–87why, one step back
79def test_load_ssl_context():
80 ssl_context = ssl.create_default_context()81 ssl_config = httpx.SSLConfig(verify=ssl_context)8283 assert ssl_config.verify is True84 assert ssl_config.ssl_context is ssl_context85 assert repr(ssl_config) == "SSLConfig(cert=None, verify=True)"8687

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

line 88why, one step back
88def test_ssl_repr():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 89why, one step back
89 ssl = httpx.SSLConfig(verify=False)

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 90–93why, one step back
90 assert repr(ssl) == "SSLConfig(cert=None, verify=False)"
919293def test_timeout_repr():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 94why, one step back
94 timeout = httpx.TimeoutConfig(timeout=5.0)

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 95–96why, one step back
95 assert repr(timeout) == "TimeoutConfig(timeout=5.0)"
96

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 97why, one step back
97 timeout = httpx.TimeoutConfig(read_timeout=5.0)

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 98–99why, one step back
98 assert (
99 repr(timeout)

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

line 100why, one step back
100 == "TimeoutConfig(connect_timeout=None, read_timeout=5.0, write_timeout=None)"

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 101–104why, one step back
101 )
102103104def test_limits_repr():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 105why, one step back
105 limits = httpx.PoolLimits(hard_limit=100)

Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054

lines 106–108why, one step back
106 assert (
107 repr(limits) == "PoolLimits(soft_limit=None, hard_limit=100, pool_timeout=None)"108 )

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 109–111why, one step back
109
110111def test_ssl_eq():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

lines 112–113why, one step back
112 ssl = httpx.SSLConfig(verify=False)
113 assert ssl == httpx.SSLConfig(verify=False)

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 114–116why, one step back
114
115116def test_timeout_eq():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

lines 117–118why, one step back
117 timeout = httpx.TimeoutConfig(timeout=5.0)
118 assert timeout == httpx.TimeoutConfig(timeout=5.0)

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

lines 119–121why, one step back
119
120121def test_limits_eq():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

lines 122–123why, one step back
122 limits = httpx.PoolLimits(hard_limit=100)
123 assert limits == httpx.PoolLimits(hard_limit=100)

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 124–126why, one step back
124
125126def test_timeout_from_tuple():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

lines 127–128why, one step back
127 timeout = httpx.TimeoutConfig(timeout=(5.0, 5.0, 5.0))
128 assert timeout == httpx.TimeoutConfig(timeout=5.0)

Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041

lines 129–131why, one step back
129
130131def test_timeout_from_config_instance():

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

lines 132–133why, one step back
132 timeout = httpx.TimeoutConfig(timeout=5.0)
133 assert httpx.TimeoutConfig(timeout) == httpx.TimeoutConfig(timeout=5.0)