From a7ef49bf6a4392afaf0d4db9922ae703092b6e55 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 23 Nov 2016 10:55:03 -0800 Subject: Support custom credential type in interop --- test/cpp/util/create_test_channel.cc | 14 ++++++++++++++ test/cpp/util/create_test_channel.h | 4 ++++ 2 files changed, 18 insertions(+) (limited to 'test/cpp/util') diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index 4512193fdd..ad62e03490 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -135,4 +135,18 @@ std::shared_ptr CreateTestChannel(const grpc::string& server, return CreateTestChannel(server, "foo.test.google.fr", enable_ssl, false); } +std::shared_ptr CreateTestChannel( + const grpc::string& server, const grpc::string& credential_type, + const std::shared_ptr& creds) { + ChannelArguments channel_args; + std::shared_ptr channel_creds = + testing::GetCredentialsProvider()->GetChannelCredentials(credential_type, + &channel_args); + GPR_ASSERT(channel_creds != nullptr); + if (creds.get()) { + channel_creds = CompositeChannelCredentials(channel_creds, creds); + } + return CreateCustomChannel(server, channel_creds, channel_args); +} + } // namespace grpc diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index 4ff666dc1b..ce71a97edb 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -59,6 +59,10 @@ std::shared_ptr CreateTestChannel( const std::shared_ptr& creds, const ChannelArguments& args); +std::shared_ptr CreateTestChannel( + const grpc::string& server, const grpc::string& credential_type, + const std::shared_ptr& creds); + } // namespace grpc #endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H -- cgit v1.2.3