test_config.py
This file
Path
tests/test_config.py
133 lines · 4.0 KiB · Python
Last changed by
Use pathlib.Path instead of os.path functions (#188)Stephen Brown IIbefore adoptionfde30b8
History of this fileTake it
Finessing interfaceTom Christiebefore adoptiond7619a9
lines 1–4why, one step back1import ssl23import pytest4Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 5why, one step back5import httpxFinessing interfaceTom Christiebefore adoptiond7619a9
lines 6–9why, one step back678@pytest.mark.asyncio9async def test_load_ssl_config():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 10why, one step back10 ssl_config = httpx.SSLConfig()Finessing interfaceTom Christiebefore adoptiond7619a9
lines 11–12why, one step back11 context = await ssl_config.load_ssl_context()12 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 13why, one step back13 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 14–17why, one step back141516@pytest.mark.asyncio17async def test_load_ssl_config_verify_non_existing_path():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 18why, one step back18 ssl_config = httpx.SSLConfig(verify="/path/to/nowhere")Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 19–24why, one step back19 with pytest.raises(IOError):20 await ssl_config.load_ssl_context()212223@pytest.mark.asyncio24async def test_load_ssl_config_verify_existing_file():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 25why, one step back25 ssl_config = httpx.SSLConfig(verify=httpx.config.DEFAULT_CA_BUNDLE_PATH)Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 26–27why, one step back26 context = await ssl_config.load_ssl_context()27 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 28why, one step back28 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 29–32why, one step back293031@pytest.mark.asyncio32async def test_load_ssl_config_verify_directory():Use pathlib.Path instead of os.path functions (#188)Stephen Brown IIbefore adoptionfde30b8
line 33why, one step back33 path = httpx.config.DEFAULT_CA_BUNDLE_PATH.parentRenaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 34why, one step back34 ssl_config = httpx.SSLConfig(verify=path)Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 35–36why, one step back35 context = await ssl_config.load_ssl_context()36 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 37why, one step back37 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 38–40why, one step back383940@pytest.mark.asyncioSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 41why, one step back41async def test_load_ssl_config_cert_and_key(cert_pem_file, cert_private_key_file):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 42why, one step back42 ssl_config = httpx.SSLConfig(cert=(cert_pem_file, cert_private_key_file))Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 43–44why, one step back43 context = await ssl_config.load_ssl_context()44 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIREDSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 45why, one step back45 assert context.check_hostname is TrueMerge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 46–48why, one step back464748@pytest.mark.asyncioSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 49–52why, one step back49@pytest.mark.parametrize("password", [b"password", "password"])50async def test_load_ssl_config_cert_and_encrypted_key(51 cert_pem_file, cert_encrypted_private_key_file, password52):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 53why, one step back53 ssl_config = httpx.SSLConfig(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 54–64why, one step back54 cert=(cert_pem_file, cert_encrypted_private_key_file, password)55 )56 context = await ssl_config.load_ssl_context()57 assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED58 assert context.check_hostname is True596061@pytest.mark.asyncio62async def test_load_ssl_config_cert_and_key_invalid_password(63 cert_pem_file, cert_encrypted_private_key_file64):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 65why, one step back65 ssl_config = httpx.SSLConfig(Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 66–68why, one step back66 cert=(cert_pem_file, cert_encrypted_private_key_file, "password1")67 )68Merge pull request #61 from yeraydiazdiaz/test-configTom Christiebefore adoptionabec2e8
lines 69–70why, one step back69 with pytest.raises(ssl.SSLError):70 await ssl_config.load_ssl_context()Finessing interfaceTom Christiebefore adoptiond7619a9
lines 71–73why, one step back717273@pytest.mark.asyncioSupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 74why, one step back74async def test_load_ssl_config_cert_without_key_raises(cert_pem_file):Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 75why, one step back75 ssl_config = httpx.SSLConfig(cert=cert_pem_file)Support client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
lines 76–81why, one step back76 with pytest.raises(ssl.SSLError):77 await ssl_config.load_ssl_context()787980@pytest.mark.asyncio81async def test_load_ssl_config_no_verify():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 82why, one step back82 ssl_config = httpx.SSLConfig(verify=False)Finessing interfaceTom Christiebefore adoptiond7619a9
lines 83–84why, one step back83 context = await ssl_config.load_ssl_context()84 assert context.verify_mode == ssl.VerifyMode.CERT_NONESupport client cert passwords, new TLS options (#118)Seth Michael Larsonbefore adoptionba83e29
line 85why, one step back85 assert context.check_hostname is FalseMerge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 86–88why, one step back868788def test_ssl_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 89why, one step back89 ssl = httpx.SSLConfig(verify=False)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 90–93why, one step back90 assert repr(ssl) == "SSLConfig(cert=None, verify=False)"919293def test_timeout_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 94why, one step back94 timeout = httpx.TimeoutConfig(timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 95–96why, one step back95 assert repr(timeout) == "TimeoutConfig(timeout=5.0)"96Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 97why, one step back97 timeout = httpx.TimeoutConfig(read_timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 98–99why, one step back98 assert (99 repr(timeout)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
line 100why, one step back100 == "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 101–104why, one step back101 )102103104def test_limits_repr():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
line 105why, one step back105 limits = httpx.PoolLimits(hard_limit=100)Merge pull request #23 from encode/adaptersTom Christiebefore adoption696c054
lines 106–108why, one step back106 assert (107 repr(limits) == "PoolLimits(soft_limit=None, hard_limit=100, pool_timeout=None)"108 )Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 109–111why, one step back109110111def test_ssl_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 112–113why, one step back112 ssl = httpx.SSLConfig(verify=False)113 assert ssl == httpx.SSLConfig(verify=False)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 114–116why, one step back114115116def test_timeout_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 117–118why, one step back117 timeout = httpx.TimeoutConfig(timeout=5.0)118 assert timeout == httpx.TimeoutConfig(timeout=5.0)Merge pull request #9 from encode/allow_per_request_timeout_and_sslTom Christiebefore adoptiondf84cde
lines 119–121why, one step back119120121def test_limits_eq():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 122–123why, one step back122 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 back124125126def test_timeout_from_tuple():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 127–128why, one step back127 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 back129130131def test_timeout_from_config_instance():Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b
lines 132–133why, one step back132 timeout = httpx.TimeoutConfig(timeout=5.0)133 assert httpx.TimeoutConfig(timeout) == httpx.TimeoutConfig(timeout=5.0)