From 6efe7c7ecf790cb53cc59c79257184beba3cbbda Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Sat, 18 Jun 2016 02:03:44 +0000 Subject: Fix secure channel construction --- src/python/grpcio/grpc/__init__.py | 2 +- src/python/grpcio/grpc/_channel.py | 7 +++++++ src/python/grpcio/tests/tests.json | 1 + src/python/grpcio/tests/unit/_api_test.py | 7 +++++++ src/python/grpcio/tests/unit/beta/test_utilities.py | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/python/grpcio') diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 28adca3772..9e784c8157 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1171,7 +1171,7 @@ def secure_channel(target, credentials, options=None): A Channel to the target through which RPCs may be conducted. """ from grpc import _channel - return _channel.Channel(target, options, credentials) + return _channel.Channel(target, options, credentials._credentials) def server(generic_rpc_handlers, thread_pool, options=None): diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index d9315d2e6c..7cdd542de2 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -814,6 +814,13 @@ def _options(options): class Channel(grpc.Channel): def __init__(self, target, options, credentials): + """Constructor. + + Args: + target: The target to which to connect. + options: Configuration options for the channel. + credentials: A cygrpc.ChannelCredentials or None. + """ self._channel = cygrpc.Channel(target, _options(options), credentials) self._call_state = _ChannelCallState(self._channel) self._connectivity_state = _ChannelConnectivityState(self._channel) diff --git a/src/python/grpcio/tests/tests.json b/src/python/grpcio/tests/tests.json index 20d11b20b5..66e29ef253 100644 --- a/src/python/grpcio/tests/tests.json +++ b/src/python/grpcio/tests/tests.json @@ -1,6 +1,7 @@ [ "_api_test.AllTest", "_api_test.ChannelConnectivityTest", + "_api_test.ChannelTest", "_auth_test.AccessTokenCallCredentialsTest", "_auth_test.GoogleCallCredentialsTest", "_base_interface_test.AsyncEasyTest", diff --git a/src/python/grpcio/tests/unit/_api_test.py b/src/python/grpcio/tests/unit/_api_test.py index 1501ec2a04..2fe89499f5 100644 --- a/src/python/grpcio/tests/unit/_api_test.py +++ b/src/python/grpcio/tests/unit/_api_test.py @@ -100,5 +100,12 @@ class ChannelConnectivityTest(unittest.TestCase): tuple(grpc.ChannelConnectivity)) +class ChannelTest(unittest.TestCase): + + def test_secure_channel(self): + channel_credentials = grpc.ssl_channel_credentials() + channel = grpc.secure_channel('google.com:443', channel_credentials) + + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/python/grpcio/tests/unit/beta/test_utilities.py b/src/python/grpcio/tests/unit/beta/test_utilities.py index e374b203ce..8ccad04e05 100644 --- a/src/python/grpcio/tests/unit/beta/test_utilities.py +++ b/src/python/grpcio/tests/unit/beta/test_utilities.py @@ -50,6 +50,6 @@ def not_really_secure_channel( """ target = '%s:%d' % (host, port) channel = grpc.secure_channel( - target, channel_credentials._credentials, + target, channel_credentials, ((b'grpc.ssl_target_name_override', server_host_override,),)) return implementations.Channel(channel) -- cgit v1.2.3