test_config.py
This file
Path
tests/test_config.py
134 lines · 4.0 KiB · Python
Last changed by
Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
History of this fileTake it
Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
line 1why, one step back1import osFinessing interfaceTom Christiebefore adoptiond7619a9
lines 2–5why, one step back2import ssl34import pytest5Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 6why, one step back6import httpxFinessing interfaceTom Christiebefore adoptiond7619a9
lines 7–10why, one step back789@pytest.mark.asyncio10async def test_load_ssl_config():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 11why, one step back11 ssl_config = httpx.SSLConfig()Finessing interfaceTom Christiebefore adoptiond7619a9
lines 12–13why, one step back12 context = await ssl_config.load_ssl_context()13 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 14why, one step back14 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 15–18why, one step back151617@pytest.mark.asyncio18async def test_load_ssl_config_verify_non_existing_path():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 19why, one step back19 ssl_config = httpx.SSLConfig(verify="/path/to/nowhere")Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 20–25why, one step back20 with pytest.raises(IOError):21 await ssl_config.load_ssl_context()222324@pytest.mark.asyncio25async def test_load_ssl_config_verify_existing_file():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 26why, one step back26 ssl_config = httpx.SSLConfig(verify=httpx.config.DEFAULT_CA_BUNDLE_PATH)Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 27–28why, one step back27 context = await ssl_config.load_ssl_context()28 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 29why, one step back29 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 30–33why, one step back303132@pytest.mark.asyncio33async def test_load_ssl_config_verify_directory():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 34–35why, one step back34 path = os.path.dirname(httpx.config.DEFAULT_CA_BUNDLE_PATH)35 ssl_config = httpx.SSLConfig(verify=path)Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 36–37why, one step back36 context = await ssl_config.load_ssl_context()37 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 38why, one step back38 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 39–41why, one step back394041@pytest.mark.asyncioSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 42why, one step back42async def test_load_ssl_config_cert_and_key(cert_pem_file, cert_private_key_file):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 43why, one step back43 ssl_config = httpx.SSLConfig(cert=(cert_pem_file, cert_private_key_file))Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 44–45why, one step back44 context = await ssl_config.load_ssl_context()45 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 46why, one step back46 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 47–49why, one step back474849@pytest.mark.asyncioSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 50–53why, one step back50@pytest.mark.parametrize("password", [b"password", "password"])51async def test_load_ssl_config_cert_and_encrypted_key(52 cert_pem_file, cert_encrypted_private_key_file, password53):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 54why, one step back54 ssl_config = httpx.SSLConfig(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 55–65why, one step back55 cert=(cert_pem_file, cert_encrypted_private_key_file, password)56 )57 context = await ssl_config.load_ssl_context()58 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED59 assert context.check_hostname is True606162@pytest.mark.asyncio63async def test_load_ssl_config_cert_and_key_invalid_password(64 cert_pem_file, cert_encrypted_private_key_file65):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 66why, one step back66 ssl_config = httpx.SSLConfig(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 67–69why, one step back67 cert=(cert_pem_file, cert_encrypted_private_key_file, "password1")68 )69Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 70–71why, one step back70 with pytest.raises(ssl.SSLError):71 await ssl_config.load_ssl_context()Finessing interfaceTom Christiebefore adoptiond7619a9
lines 72–74why, one step back727374@pytest.mark.asyncioSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 75why, one step back75async def test_load_ssl_config_cert_without_key_raises(cert_pem_file):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 76why, one step back76 ssl_config = httpx.SSLConfig(cert=cert_pem_file)Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 77–82why, one step back77 with pytest.raises(ssl.SSLError):78 await ssl_config.load_ssl_context()798081@pytest.mark.asyncio82async def test_load_ssl_config_no_verify():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 83why, one step back83 ssl_config = httpx.SSLConfig(verify=False)Finessing interfaceTom Christiebefore adoptiond7619a9
lines 84–85why, one step back84 context = await ssl_config.load_ssl_context()85 assert context.verify_mode == ssl.VerifyMode.CERT_NONESupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 86why, one step back86 assert context.check_hostname is FalseMerge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 87–89why, one step back878889def test_ssl_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 90why, one step back90 ssl = httpx.SSLConfig(verify=False)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 91–94why, one step back91 assert repr(ssl) == "SSLConfig(cert=None, verify=False)"929394def test_timeout_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 95why, one step back95 timeout = httpx.TimeoutConfig(timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 96–97why, one step back96 assert repr(timeout) == "TimeoutConfig(timeout=5.0)"97Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 98why, one step back98 timeout = httpx.TimeoutConfig(read_timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 99–100why, one step back99 assert (100 repr(timeout)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 101why, one step back101 == "TimeoutConfig(connect_timeout=None, read_timeout=5.0, write_timeout=None)"Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 102–105why, one step back102 )103104105def test_limits_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 106why, one step back106 limits = httpx.PoolLimits(hard_limit=100)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 107–109why, one step back107 assert (108 repr(limits) == "PoolLimits(soft_limit=None, hard_limit=100, pool_timeout=None)"109 )Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 110–112why, one step back110111112def test_ssl_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 113–114why, one step back113 ssl = httpx.SSLConfig(verify=False)114 assert ssl == httpx.SSLConfig(verify=False)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 115–117why, one step back115116117def test_timeout_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 118–119why, one step back118 timeout = httpx.TimeoutConfig(timeout=5.0)119 assert timeout == httpx.TimeoutConfig(timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 120–122why, one step back120121122def test_limits_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 123–124why, one step back123 limits = httpx.PoolLimits(hard_limit=100)124 assert limits == httpx.PoolLimits(hard_limit=100)Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 125–127why, one step back125126127def test_timeout_from_tuple():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 128–129why, one step back128 timeout = httpx.TimeoutConfig(timeout=(5.0, 5.0, 5.0))129 assert timeout == httpx.TimeoutConfig(timeout=5.0)Work on bringing API into parity with `requests`. (#76)Tom Christiebefore adoption9574041
lines 130–132why, one step back130131132def test_timeout_from_config_instance():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 133–134why, one step back133 timeout = httpx.TimeoutConfig(timeout=5.0)134 assert httpx.TimeoutConfig(timeout) == httpx.TimeoutConfig(timeout=5.0)