Fix build & address review comments

Fixes https://github.com/grpc/grpc/issues/20532
pull/22343/head
Mariano Anaya 5 years ago committed by Lidi Zheng
parent 4d492d28a7
commit dff4a30b6c
  1. 2
      src/python/grpcio/grpc/_cython/_cygrpc/aio/call.pyx.pxi
  2. 2
      src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi
  3. 18
      src/python/grpcio_tests/tests_aio/unit/secure_call_test.py

@ -125,7 +125,7 @@ cdef class _AioCall(GrpcCallWrapper):
if credentials is not None:
set_credentials_error = grpc_call_set_credentials(self.call, credentials.c())
if set_credentials_error != GRPC_CALL_OK:
raise RuntimeError("Credentials couldn't have been set: {0}".format(set_credentials_error))
raise InternalError("Credentials couldn't have been set: {0}".format(set_credentials_error))
grpc_slice_unref(method_slice)

@ -125,7 +125,7 @@ cdef class AioChannel:
cdef CallCredentials cython_call_credentials
if python_call_credentials is not None:
if not self._is_secure:
raise RuntimeError("Call credentials are only valid on secure channels")
raise UsageError("Call credentials are only valid on secure channels")
cython_call_credentials = python_call_credentials._credentials
else:

@ -1,3 +1,18 @@
# Copyright 2020 The gRPC Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests the behaviour of the Call classes under a secure channel."""
import unittest
import logging
@ -89,11 +104,12 @@ _STREAM_OUTPUT_REQUEST_ONE_RESPONSE.response_parameters.append(
class TestStreamStreamSecureCall(_SecureCallMixin, AioTestBase):
_STREAM_ITERATIONS = 2
async def test_async_generator_secure_channel(self):
async def request_generator():
for _ in range(2):
for _ in range(self._STREAM_ITERATIONS):
yield _STREAM_OUTPUT_REQUEST_ONE_RESPONSE
call_credentials = grpc.composite_call_credentials(

Loading…
Cancel
Save