1# Copyright 2015 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Test-appropriate entry points into the gRPC Python Beta API.""" 15 16import grpc 17from grpc.beta import implementations 18 19 20def not_really_secure_channel( 21 host, port, channel_credentials, server_host_override 22): 23 """Creates an insecure Channel to a remote host. 24 25 Args: 26 host: The name of the remote host to which to connect. 27 port: The port of the remote host to which to connect. 28 channel_credentials: The implementations.ChannelCredentials with which to 29 connect. 30 server_host_override: The target name used for SSL host name checking. 31 32 Returns: 33 An implementations.Channel to the remote host through which RPCs may be 34 conducted. 35 """ 36 target = "%s:%d" % (host, port) 37 channel = grpc.secure_channel( 38 target, 39 channel_credentials, 40 ( 41 ( 42 "grpc.ssl_target_name_override", 43 server_host_override, 44 ), 45 ), 46 ) 47 return implementations.Channel(channel) 48