Fix secure channel construction

pull/6961/head
Nathaniel Manista 9 years ago
parent fa1433a4b6
commit 6efe7c7ecf
  1. 2
      src/python/grpcio/grpc/__init__.py
  2. 7
      src/python/grpcio/grpc/_channel.py
  3. 1
      src/python/grpcio/tests/tests.json
  4. 7
      src/python/grpcio/tests/unit/_api_test.py
  5. 2
      src/python/grpcio/tests/unit/beta/test_utilities.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):

@ -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)

@ -1,6 +1,7 @@
[
"_api_test.AllTest",
"_api_test.ChannelConnectivityTest",
"_api_test.ChannelTest",
"_auth_test.AccessTokenCallCredentialsTest",
"_auth_test.GoogleCallCredentialsTest",
"_base_interface_test.AsyncEasyTest",

@ -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)

@ -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)

Loading…
Cancel
Save