aboutsummaryrefslogtreecommitdiff
path: root/tests/test__default.py
diff options
context:
space:
mode:
authorJon Wayne Parrott <jonwayne@google.com>2016-11-07 16:45:17 -0800
committerGitHub <noreply@github.com>2016-11-07 16:45:17 -0800
commit8a7e50666f439a89564f9a48f21e93b31fe549ba (patch)
treedfa65ee555a5f8ae875627eb2f417a5fb8a0da72 /tests/test__default.py
parentce37cbacc1d23b056b543309c784ddcdfd3df7e0 (diff)
downloadgoogle-auth-library-python-8a7e50666f439a89564f9a48f21e93b31fe549ba.tar.gz
Add scope argument to default (#75)
Diffstat (limited to 'tests/test__default.py')
-rw-r--r--tests/test__default.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test__default.py b/tests/test__default.py
index c33db13..bfb0c39 100644
--- a/tests/test__default.py
+++ b/tests/test__default.py
@@ -290,3 +290,19 @@ def test_default_explict_legacy_project_id(get_mock, monkeypatch):
def test_default_fail(unused_gce, unused_gae, unused_sdk, unused_explicit):
with pytest.raises(exceptions.DefaultCredentialsError):
assert _default.default()
+
+
+@mock.patch(
+ 'google.auth._default._get_explicit_environ_credentials',
+ return_value=(mock.sentinel.credentials, mock.sentinel.project_id))
+@mock.patch(
+ 'google.auth.credentials.with_scopes_if_required')
+def test_default_scoped(with_scopes_mock, get_mock):
+ scopes = ['one', 'two']
+
+ credentials, project_id = _default.default(scopes=scopes)
+
+ assert credentials == with_scopes_mock.return_value
+ assert project_id == mock.sentinel.project_id
+ with_scopes_mock.assert_called_once_with(
+ mock.sentinel.credentials, scopes)