Warn when using user credentials from the Cloud SDK (#266)
diff --git a/tests/test__default.py b/tests/test__default.py
index 68c4fb0..d7d537c 100644
--- a/tests/test__default.py
+++ b/tests/test__default.py
@@ -33,6 +33,9 @@
with open(AUTHORIZED_USER_FILE) as fh:
AUTHORIZED_USER_FILE_DATA = json.load(fh)
+AUTHORIZED_USER_CLOUD_SDK_FILE = os.path.join(
+ DATA_DIR, 'authorized_user_cloud_sdk.json')
+
SERVICE_ACCOUNT_FILE = os.path.join(DATA_DIR, 'service_account.json')
with open(SERVICE_ACCOUNT_FILE) as fh:
@@ -88,6 +91,14 @@
assert excinfo.match(r'missing fields')
+def test__load_credentials_from_file_authorized_user_cloud_sdk():
+ with pytest.warns(UserWarning, matches='Cloud SDK'):
+ credentials, project_id = _default._load_credentials_from_file(
+ AUTHORIZED_USER_CLOUD_SDK_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)