21 #include "absl/flags/flag.h"
30 "If non-empty, set a static service config on channels created by "
31 "grpc::CreateTestChannel, that configures the grpclb LB policy "
32 "with a child policy being the value of this flag (e.g. round_robin "
39 const char kProdTlsCredentialsType[] =
"prod_ssl";
41 class SslCredentialProvider :
public testing::CredentialTypeProvider {
43 std::shared_ptr<ChannelCredentials> GetChannelCredentials(
47 std::shared_ptr<ServerCredentials> GetServerCredentials()
override {
54 void AddProdSslType() {
56 kProdTlsCredentialsType, std::unique_ptr<testing::CredentialTypeProvider>(
57 new SslCredentialProvider));
63 "grpc.service_config",
64 "{\"loadBalancingConfig\":[{\"grpclb\":{\"childPolicy\":[{"
90 const std::string& override_hostname,
bool use_prod_roots,
91 const std::shared_ptr<CallCredentials>& creds,
101 const std::shared_ptr<CallCredentials>& creds,
104 use_prod_roots, creds,
args,
111 const std::shared_ptr<CallCredentials>& creds) {
120 use_prod_roots, std::shared_ptr<CallCredentials>());
131 const std::shared_ptr<CallCredentials>& creds) {
133 MaybeSetCustomChannelArgs(&channel_args);
134 std::shared_ptr<ChannelCredentials> channel_creds =
146 const std::string& override_hostname,
bool use_prod_roots,
149 std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
150 interceptor_creators) {
152 MaybeSetCustomChannelArgs(&channel_args);
153 std::shared_ptr<ChannelCredentials> channel_creds;
154 if (cred_type.empty()) {
155 if (interceptor_creators.empty()) {
164 if (use_prod_roots) {
165 gpr_once_init(&g_once_init_add_prod_ssl_provider, &AddProdSslType);
167 kProdTlsCredentialsType, &channel_args);
168 if (!
server.empty() && !override_hostname.empty()) {
182 if (interceptor_creators.empty()) {
186 connect_to, channel_creds, channel_args,
191 cred_type, &channel_args);
194 if (interceptor_creators.empty()) {
208 std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
209 interceptor_creators) {
216 use_prod_roots, creds,
args,
223 const std::shared_ptr<CallCredentials>& creds,
225 std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
226 interceptor_creators) {
234 const std::shared_ptr<CallCredentials>& creds,
236 std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
237 interceptor_creators) {
239 MaybeSetCustomChannelArgs(&channel_args);
240 std::shared_ptr<ChannelCredentials> channel_creds =