feat: add quota project to base credentials class (#546)

diff --git a/tests/test__default.py b/tests/test__default.py
index 3c87b35..0665efa 100644
--- a/tests/test__default.py
+++ b/tests/test__default.py
@@ -21,6 +21,7 @@
 from google.auth import _default
 from google.auth import app_engine
 from google.auth import compute_engine
+from google.auth import credentials
 from google.auth import environment_vars
 from google.auth import exceptions
 from google.oauth2 import service_account
@@ -48,9 +49,12 @@
 with open(SERVICE_ACCOUNT_FILE) as fh:
     SERVICE_ACCOUNT_FILE_DATA = json.load(fh)
 
+MOCK_CREDENTIALS = mock.Mock(spec=credentials.Credentials)
+MOCK_CREDENTIALS.with_quota_project.return_value = MOCK_CREDENTIALS
+
 LOAD_FILE_PATCH = mock.patch(
     "google.auth._default.load_credentials_from_file",
-    return_value=(mock.sentinel.credentials, mock.sentinel.project_id),
+    return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id),
     autospec=True,
 )
 
@@ -136,6 +140,16 @@
     assert credentials.scopes == ["https://www.google.com/calendar/feeds"]
 
 
+def test_load_credentials_from_file_authorized_user_cloud_sdk_with_quota_project():
+    credentials, project_id = _default.load_credentials_from_file(
+        AUTHORIZED_USER_CLOUD_SDK_FILE, quota_project_id="project-foo"
+    )
+
+    assert isinstance(credentials, google.oauth2.credentials.Credentials)
+    assert project_id is None
+    assert credentials.quota_project_id == "project-foo"
+
+
 def test_load_credentials_from_file_service_account():
     credentials, project_id = _default.load_credentials_from_file(SERVICE_ACCOUNT_FILE)
     assert isinstance(credentials, service_account.Credentials)
@@ -173,19 +187,19 @@
 
     credentials, project_id = _default._get_explicit_environ_credentials()
 
-    assert credentials is mock.sentinel.credentials
+    assert credentials is MOCK_CREDENTIALS
     assert project_id is mock.sentinel.project_id
     load.assert_called_with("filename")
 
 
 @LOAD_FILE_PATCH
 def test__get_explicit_environ_credentials_no_project_id(load, monkeypatch):
-    load.return_value = mock.sentinel.credentials, None
+    load.return_value = MOCK_CREDENTIALS, None
     monkeypatch.setenv(environment_vars.CREDENTIALS, "filename")
 
     credentials, project_id = _default._get_explicit_environ_credentials()
 
-    assert credentials is mock.sentinel.credentials
+    assert credentials is MOCK_CREDENTIALS
     assert project_id is None
 
 
@@ -198,7 +212,7 @@
 
     credentials, project_id = _default._get_gcloud_sdk_credentials()
 
-    assert credentials is mock.sentinel.credentials
+    assert credentials is MOCK_CREDENTIALS
     assert project_id is mock.sentinel.project_id
     load.assert_called_with(SERVICE_ACCOUNT_FILE)
 
@@ -226,11 +240,11 @@
 def test__get_gcloud_sdk_credentials_project_id(load, unused_isfile, get_project_id):
     # Don't return a project ID from load file, make the function check
     # the Cloud SDK project.
-    load.return_value = mock.sentinel.credentials, None
+    load.return_value = MOCK_CREDENTIALS, None
 
     credentials, project_id = _default._get_gcloud_sdk_credentials()
 
-    assert credentials == mock.sentinel.credentials
+    assert credentials == MOCK_CREDENTIALS
     assert project_id == mock.sentinel.project_id
     assert get_project_id.called
 
@@ -241,11 +255,11 @@
 def test__get_gcloud_sdk_credentials_no_project_id(load, unused_isfile, get_project_id):
     # Don't return a project ID from load file, make the function check
     # the Cloud SDK project.
-    load.return_value = mock.sentinel.credentials, None
+    load.return_value = MOCK_CREDENTIALS, None
 
     credentials, project_id = _default._get_gcloud_sdk_credentials()
 
-    assert credentials == mock.sentinel.credentials
+    assert credentials == MOCK_CREDENTIALS
     assert project_id is None
     assert get_project_id.called
 
@@ -351,58 +365,58 @@
 
 @mock.patch(
     "google.auth._default._get_explicit_environ_credentials",
-    return_value=(mock.sentinel.credentials, mock.sentinel.project_id),
+    return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id),
     autospec=True,
 )
 def test_default_early_out(unused_get):
-    assert _default.default() == (mock.sentinel.credentials, mock.sentinel.project_id)
+    assert _default.default() == (MOCK_CREDENTIALS, mock.sentinel.project_id)
 
 
 @mock.patch(
     "google.auth._default._get_explicit_environ_credentials",
-    return_value=(mock.sentinel.credentials, mock.sentinel.project_id),
+    return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id),
     autospec=True,
 )
 def test_default_explict_project_id(unused_get, monkeypatch):
     monkeypatch.setenv(environment_vars.PROJECT, "explicit-env")
-    assert _default.default() == (mock.sentinel.credentials, "explicit-env")
+    assert _default.default() == (MOCK_CREDENTIALS, "explicit-env")
 
 
 @mock.patch(
     "google.auth._default._get_explicit_environ_credentials",
-    return_value=(mock.sentinel.credentials, mock.sentinel.project_id),
+    return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id),
     autospec=True,
 )
 def test_default_explict_legacy_project_id(unused_get, monkeypatch):
     monkeypatch.setenv(environment_vars.LEGACY_PROJECT, "explicit-env")
-    assert _default.default() == (mock.sentinel.credentials, "explicit-env")
+    assert _default.default() == (MOCK_CREDENTIALS, "explicit-env")
 
 
 @mock.patch("logging.Logger.warning", autospec=True)
 @mock.patch(
     "google.auth._default._get_explicit_environ_credentials",
-    return_value=(mock.sentinel.credentials, None),
+    return_value=(MOCK_CREDENTIALS, None),
     autospec=True,
 )
 @mock.patch(
     "google.auth._default._get_gcloud_sdk_credentials",
-    return_value=(mock.sentinel.credentials, None),
+    return_value=(MOCK_CREDENTIALS, None),
     autospec=True,
 )
 @mock.patch(
     "google.auth._default._get_gae_credentials",
-    return_value=(mock.sentinel.credentials, None),
+    return_value=(MOCK_CREDENTIALS, None),
     autospec=True,
 )
 @mock.patch(
     "google.auth._default._get_gce_credentials",
-    return_value=(mock.sentinel.credentials, None),
+    return_value=(MOCK_CREDENTIALS, None),
     autospec=True,
 )
 def test_default_without_project_id(
     unused_gce, unused_gae, unused_sdk, unused_explicit, logger_warning
 ):
-    assert _default.default() == (mock.sentinel.credentials, None)
+    assert _default.default() == (MOCK_CREDENTIALS, None)
     logger_warning.assert_called_with(mock.ANY, mock.ANY, mock.ANY)
 
 
@@ -433,10 +447,14 @@
 
 @mock.patch(
     "google.auth._default._get_explicit_environ_credentials",
-    return_value=(mock.sentinel.credentials, mock.sentinel.project_id),
+    return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id),
     autospec=True,
 )
[email protected]("google.auth.credentials.with_scopes_if_required", autospec=True)
[email protected](
+    "google.auth.credentials.with_scopes_if_required",
+    return_value=MOCK_CREDENTIALS,
+    autospec=True,
+)
 def test_default_scoped(with_scopes, unused_get):
     scopes = ["one", "two"]
 
@@ -444,12 +462,12 @@
 
     assert credentials == with_scopes.return_value
     assert project_id == mock.sentinel.project_id
-    with_scopes.assert_called_once_with(mock.sentinel.credentials, scopes)
+    with_scopes.assert_called_once_with(MOCK_CREDENTIALS, scopes)
 
 
 @mock.patch(
     "google.auth._default._get_explicit_environ_credentials",
-    return_value=(mock.sentinel.credentials, mock.sentinel.project_id),
+    return_value=(MOCK_CREDENTIALS, mock.sentinel.project_id),
     autospec=True,
 )
 def test_default_no_app_engine_compute_engine_module(unused_get):
@@ -463,7 +481,4 @@
     with mock.patch.dict("sys.modules"):
         sys.modules["google.auth.compute_engine"] = None
         sys.modules["google.auth.app_engine"] = None
-        assert _default.default() == (
-            mock.sentinel.credentials,
-            mock.sentinel.project_id,
-        )
+        assert _default.default() == (MOCK_CREDENTIALS, mock.sentinel.project_id)