aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/interop/client.cc1
-rw-r--r--test/cpp/interop/client_helper.cc9
-rw-r--r--test/cpp/interop/interop_server.cc1
-rw-r--r--test/cpp/interop/server_helper.cc6
-rw-r--r--test/cpp/interop/stress_test.cc1
-rw-r--r--test/cpp/util/create_test_channel.cc14
-rw-r--r--test/cpp/util/create_test_channel.h4
7 files changed, 33 insertions, 3 deletions
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index c58910abc3..3265554444 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -49,6 +49,7 @@
#include "test/cpp/util/test_config.h"
DEFINE_bool(use_tls, false, "Whether to use tls.");
+DEFINE_string(custom_credentials_type, "", "User provided credentials type.");
DEFINE_bool(use_test_ca, false, "False to use SSL roots for google");
DEFINE_int32(server_port, 0, "Server port.");
DEFINE_string(server_host, "127.0.0.1", "Server host to connect to");
diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc
index 6380c10800..91564e5dce 100644
--- a/test/cpp/interop/client_helper.cc
+++ b/test/cpp/interop/client_helper.cc
@@ -53,6 +53,7 @@
#include "test/cpp/util/test_credentials_provider.h"
DECLARE_bool(use_tls);
+DECLARE_string(custom_credentials_type);
DECLARE_bool(use_test_ca);
DECLARE_int32(server_port);
DECLARE_string(server_host);
@@ -115,8 +116,12 @@ std::shared_ptr<Channel> CreateChannelForTestCase(
creds = AccessTokenCredentials(raw_token);
GPR_ASSERT(creds);
}
- return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_use_tls,
- !FLAGS_use_test_ca, creds);
+ if (FLAGS_custom_credentials_type.empty()) {
+ return CreateTestChannel(host_port, FLAGS_server_host_override,
+ FLAGS_use_tls, !FLAGS_use_test_ca, creds);
+ } else {
+ return CreateTestChannel(host_port, FLAGS_custom_credentials_type, creds);
+ }
}
} // namespace testing
diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc
index 8b50ae8c05..bc6dc07454 100644
--- a/test/cpp/interop/interop_server.cc
+++ b/test/cpp/interop/interop_server.cc
@@ -56,6 +56,7 @@
#include "test/cpp/util/test_config.h"
DEFINE_bool(use_tls, false, "Whether to use tls.");
+DEFINE_string(custom_credentials_type, "", "User provided credentials type.");
DEFINE_int32(port, 0, "Server port.");
DEFINE_int32(max_send_message_size, -1, "The maximum send message size.");
diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc
index af3171bf13..8c359628f7 100644
--- a/test/cpp/interop/server_helper.cc
+++ b/test/cpp/interop/server_helper.cc
@@ -42,12 +42,16 @@
#include "test/cpp/util/test_credentials_provider.h"
DECLARE_bool(use_tls);
+DECLARE_string(custom_credentials_type);
namespace grpc {
namespace testing {
std::shared_ptr<ServerCredentials> CreateInteropServerCredentials() {
- if (FLAGS_use_tls) {
+ if (FLAGS_custom_credentials_type.empty()) {
+ return GetCredentialsProvider()->GetServerCredentials(
+ FLAGS_custom_credentials_type);
+ } else if (FLAGS_use_tls) {
return GetCredentialsProvider()->GetServerCredentials(kTlsCredentialsType);
} else {
return GetCredentialsProvider()->GetServerCredentials(
diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc
index fc35db5233..af707d3190 100644
--- a/test/cpp/interop/stress_test.cc
+++ b/test/cpp/interop/stress_test.cc
@@ -147,6 +147,7 @@ DEFINE_bool(do_not_abort_on_transient_failures, true,
// Options from client.cc (for compatibility with interop test).
// TODO(sreek): Consolidate overlapping options
DEFINE_bool(use_tls, false, "Whether to use tls.");
+DEFINE_string(custom_credentials_type, "", "User provided credentials type.");
DEFINE_bool(use_test_ca, false, "False to use SSL roots for google");
DEFINE_int32(server_port, 0, "Server port.");
DEFINE_string(server_host, "127.0.0.1", "Server host to connect to");
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