diff options
| author | robot-piglet <[email protected]> | 2024-10-06 13:42:43 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2024-10-06 13:52:30 +0300 |
| commit | 52aed29f744afda4549ef5d64acd0fa8c2092789 (patch) | |
| tree | e40c9abd25653990d13b68936aee518454df424e /contrib/python/google-auth/py3/tests/test__default.py | |
| parent | 813943fcad905eee1235d764be4268dddd07ce64 (diff) | |
Intermediate changes
commit_hash:cc4365f5a0e443b92d87079a9c91e77fea2ddcaf
Diffstat (limited to 'contrib/python/google-auth/py3/tests/test__default.py')
| -rw-r--r-- | contrib/python/google-auth/py3/tests/test__default.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/python/google-auth/py3/tests/test__default.py b/contrib/python/google-auth/py3/tests/test__default.py index aaf892f6d04..3147d505dab 100644 --- a/contrib/python/google-auth/py3/tests/test__default.py +++ b/contrib/python/google-auth/py3/tests/test__default.py @@ -884,6 +884,38 @@ def test_default_early_out(unused_get): @mock.patch( + "google.auth._default.load_credentials_from_file", + return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id), + autospec=True, +) +def test_default_cred_file_path_env_var(unused_load_cred, monkeypatch): + monkeypatch.setenv(environment_vars.CREDENTIALS, "/path/to/file") + cred, _ = _default.default() + assert ( + cred._cred_file_path + == "/path/to/file file via the GOOGLE_APPLICATION_CREDENTIALS environment variable" + ) + + [email protected]("os.path.isfile", return_value=True, autospec=True) + "google.auth._cloud_sdk.get_application_default_credentials_path", + return_value="/path/to/adc/file", + autospec=True, +) + "google.auth._default.load_credentials_from_file", + return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id), + autospec=True, +) +def test_default_cred_file_path_gcloud( + unused_load_cred, unused_get_adc_file, unused_isfile +): + cred, _ = _default.default() + assert cred._cred_file_path == "/path/to/adc/file" + + "google.auth._default._get_explicit_environ_credentials", return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id), autospec=True, |
