run yapf; delete alts unit tests

pull/22638/head
Taras Galkovskyi 5 years ago
parent 486e27e2de
commit 469631f549
  1. 4
      examples/python/data_transmission/alts_client.py
  2. 3
      examples/python/data_transmission/alts_server.py
  3. 3
      src/python/grpcio/grpc/__init__.py
  4. 1
      src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
  5. 2
      src/python/grpcio_tests/tests/interop/server.py
  6. 1
      src/python/grpcio_tests/tests/tests.json
  7. 1
      src/python/grpcio_tests/tests/unit/BUILD.bazel
  8. 57
      src/python/grpcio_tests/tests/unit/_alts_credentials_test.py

@ -22,9 +22,11 @@ import demo_pb2_grpc
SERVER_ADDRESS = "localhost:23333"
def main():
with grpc.secure_channel(
SERVER_ADDRESS, credentials=grpc.alts_channel_credentials()) as channel:
SERVER_ADDRESS,
credentials=grpc.alts_channel_credentials()) as channel:
stub = demo_pb2_grpc.GRPCDemoStub(channel)
client.simple_method(stub)
client.client_streaming_method(stub)

@ -27,7 +27,8 @@ SERVER_ADDRESS = 'localhost:23333'
def main():
svr = grpc.server(futures.ThreadPoolExecutor())
demo_pb2_grpc.add_GRPCDemoServicer_to_server(server.DemoServer(), svr)
svr.add_secure_port(SERVER_ADDRESS, server_credentials=grpc.alts_server_credentials())
svr.add_secure_port(SERVER_ADDRESS,
server_credentials=grpc.alts_server_credentials())
print("------------------start Python GRPC server with ALTS encryption")
svr.start()
svr.wait_for_termination()

@ -1850,7 +1850,8 @@ def alts_channel_credentials(service_accounts=[]):
Returns:
A ChannelCredentials for use with an ALTS-enabled Channel
"""
return ChannelCredentials(_cygrpc.channel_credentials_alts(service_accounts))
return ChannelCredentials(
_cygrpc.channel_credentials_alts(service_accounts))
def alts_server_credentials():

@ -357,6 +357,7 @@ cdef class ALTSChannelCredentials(ChannelCredentials):
def __cinit__(self, list service_accounts):
self.c_options = grpc_alts_credentials_client_options_create()
cdef str account
for account in service_accounts:
grpc_alts_credentials_client_options_add_target_service_account(self.c_options, account)

@ -54,8 +54,6 @@ def get_server_credentials(use_tls):
return grpc.alts_server_credentials()
def serve():
args = parse_interop_server_arguments()

@ -24,7 +24,6 @@
"testing._time_test.StrictFakeTimeTest",
"testing._time_test.StrictRealTimeTest",
"unit._abort_test.AbortTest",
"unit._alts_credentials_test.ALTSCredentialsTest",
"unit._api_test.AllTest",
"unit._api_test.ChannelConnectivityTest",
"unit._api_test.ChannelTest",

@ -4,7 +4,6 @@ package(default_visibility = ["//visibility:public"])
GRPCIO_TESTS_UNIT = [
"_abort_test.py",
"_alts_credentials_test.py",
"_api_test.py",
"_auth_context_test.py",
"_auth_test.py",

@ -1,57 +0,0 @@
# 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.
"""Test of RPCs made using ALTS credentials."""
import unittest
import os
from concurrent.futures import ThreadPoolExecutor
import grpc
REQUEST = b'abc'
class _GenericHandler(grpc.GenericRpcHandler):
def service(self, handler_call_details):
return grpc.unary_unary_rpc_method_handler(
lambda request, unused_context: request)
class ALTSCredentialsTest(unittest.TestCase):
def _create_server(self):
server = grpc.server(ThreadPoolExecutor())
server.add_generic_rpc_handlers((_GenericHandler(),))
return server
def test_alts(self):
server_addr = 'localhost:{}'
channel_creds = grpc.alts_channel_credentials([])
server_creds = grpc.alts_server_credentials()
server = self._create_server()
port = server.add_secure_port(server_addr.format(0), server_creds)
server.start()
with grpc.secure_channel(server_addr.format(port),
channel_creds) as channel:
self.assertEqual(
REQUEST,
channel.unary_unary('/test/method')(REQUEST,
wait_for_ready=True))
server.stop(None)
if __name__ == '__main__':
unittest.main()
Loading…
Cancel
Save