aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2016-11-23 10:55:03 -0800
committerGravatar yang-g <yangg@google.com>2016-11-23 10:55:03 -0800
commita7ef49bf6a4392afaf0d4db9922ae703092b6e55 (patch)
tree2f2528d04ab660b31a3a2859a8a8b21c141be894 /test/cpp/util
parent71b275bc10558107cd41448a8c8ce96d1d1dd79c (diff)
Support custom credential type in interop
Diffstat (limited to 'test/cpp/util')
-rw-r--r--test/cpp/util/create_test_channel.cc14
-rw-r--r--test/cpp/util/create_test_channel.h4
2 files changed, 18 insertions, 0 deletions
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<Channel> CreateTestChannel(const grpc::string& server,
return CreateTestChannel(server, "foo.test.google.fr", enable_ssl, false);
}
+std::shared_ptr<Channel> CreateTestChannel(
+ const grpc::string& server, const grpc::string& credential_type,
+ const std::shared_ptr<CallCredentials>& creds) {
+ ChannelArguments channel_args;
+ std::shared_ptr<ChannelCredentials> 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<Channel> CreateTestChannel(
const std::shared_ptr<CallCredentials>& creds,
const ChannelArguments& args);
+std::shared_ptr<Channel> CreateTestChannel(
+ const grpc::string& server, const grpc::string& credential_type,
+ const std::shared_ptr<CallCredentials>& creds);
+
} // namespace grpc
#endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H