address review comments

pull/22638/head
Taras Galkovskyi 5 years ago
parent 97e7c5e9b6
commit 02da3330c2
  1. 32
      examples/BUILD
  2. 49
      examples/python/data_transmission/BUILD
  3. 2
      examples/python/data_transmission/alts_client.py
  4. 2
      examples/python/data_transmission/alts_server.py
  5. 4
      src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
  6. 1
      src/python/grpcio_tests/commands.py
  7. 4
      src/python/grpcio_tests/tests/interop/client.py
  8. 11
      src/python/grpcio_tests/tests/unit/_alts_credentials_test.py

@ -245,35 +245,3 @@ proto_library(
name = "route_guide_proto",
srcs = ["protos/route_guide.proto"],
)
py_binary(
name = "data_transmission_server",
python_version = "PY3",
srcs_version = "PY2AND3",
main = "alts_server.py",
srcs = [
"python/data_transmission/alts_server.py",
"python/data_transmission/demo_pb2.py",
"python/data_transmission/demo_pb2_grpc.py",
"python/data_transmission/server.py",
],
deps = [
"//src/python/grpcio/grpc:grpcio",
],
)
py_binary(
name = "data_transmission_client",
python_version = "PY3",
srcs_version = "PY2AND3",
main = "alts_client.py",
srcs = [
"python/data_transmission/alts_client.py",
"python/data_transmission/client.py",
"python/data_transmission/demo_pb2.py",
"python/data_transmission/demo_pb2_grpc.py",
],
deps = [
"//src/python/grpcio/grpc:grpcio",
],
)

@ -0,0 +1,49 @@
# Copyright 2017 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.
licenses(["notice"]) # 3-clause BSD
load("@grpc_python_dependencies//:requirements.bzl", "requirement")
py_binary(
name = "alts_server",
python_version = "PY3",
srcs_version = "PY2AND3",
main = "alts_server.py",
srcs = [
"alts_server.py",
"demo_pb2.py",
"demo_pb2_grpc.py",
"server.py",
],
deps = [
"//src/python/grpcio/grpc:grpcio",
],
)
py_binary(
name = "alts_client",
python_version = "PY3",
srcs_version = "PY2AND3",
main = "alts_client.py",
srcs = [
"alts_client.py",
"client.py",
"demo_pb2.py",
"demo_pb2_grpc.py",
],
deps = [
"//src/python/grpcio/grpc:grpcio",
],
)

@ -13,12 +13,10 @@
# limitations under the License.
"""The example of using ALTS credentials to setup gRPC client."""
import time
import grpc
import client
import demo_pb2_grpc
import demo_pb2
SERVER_ADDRESS = "localhost:23333"

@ -13,12 +13,10 @@
# limitations under the License.
"""The example of using ALTS credentials to setup gRPC server in python."""
from threading import Thread
from concurrent import futures
import grpc
import demo_pb2_grpc
import demo_pb2
import server
SERVER_ADDRESS = 'localhost:23333'

@ -355,7 +355,7 @@ def server_credentials_local(grpc_local_connect_type local_connect_type):
cdef class ALTSChannelCredentials(ChannelCredentials):
def __cinit__(self, service_accounts):
def __cinit__(self, list service_accounts):
self.c_options = grpc_alts_credentials_client_options_create()
for account in service_accounts:
grpc_alts_credentials_client_options_add_target_service_account(self.c_options, account)
@ -368,7 +368,7 @@ cdef class ALTSChannelCredentials(ChannelCredentials):
return grpc_alts_credentials_create(self.c_options)
def channel_credentials_alts(service_accounts):
def channel_credentials_alts(list service_accounts):
return ALTSChannelCredentials(service_accounts)

@ -220,7 +220,6 @@ class TestGevent(setuptools.Command):
'unit._cython._channel_test.ChannelTest.test_negative_deadline_connectivity',
# TODO(https://github.com/grpc/grpc/issues/15411) enable this test
'unit._local_credentials_test.LocalCredentialsTest',
'unit._alts_credentials_test.ALTSCredentialsTest',
'testing._time_test.StrictRealTimeTest',
)
BANNED_WINDOWS_TESTS = (

@ -106,8 +106,8 @@ def get_secure_channel_parameters(args):
'grpc.ssl_target_name_override',
args.server_host_override,
),)
else args.use_alts:
channel_credentials = grpc.alts_channel_credentials(['svc_account1@gmail.com'])
elif args.use_alts:
channel_credentials = grpc.alts_channel_credentials()
return channel_credentials, channel_opts

@ -19,6 +19,9 @@ from concurrent.futures import ThreadPoolExecutor
import grpc
REQUEST = b'abc'
class _GenericHandler(grpc.GenericRpcHandler):
def service(self, handler_call_details):
@ -33,11 +36,9 @@ class ALTSCredentialsTest(unittest.TestCase):
server.add_generic_rpc_handlers((_GenericHandler(),))
return server
@unittest.skipIf(os.name == 'nt',
'TODO(https://github.com/grpc/grpc/issues/20078)')
def test_alts(self):
server_addr = 'localhost:{}'
channel_creds = grpc.alts_channel_credentials(['svcacct@server.com'])
channel_creds = grpc.alts_channel_credentials([])
server_creds = grpc.alts_server_credentials()
server = self._create_server()
@ -46,8 +47,8 @@ class ALTSCredentialsTest(unittest.TestCase):
with grpc.secure_channel(server_addr.format(port),
channel_creds) as channel:
self.assertEqual(
b'abc',
channel.unary_unary('/test/method')(b'abc',
REQUEST,
channel.unary_unary('/test/method')(REQUEST,
wait_for_ready=True))
server.stop(None)

Loading…
Cancel
Save