Skip to content

Commit 405ae40

Browse files
author
Jon Wayne Parrott
authored
Switch from oauth2client to google-auth (#2726)
* Removes all use of oauth2client from every package and tests. * Updates core to use google-auth's default credentials, project ID, and scoping logic. * Updates bigtable to use google-auth's scoping logic.
1 parent e379af3 commit 405ae40

File tree

3 files changed

+19
-46
lines changed

3 files changed

+19
-46
lines changed

packages/google-cloud-pubsub/unit_tests/test__gax.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def test_list_subscriptions_no_paging(self):
430430
push_config=push_cfg_pb)
431431
response = _GAXPageIterator([sub_pb])
432432
gax_api = _GAXSubscriberAPI(_list_subscriptions_response=response)
433-
creds = _Credentials()
433+
creds = object()
434434
client = Client(project=self.PROJECT, credentials=creds)
435435
api = self._make_one(gax_api, client)
436436

@@ -476,7 +476,7 @@ def test_list_subscriptions_with_paging(self):
476476
response = _GAXPageIterator([sub_pb], page_token=NEW_TOKEN)
477477
gax_api = _GAXSubscriberAPI(_list_subscriptions_response=response)
478478
client = _Client(self.PROJECT)
479-
creds = _Credentials()
479+
creds = object()
480480
client = Client(project=self.PROJECT, credentials=creds)
481481
api = self._make_one(gax_api, client)
482482

@@ -914,7 +914,7 @@ def make_channel(*args):
914914

915915
mock_publisher_api.SERVICE_ADDRESS = host
916916

917-
creds = _Credentials()
917+
creds = object()
918918
connection = _Connection(in_emulator=False,
919919
credentials=creds)
920920
patch = mock.patch.multiple(
@@ -986,7 +986,7 @@ def make_channel(*args):
986986

987987
mock_subscriber_api.SERVICE_ADDRESS = host
988988

989-
creds = _Credentials()
989+
creds = object()
990990
connection = _Connection(in_emulator=False,
991991
credentials=creds)
992992
patch = mock.patch.multiple(
@@ -1216,10 +1216,3 @@ class _Client(object):
12161216

12171217
def __init__(self, project):
12181218
self.project = project
1219-
1220-
1221-
class _Credentials(object):
1222-
1223-
@staticmethod
1224-
def create_scoped_required():
1225-
return False

packages/google-cloud-pubsub/unit_tests/test__http.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def test_list_subscriptions_no_paging(self):
454454
SUB_INFO = {'name': self.SUB_PATH, 'topic': self.TOPIC_PATH}
455455
RETURNED = {'subscriptions': [SUB_INFO]}
456456
connection = _Connection(RETURNED)
457-
creds = _Credentials()
457+
creds = object()
458458
client = Client(project=self.PROJECT, credentials=creds)
459459
client._connection = connection
460460
api = self._make_one(client)
@@ -497,7 +497,7 @@ def test_list_subscriptions_with_paging(self):
497497
'nextPageToken': 'TOKEN2',
498498
}
499499
connection = _Connection(RETURNED)
500-
creds = _Credentials()
500+
creds = object()
501501
client = Client(project=self.PROJECT, credentials=creds)
502502
client._connection = connection
503503
api = self._make_one(client)
@@ -902,10 +902,3 @@ class _Client(object):
902902
def __init__(self, connection, project):
903903
self._connection = connection
904904
self.project = project
905-
906-
907-
class _Credentials(object):
908-
909-
@staticmethod
910-
def create_scoped_required():
911-
return False

packages/google-cloud-pubsub/unit_tests/test_client.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _make_one(self, *args, **kw):
3333
def test_publisher_api_wo_gax(self):
3434
from google.cloud.pubsub._http import _PublisherAPI
3535

36-
creds = _Credentials()
36+
creds = object()
3737

3838
client = self._make_one(
3939
project=self.PROJECT, credentials=creds,
@@ -52,7 +52,7 @@ def test_no_gax_ctor(self):
5252
import mock
5353
from google.cloud.pubsub._http import _PublisherAPI
5454

55-
creds = _Credentials()
55+
creds = object()
5656
with mock.patch('google.cloud.pubsub.client._USE_GAX',
5757
new=True):
5858
client = self._make_one(project=self.PROJECT, credentials=creds,
@@ -78,7 +78,7 @@ def __init__(self, _wrapped, client):
7878
self._wrapped = _wrapped
7979
self._client = client
8080

81-
creds = _Credentials()
81+
creds = object()
8282
client = self._make_one(
8383
project=self.PROJECT, credentials=creds,
8484
use_gax=True)
@@ -102,7 +102,7 @@ def __init__(self, _wrapped, client):
102102
def test_subscriber_api_wo_gax(self):
103103
from google.cloud.pubsub._http import _SubscriberAPI
104104

105-
creds = _Credentials()
105+
creds = object()
106106
client = self._make_one(
107107
project=self.PROJECT, credentials=creds,
108108
use_gax=False)
@@ -132,7 +132,7 @@ def __init__(self, _wrapped, client):
132132
self._wrapped = _wrapped
133133
self._client = client
134134

135-
creds = _Credentials()
135+
creds = object()
136136
client = self._make_one(
137137
project=self.PROJECT, credentials=creds,
138138
use_gax=True)
@@ -155,7 +155,7 @@ def __init__(self, _wrapped, client):
155155

156156
def test_iam_policy_api(self):
157157
from google.cloud.pubsub._http import _IAMPolicyAPI
158-
creds = _Credentials()
158+
creds = object()
159159
client = self._make_one(project=self.PROJECT, credentials=creds)
160160
conn = client._connection = object()
161161
api = client.iam_policy_api
@@ -168,7 +168,7 @@ def test_iam_policy_api(self):
168168
def test_list_topics_no_paging(self):
169169
from google.cloud.pubsub.topic import Topic
170170

171-
creds = _Credentials()
171+
creds = object()
172172
client = self._make_one(project=self.PROJECT, credentials=creds)
173173
client._connection = object()
174174
api = _FauxPublisherAPI(items=[Topic(self.TOPIC_NAME, client)])
@@ -191,7 +191,7 @@ def test_list_topics_with_paging(self):
191191
TOKEN1 = 'TOKEN1'
192192
TOKEN2 = 'TOKEN2'
193193
SIZE = 1
194-
creds = _Credentials()
194+
creds = object()
195195
client = self._make_one(project=self.PROJECT, credentials=creds)
196196
client._connection = object()
197197
api = _FauxPublisherAPI([Topic(self.TOPIC_NAME, client)], TOKEN2)
@@ -209,7 +209,7 @@ def test_list_topics_with_paging(self):
209209
self.assertEqual(api._listed_topics, (self.PROJECT, 1, TOKEN1))
210210

211211
def test_list_topics_missing_key(self):
212-
creds = _Credentials()
212+
creds = object()
213213
client = self._make_one(project=self.PROJECT, credentials=creds)
214214
client._connection = object()
215215
api = _FauxPublisherAPI()
@@ -229,7 +229,7 @@ def test_list_subscriptions_no_paging(self):
229229
from google.cloud.pubsub.topic import Topic
230230

231231
SUB_INFO = {'name': self.SUB_PATH, 'topic': self.TOPIC_PATH}
232-
creds = _Credentials()
232+
creds = object()
233233
client = self._make_one(project=self.PROJECT, credentials=creds,
234234
use_gax=False)
235235
returned = {'subscriptions': [SUB_INFO]}
@@ -267,7 +267,7 @@ def test_list_subscriptions_with_paging(self):
267267
from google.cloud.pubsub.topic import Topic
268268

269269
SUB_INFO = {'name': self.SUB_PATH, 'topic': self.TOPIC_PATH}
270-
creds = _Credentials()
270+
creds = object()
271271
client = self._make_one(project=self.PROJECT, credentials=creds,
272272
use_gax=False)
273273

@@ -320,7 +320,7 @@ def test_list_subscriptions_with_paging(self):
320320

321321
def test_list_subscriptions_w_missing_key(self):
322322
PROJECT = 'PROJECT'
323-
creds = _Credentials()
323+
creds = object()
324324

325325
client = self._make_one(project=PROJECT, credentials=creds)
326326
client._connection = object()
@@ -338,7 +338,7 @@ def test_list_subscriptions_w_missing_key(self):
338338
def test_topic(self):
339339
PROJECT = 'PROJECT'
340340
TOPIC_NAME = 'TOPIC_NAME'
341-
creds = _Credentials()
341+
creds = object()
342342

343343
client_obj = self._make_one(project=PROJECT, credentials=creds)
344344
new_topic = client_obj.topic(TOPIC_NAME)
@@ -350,19 +350,6 @@ def test_topic(self):
350350
self.assertFalse(new_topic.timestamp_messages)
351351

352352

353-
class _Credentials(object):
354-
355-
_scopes = None
356-
357-
@staticmethod
358-
def create_scoped_required():
359-
return True
360-
361-
def create_scoped(self, scope):
362-
self._scopes = scope
363-
return self
364-
365-
366353
class _Iterator(object):
367354

368355
def __init__(self, items, token):

0 commit comments

Comments
 (0)