aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-06-20 13:44:56 -0700
committerGravatar GitHub <noreply@github.com>2016-06-20 13:44:56 -0700
commit604bdf74b95569979c7f918c2aaa540378447d8b (patch)
treebe9da19235579176bde2fcdf2daf91a7a03baf9d /src/python/grpcio
parent53018e49766a6dc0d25dfad14d57b48eef04f6db (diff)
parent6efe7c7ecf790cb53cc59c79257184beba3cbbda (diff)
Merge pull request #6961 from nathanielmanistaatgoogle/secure-channel-construction
Fix secure channel construction
Diffstat (limited to 'src/python/grpcio')
-rw-r--r--src/python/grpcio/grpc/__init__.py2
-rw-r--r--src/python/grpcio/grpc/_channel.py7
-rw-r--r--src/python/grpcio/tests/tests.json1
-rw-r--r--src/python/grpcio/tests/unit/_api_test.py7
-rw-r--r--src/python/grpcio/tests/unit/beta/test_utilities.py2
5 files changed, 17 insertions, 2 deletions
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)