Add scope argument to default (#75)
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_fail(unused_gce, unused_gae, unused_sdk, unused_explicit): with pytest.raises(exceptions.DefaultCredentialsError): assert _default.default() + + [email protected]( + 'google.auth._default._get_explicit_environ_credentials', + return_value=(mock.sentinel.credentials, mock.sentinel.project_id)) [email protected]( + '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)