From 35393b87d61e4624e5e852db2eee940f38aa5798 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Fri, 2 Dec 2016 14:10:35 -0800 Subject: [PATCH] Make secure_authorized_channel pass kwargs to grpc.secure_channel --- google/auth/transport/grpc.py | 5 +++-- tests/transport/test_grpc.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/google/auth/transport/grpc.py b/google/auth/transport/grpc.py index 1e02b3830..4062972aa 100644 --- a/google/auth/transport/grpc.py +++ b/google/auth/transport/grpc.py @@ -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 @@ -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. @@ -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) diff --git a/tests/transport/test_grpc.py b/tests/transport/test_grpc.py index 84e4b5659..15a301fa3 100644 --- a/tests/transport/test_grpc.py +++ b/tests/transport/test_grpc.py @@ -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] @@ -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