aboutsummaryrefslogtreecommitdiff
path: root/tests_async
diff options
context:
space:
mode:
authorarithmetic1728 <58957152+arithmetic1728@users.noreply.github.com>2021-02-25 15:42:32 -0800
committerGitHub <noreply@github.com>2021-02-25 15:42:32 -0800
commit333cb765b52028329ec3ca04edf32c5764b1db68 (patch)
treeacd5c07a9513be2e97a72ed0c08237f388a8369d /tests_async
parent3f2f3eaf09006d3d0ec9c030d359114238479279 (diff)
downloadgoogle-auth-library-python-333cb765b52028329ec3ca04edf32c5764b1db68.tar.gz
fix: use gcloud creds flow (#705)
Diffstat (limited to 'tests_async')
-rw-r--r--tests_async/test__default_async.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests_async/test__default_async.py b/tests_async/test__default_async.py
index bca396a..527a8da 100644
--- a/tests_async/test__default_async.py
+++ b/tests_async/test__default_async.py
@@ -187,6 +187,24 @@ def test__get_explicit_environ_credentials_no_project_id(load, monkeypatch):
assert project_id is None
+@mock.patch(
+ "google.auth._cloud_sdk.get_application_default_credentials_path", autospec=True
+)
+@mock.patch("google.auth._default_async._get_gcloud_sdk_credentials", autospec=True)
+def test__get_explicit_environ_credentials_fallback_to_gcloud(
+ get_gcloud_creds, get_adc_path, monkeypatch
+):
+ # Set explicit credentials path to cloud sdk credentials path.
+ get_adc_path.return_value = "filename"
+ monkeypatch.setenv(environment_vars.CREDENTIALS, "filename")
+
+ _default._get_explicit_environ_credentials()
+
+ # Check we fall back to cloud sdk flow since explicit credentials path is
+ # cloud sdk credentials path
+ get_gcloud_creds.assert_called_once()
+
+
@LOAD_FILE_PATCH
@mock.patch(
"google.auth._cloud_sdk.get_application_default_credentials_path", autospec=True