Skip to content

Commit

Permalink
Fixing credentials without scopes issue in logging.
Browse files Browse the repository at this point in the history
See:
https://travis-ci.org/GoogleCloudPlatform/google-cloud-python/builds/191433056#L2195

This is a band-aid for now. I caused it in googleapis#2875 and will roll-back this
roll-back at a later time.

@daspecter fixed a similar breakage in googleapis#2909.
  • Loading branch information
dhermes committed Jan 12, 2017
1 parent 4860b09 commit b0dfd7b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions logging/google/cloud/logging/_gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def make_gax_logging_api(client):
:returns: A metrics API instance with the proper credentials.
"""
channel = make_secure_channel(
client._credentials, DEFAULT_USER_AGENT,
client._connection.credentials, DEFAULT_USER_AGENT,
LoggingServiceV2Client.SERVICE_ADDRESS)
generated = LoggingServiceV2Client(channel=channel)
return _LoggingAPI(generated, client)
Expand All @@ -548,7 +548,7 @@ def make_gax_metrics_api(client):
:returns: A metrics API instance with the proper credentials.
"""
channel = make_secure_channel(
client._credentials, DEFAULT_USER_AGENT,
client._connection.credentials, DEFAULT_USER_AGENT,
MetricsServiceV2Client.SERVICE_ADDRESS)
generated = MetricsServiceV2Client(channel=channel)
return _MetricsAPI(generated, client)
Expand All @@ -564,7 +564,7 @@ def make_gax_sinks_api(client):
:returns: A metrics API instance with the proper credentials.
"""
channel = make_secure_channel(
client._credentials, DEFAULT_USER_AGENT,
client._connection.credentials, DEFAULT_USER_AGENT,
ConfigServiceV2Client.SERVICE_ADDRESS)
generated = ConfigServiceV2Client(channel=channel)
return _SinksAPI(generated, client)
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class BackgroundThreadTransport(Transport):
def __init__(self, client, name):
http = copy.deepcopy(client._http)
self.client = client.__class__(
client.project, client._credentials, http)
client.project, client._connection.credentials, http)
logger = self.client.logger(name)
self.worker = _Worker(logger)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,13 @@ def batch(self):
class _Client(object):

def __init__(self, project, http=None, credentials=None):
import mock

self.project = project
self._http = http
self._credentials = credentials
self._connection = mock.Mock(
credentials=credentials, spec=['credentials'])

def logger(self, name): # pylint: disable=unused-argument
self._logger = _Logger(name)
Expand Down
9 changes: 6 additions & 3 deletions logging/unit_tests/test__gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,8 @@ def test_it(self):
from google.cloud.logging._gax import DEFAULT_USER_AGENT

creds = object()
client = mock.Mock(_credentials=creds)
conn = mock.Mock(credentials=creds, spec=['credentials'])
client = mock.Mock(_connection=conn, spec=['_connection'])
channels = []
channel_args = []
channel_obj = object()
Expand Down Expand Up @@ -1130,7 +1131,8 @@ def test_it(self):
from google.cloud.logging._gax import DEFAULT_USER_AGENT

creds = object()
client = mock.Mock(_credentials=creds)
conn = mock.Mock(credentials=creds, spec=['credentials'])
client = mock.Mock(_connection=conn, spec=['_connection'])
channels = []
channel_args = []
channel_obj = object()
Expand Down Expand Up @@ -1175,7 +1177,8 @@ def test_it(self):
from google.cloud.logging._gax import DEFAULT_USER_AGENT

creds = object()
client = mock.Mock(_credentials=creds)
conn = mock.Mock(credentials=creds, spec=['credentials'])
client = mock.Mock(_connection=conn, spec=['_connection'])
channels = []
channel_args = []
channel_obj = object()
Expand Down

0 comments on commit b0dfd7b

Please sign in to comment.