|
|
|
@ -71,10 +71,74 @@ std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
const grpc::string& override_hostname, bool use_prod_roots, |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds, |
|
|
|
|
const ChannelArguments& args) { |
|
|
|
|
return CreateTestChannel(server, cred_type, override_hostname, |
|
|
|
|
use_prod_roots, creds, args, |
|
|
|
|
/*interceptor_creators=*/{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
const grpc::string& server, const grpc::string& override_hostname, |
|
|
|
|
testing::transport_security security_type, bool use_prod_roots, |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds, |
|
|
|
|
const ChannelArguments& args) { |
|
|
|
|
return CreateTestChannel(server, override_hostname, security_type, |
|
|
|
|
use_prod_roots, creds, args, |
|
|
|
|
/*interceptor_creators=*/{}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
const grpc::string& server, const grpc::string& override_hostname, |
|
|
|
|
testing::transport_security security_type, bool use_prod_roots, |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds) { |
|
|
|
|
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, |
|
|
|
|
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, testing::transport_security security_type) { |
|
|
|
|
return CreateTestChannel(server, "foo.test.google.fr", security_type, 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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
const grpc::string& server, const grpc::string& cred_type, |
|
|
|
|
const grpc::string& override_hostname, bool use_prod_roots, |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds, |
|
|
|
|
const ChannelArguments& args, |
|
|
|
|
std::vector< |
|
|
|
|
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> |
|
|
|
|
interceptor_creators) { |
|
|
|
|
ChannelArguments channel_args(args); |
|
|
|
|
std::shared_ptr<ChannelCredentials> channel_creds; |
|
|
|
|
if (cred_type.empty()) { |
|
|
|
|
return CreateCustomChannel(server, InsecureChannelCredentials(), args); |
|
|
|
|
if (interceptor_creators.empty()) { |
|
|
|
|
return CreateCustomChannel(server, InsecureChannelCredentials(), args); |
|
|
|
|
} else { |
|
|
|
|
return experimental::CreateCustomChannelWithInterceptors( |
|
|
|
|
server, InsecureChannelCredentials(), args, |
|
|
|
|
std::move(interceptor_creators)); |
|
|
|
|
} |
|
|
|
|
} else if (cred_type == testing::kTlsCredentialsType) { // cred_type == "ssl"
|
|
|
|
|
if (use_prod_roots) { |
|
|
|
|
gpr_once_init(&g_once_init_add_prod_ssl_provider, &AddProdSslType); |
|
|
|
@ -95,54 +159,62 @@ std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
if (creds.get()) { |
|
|
|
|
channel_creds = CompositeChannelCredentials(channel_creds, creds); |
|
|
|
|
} |
|
|
|
|
return CreateCustomChannel(connect_to, channel_creds, channel_args); |
|
|
|
|
if (interceptor_creators.empty()) { |
|
|
|
|
return CreateCustomChannel(connect_to, channel_creds, channel_args); |
|
|
|
|
} else { |
|
|
|
|
return experimental::CreateCustomChannelWithInterceptors( |
|
|
|
|
connect_to, channel_creds, channel_args, |
|
|
|
|
std::move(interceptor_creators)); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
channel_creds = testing::GetCredentialsProvider()->GetChannelCredentials( |
|
|
|
|
cred_type, &channel_args); |
|
|
|
|
GPR_ASSERT(channel_creds != nullptr); |
|
|
|
|
|
|
|
|
|
return CreateCustomChannel(server, channel_creds, args); |
|
|
|
|
if (interceptor_creators.empty()) { |
|
|
|
|
return CreateCustomChannel(server, channel_creds, args); |
|
|
|
|
} else { |
|
|
|
|
return experimental::CreateCustomChannelWithInterceptors( |
|
|
|
|
server, channel_creds, args, std::move(interceptor_creators)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
const grpc::string& server, const grpc::string& override_hostname, |
|
|
|
|
testing::transport_security security_type, bool use_prod_roots, |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds, |
|
|
|
|
const ChannelArguments& args) { |
|
|
|
|
grpc::string type = |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds, const ChannelArguments& args, |
|
|
|
|
std::vector< |
|
|
|
|
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> |
|
|
|
|
interceptor_creators) { |
|
|
|
|
grpc::string credential_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); |
|
|
|
|
return CreateTestChannel( |
|
|
|
|
server, credential_type, override_hostname, use_prod_roots, creds, args, |
|
|
|
|
std::move(interceptor_creators)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
const grpc::string& server, const grpc::string& override_hostname, |
|
|
|
|
testing::transport_security security_type, bool use_prod_roots, |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds) { |
|
|
|
|
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, |
|
|
|
|
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, testing::transport_security security_type) { |
|
|
|
|
return CreateTestChannel(server, "foo.test.google.fr", security_type, false); |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds, |
|
|
|
|
std::vector< |
|
|
|
|
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> |
|
|
|
|
interceptor_creators) { |
|
|
|
|
return CreateTestChannel( |
|
|
|
|
server, override_hostname, security_type, use_prod_roots, creds, |
|
|
|
|
ChannelArguments(), std::move(interceptor_creators)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
const grpc::string& server, const grpc::string& credential_type, |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds) { |
|
|
|
|
const std::shared_ptr<CallCredentials>& creds, |
|
|
|
|
std::vector< |
|
|
|
|
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> |
|
|
|
|
interceptor_creators) { |
|
|
|
|
ChannelArguments channel_args; |
|
|
|
|
std::shared_ptr<ChannelCredentials> channel_creds = |
|
|
|
|
testing::GetCredentialsProvider()->GetChannelCredentials(credential_type, |
|
|
|
@ -151,7 +223,8 @@ std::shared_ptr<Channel> CreateTestChannel( |
|
|
|
|
if (creds.get()) { |
|
|
|
|
channel_creds = CompositeChannelCredentials(channel_creds, creds); |
|
|
|
|
} |
|
|
|
|
return CreateCustomChannel(server, channel_creds, channel_args); |
|
|
|
|
return experimental::CreateCustomChannelWithInterceptors( |
|
|
|
|
server, channel_creds, channel_args, std::move(interceptor_creators)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace grpc
|
|
|
|
|