Initial working implementation

pull/23203/head
Richard Belleville 5 years ago
parent 8cd6ee6297
commit b821ff99a8
  1. 7
      src/python/grpcio/grpc/__init__.py
  2. 13
      src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
  3. 2
      src/python/grpcio_tests/tests/interop/BUILD.bazel
  4. 17
      src/python/grpcio_tests/tests/interop/client.py
  5. 1
      src/python/grpcio_tests/tests_aio/interop/BUILD.bazel

@ -1868,6 +1868,13 @@ def alts_server_credentials():
return ServerCredentials(_cygrpc.server_credentials_alts())
def google_default_channel_credentials():
"""
TODO: Document.
"""
return ChannelCredentials(_cygrpc.channel_credentials_google_default())
def channel_ready_future(channel):
"""Creates a Future that tracks when a Channel is ready.

@ -380,3 +380,16 @@ def server_credentials_alts():
# Options can be destroyed as deep copy was performed.
grpc_alts_credentials_options_destroy(c_options)
return credentials
cdef class GoogleDefaultChannelCredentials(ChannelCredentials):
cdef grpc_channel_credentials* _c_creds
def __cinit__(self):
self._c_creds = NULL
cdef grpc_channel_credentials *c(self) except *:
self._c_creds = grpc_google_default_credentials_create()
return self._c_creds
def channel_credentials_google_default():
return GoogleDefaultChannelCredentials()

@ -12,7 +12,7 @@ py_library(
],
)
py_library(
py_binary(
name = "client",
srcs = ["client.py"],
imports = ["../../"],

@ -51,6 +51,10 @@ def parse_interop_client_args():
default=False,
type=resources.parse_bool,
help='replace platform root CAs with ca.pem')
parser.add_argument('--custom_credentials_type',
choices=["google_default_credentials"],
default=None,
help='use google default credentials')
parser.add_argument('--server_host_override',
type=str,
help='the server host to which to claim to connect')
@ -90,7 +94,16 @@ def get_secure_channel_parameters(args):
call_credentials = _create_call_credentials(args)
channel_opts = None
if args.use_tls:
if args.custom_credentials_type is not None:
if args.custom_credentials_type == "google_default_credentials":
channel_credentials = grpc.google_default_channel_credentials()
if call_credentials is not None:
channel_credentials = grpc.composite_channel_credentials(
channel_credentials, call_credentials)
else:
raise ValueError("Unknown credentials type '{}'".format(
args.custom_credentials_type))
elif args.use_tls:
if args.use_test_ca:
root_certificates = resources.test_root_certificates()
else:
@ -115,7 +128,7 @@ def get_secure_channel_parameters(args):
def _create_channel(args):
target = '{}:{}'.format(args.server_host, args.server_port)
if args.use_tls or args.use_alts:
if args.use_tls or args.use_alts or args.custom_credentials_type is not None:
channel_credentials, options = get_secure_channel_parameters(args)
return grpc.secure_channel(target, channel_credentials, options)
else:

@ -62,6 +62,7 @@ py_binary(
],
)
# TODO: Pull out library to fix aio interop client.
py_binary(
name = "client",
srcs = ["client.py"],

Loading…
Cancel
Save