|
17 | 17 | import pytest # type: ignore |
18 | 18 |
|
19 | 19 | from google.auth import exceptions |
| 20 | +from google.auth.transport import _mtls_helper |
20 | 21 | from google.auth.transport import mtls |
21 | 22 |
|
22 | 23 |
|
@@ -46,34 +47,6 @@ def side_effect(path): |
46 | 47 | check_config_path.assert_called_with("path/to/cert.json") |
47 | 48 |
|
48 | 49 |
|
49 | | -@mock.patch("google.auth.transport.mtls.getenv", autospec=True) |
50 | | -@mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) |
51 | | -def test_has_default_client_cert_source_config_path_success( |
52 | | - check_config_path, mock_getenv |
53 | | -): |
54 | | - # 1. Mock getenv to return our custom path for the env var |
55 | | - mock_getenv.side_effect = ( |
56 | | - lambda var: "path/to/cert.json" |
57 | | - if var == "GOOGLE_API_CERTIFICATE_CONFIG" |
58 | | - else None |
59 | | - ) |
60 | | - |
61 | | - # 2. Configure side_effect to return None for default paths, |
62 | | - # and a value ONLY for our custom path. |
63 | | - def side_effect(path): |
64 | | - if path == "path/to/cert.json": |
65 | | - return "/absolute/path/to/cert.json" |
66 | | - return None |
67 | | - |
68 | | - check_config_path.side_effect = side_effect |
69 | | - |
70 | | - # 3. Now the first two checks will return None, reaching the third check. |
71 | | - assert mtls.has_default_client_cert_source() |
72 | | - |
73 | | - # 4. Verify that the last call made was indeed with our env var path. |
74 | | - check_config_path.assert_called_with("path/to/cert.json") |
75 | | - |
76 | | - |
77 | 50 | @mock.patch("google.auth.transport.mtls.getenv", autospec=True) |
78 | 51 | @mock.patch("google.auth.transport._mtls_helper._check_config_path", autospec=True) |
79 | 52 | def test_has_default_client_cert_source_env_var_invalid_config_path( |
|
0 commit comments