fix: no warning if quota_project_id is given (#537)
If user account cred has 'quota_project_id', ignore the warning.
Implementing http://shortn/_YUlAgzL40H
diff --git a/tests/test__default.py b/tests/test__default.py
index 35000b0..b769fc7 100644
--- a/tests/test__default.py
+++ b/tests/test__default.py
@@ -37,6 +37,10 @@
DATA_DIR, "authorized_user_cloud_sdk.json"
)
+AUTHORIZED_USER_CLOUD_SDK_WITH_QUOTA_PROJECT_ID_FILE = os.path.join(
+ DATA_DIR, "authorized_user_cloud_sdk_with_quota_project_id.json"
+)
+
SERVICE_ACCOUNT_FILE = os.path.join(DATA_DIR, "service_account.json")
with open(SERVICE_ACCOUNT_FILE) as fh:
@@ -101,6 +105,13 @@
assert isinstance(credentials, google.oauth2.credentials.Credentials)
assert project_id is None
+ # No warning if the json file has quota project id.
+ credentials, project_id = _default._load_credentials_from_file(
+ AUTHORIZED_USER_CLOUD_SDK_WITH_QUOTA_PROJECT_ID_FILE
+ )
+ assert isinstance(credentials, google.oauth2.credentials.Credentials)
+ assert project_id is None
+
def test__load_credentials_from_file_service_account():
credentials, project_id = _default._load_credentials_from_file(SERVICE_ACCOUNT_FILE)