aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/util
diff options
context:
space:
mode:
authorGravatar Yihua Zhang <yihuaz@google.com>2018-04-20 08:50:45 -0700
committerGravatar Yihua Zhang <yihuaz@google.com>2018-04-20 08:50:45 -0700
commit0dcbb83420e25b657249878606bbef9c53f09ea3 (patch)
treef4864ac186a6c2d2c62b1ad19d546724fcd8ec9f /test/cpp/util
parent2a6f47354391af2514310ff06d44a26354cc07fb (diff)
add alts to interop tests
Diffstat (limited to 'test/cpp/util')
-rw-r--r--test/cpp/util/create_test_channel.cc26
-rw-r--r--test/cpp/util/create_test_channel.h16
-rw-r--r--test/cpp/util/test_credentials_provider.cc6
-rw-r--r--test/cpp/util/test_credentials_provider.h2
4 files changed, 31 insertions, 19 deletions
diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc
index 1047d44627..0bcd4dbc84 100644
--- a/test/cpp/util/create_test_channel.cc
+++ b/test/cpp/util/create_test_channel.cc
@@ -107,37 +107,37 @@ std::shared_ptr<Channel> CreateTestChannel(
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
- bool enable_ssl, bool use_prod_roots,
+ testing::transport_security security_type, bool use_prod_roots,
const std::shared_ptr<CallCredentials>& creds,
const ChannelArguments& args) {
- grpc::string type;
- if (enable_ssl) {
- type = testing::kTlsCredentialsType;
- }
-
+ grpc::string type =
+ security_type == testing::ALTS
+ ? testing::kAltsCredentialsType
+ : (security_type == testing::TLS ? testing::kTlsCredentialsType
+ : testing::kInsecureCredentialsType);
return CreateTestChannel(server, type, override_hostname, use_prod_roots,
creds, args);
}
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
- bool enable_ssl, bool use_prod_roots,
+ testing::transport_security security_type, bool use_prod_roots,
const std::shared_ptr<CallCredentials>& creds) {
- return CreateTestChannel(server, override_hostname, enable_ssl,
+ return CreateTestChannel(server, override_hostname, security_type,
use_prod_roots, creds, ChannelArguments());
}
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
- bool enable_ssl, bool use_prod_roots) {
- return CreateTestChannel(server, override_hostname, enable_ssl,
+ testing::transport_security security_type, bool use_prod_roots) {
+ return CreateTestChannel(server, override_hostname, security_type,
use_prod_roots, std::shared_ptr<CallCredentials>());
}
// Shortcut for end2end and interop tests.
-std::shared_ptr<Channel> CreateTestChannel(const grpc::string& server,
- bool enable_ssl) {
- return CreateTestChannel(server, "foo.test.google.fr", enable_ssl, false);
+std::shared_ptr<Channel> CreateTestChannel(
+ const grpc::string& server, testing::transport_security security_type) {
+ return CreateTestChannel(server, "foo.test.google.fr", security_type, false);
}
std::shared_ptr<Channel> CreateTestChannel(
diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h
index ddaa99f43e..c615fb7653 100644
--- a/test/cpp/util/create_test_channel.h
+++ b/test/cpp/util/create_test_channel.h
@@ -26,21 +26,27 @@
namespace grpc {
class Channel;
-std::shared_ptr<Channel> CreateTestChannel(const grpc::string& server,
- bool enable_ssl);
+namespace testing {
+
+typedef enum { INSECURE = 0, TLS, ALTS } transport_security;
+
+} // namespace testing
+
+std::shared_ptr<Channel> CreateTestChannel(
+ const grpc::string& server, testing::transport_security security_type);
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
- bool enable_ssl, bool use_prod_roots);
+ testing::transport_security security_type, bool use_prod_roots);
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
- bool enable_ssl, bool use_prod_roots,
+ testing::transport_security security_type, bool use_prod_roots,
const std::shared_ptr<CallCredentials>& creds);
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
- bool enable_ssl, bool use_prod_roots,
+ testing::transport_security security_type, bool use_prod_roots,
const std::shared_ptr<CallCredentials>& creds,
const ChannelArguments& args);
diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc
index 76561007c4..c8b0ac73f4 100644
--- a/test/cpp/util/test_credentials_provider.cc
+++ b/test/cpp/util/test_credentials_provider.cc
@@ -56,6 +56,9 @@ class DefaultCredentialsProvider : public CredentialsProvider {
const grpc::string& type, ChannelArguments* args) override {
if (type == grpc::testing::kInsecureCredentialsType) {
return InsecureChannelCredentials();
+ } else if (type == grpc::testing::kAltsCredentialsType) {
+ grpc::experimental::AltsCredentialsOptions alts_opts;
+ return grpc::experimental::AltsCredentials(alts_opts);
} else if (type == grpc::testing::kTlsCredentialsType) {
SslCredentialsOptions ssl_opts = {test_root_cert, "", ""};
args->SetSslTargetNameOverride("foo.test.google.fr");
@@ -77,6 +80,9 @@ class DefaultCredentialsProvider : public CredentialsProvider {
const grpc::string& type) override {
if (type == grpc::testing::kInsecureCredentialsType) {
return InsecureServerCredentials();
+ } else if (type == grpc::testing::kAltsCredentialsType) {
+ grpc::experimental::AltsServerCredentialsOptions alts_opts;
+ return grpc::experimental::AltsServerCredentials(alts_opts);
} else if (type == grpc::testing::kTlsCredentialsType) {
SslServerCredentialsOptions::PemKeyCertPair pkcp = {test_server1_key,
test_server1_cert};
diff --git a/test/cpp/util/test_credentials_provider.h b/test/cpp/util/test_credentials_provider.h
index f489a2c563..b1d69e893d 100644
--- a/test/cpp/util/test_credentials_provider.h
+++ b/test/cpp/util/test_credentials_provider.h
@@ -29,10 +29,10 @@ namespace grpc {
namespace testing {
const char kInsecureCredentialsType[] = "INSECURE_CREDENTIALS";
-
// For real credentials, like tls/ssl, this name should match the AuthContext
// property "transport_security_type".
const char kTlsCredentialsType[] = "ssl";
+const char kAltsCredentialsType[] = "alts";
// Provide test credentials of a particular type.
class CredentialTypeProvider {