Skip to content
Snippets Groups Projects
Commit 3f1af6ee authored by yangg's avatar yangg Committed by Jan Tattermusch
Browse files

Make override hostname an argument for testing against prod gfe.

	Change on 2014/12/19 by yangg <yangg@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82544544
parent 59dfc90f
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,16 @@ ...@@ -40,7 +40,16 @@
namespace grpc { namespace grpc {
std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server, // When ssl is enabled, if server is empty, override_hostname is used to
// create channel. Otherwise, connect to server and override hostname if
// override_hostname is provided.
// When ssl is not enabled, override_hostname is ignored.
// Use examples:
// CreateTestChannel("1.1.1.1:12345", "override.hostname.com", true);
// CreateTestChannel("test.google.com:443", "", true);
// CreateTestChannel("", "test.google.com:443", true); // same as above
std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl) { bool enable_ssl) {
ChannelArguments channel_args; ChannelArguments channel_args;
if (enable_ssl) { if (enable_ssl) {
...@@ -52,11 +61,21 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server, ...@@ -52,11 +61,21 @@ std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server,
std::unique_ptr<Credentials> creds = std::unique_ptr<Credentials> creds =
CredentialsFactory::SslCredentials(ssl_opts); CredentialsFactory::SslCredentials(ssl_opts);
channel_args.SetSslTargetNameOverride("foo.test.google.com"); if (!server.empty() && !override_hostname.empty()) {
return CreateChannel(server, creds, channel_args); channel_args.SetSslTargetNameOverride(override_hostname);
}
const grpc::string& connect_to =
server.empty() ? override_hostname : server;
return CreateChannel(connect_to, creds, channel_args);
} else { } else {
return CreateChannel(server, channel_args); return CreateChannel(server, channel_args);
} }
} }
// Shortcut for end2end and interop tests.
std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server,
bool enable_ssl) {
return CreateTestChannel(server, "foo.test.google.com", enable_ssl);
}
} // namespace grpc } // namespace grpc
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
namespace grpc { namespace grpc {
class ChannelInterface; class ChannelInterface;
std::shared_ptr<ChannelInterface> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl);
std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server, std::shared_ptr<ChannelInterface> CreateTestChannel(const grpc::string& server,
bool enable_ssl); bool enable_ssl);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment