Skip to content

Commit

Permalink
Make secure_authorized_channel pass kwargs to grpc.secure_channel (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott authored Dec 2, 2016
1 parent 3f44cd6 commit 56fe71a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions google/auth/transport/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __call__(self, context, callback):


def secure_authorized_channel(
credentials, request, target, ssl_credentials=None):
credentials, request, target, ssl_credentials=None, **kwargs):
"""Creates a secure authorized gRPC channel.
This creates a channel with SSL and :class:`AuthMetadataPlugin`. This
Expand Down Expand Up @@ -98,6 +98,7 @@ def secure_authorized_channel(
target (str): The host and port of the service.
ssl_credentials (grpc.ChannelCredentials): Optional SSL channel
credentials. This can be used to specify different certificates.
kwargs: Additional arguments to pass to :func:`grpc.secure_channel`.
Returns:
grpc.Channel: The created gRPC channel.
Expand All @@ -115,4 +116,4 @@ def secure_authorized_channel(
composite_credentials = grpc.composite_channel_credentials(
ssl_credentials, google_auth_credentials)

return grpc.secure_channel(target, composite_credentials)
return grpc.secure_channel(target, composite_credentials, **kwargs)
5 changes: 3 additions & 2 deletions tests/transport/test_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_secure_authorized_channel(
target = 'example.com:80'

channel = google.auth.transport.grpc.secure_authorized_channel(
credentials, request, target)
credentials, request, target, options=mock.sentinel.options)

# Check the auth plugin construction.
auth_plugin = metadata_call_credentials.call_args[0][0]
Expand All @@ -101,7 +101,8 @@ def test_secure_authorized_channel(

# Check the channel call.
secure_channel.assert_called_once_with(
target, composite_channel_credentials.return_value)
target, composite_channel_credentials.return_value,
options=mock.sentinel.options)
assert channel == secure_channel.return_value


Expand Down

0 comments on commit 56fe71a

Please sign in to comment.