diff options
author | heretic <heretic@yandex-team.ru> | 2022-02-10 16:45:43 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:43 +0300 |
commit | 397cbe258b9e064f49c4ca575279f02f39fef76e (patch) | |
tree | a0b0eb3cca6a14e4e8ea715393637672fa651284 /contrib/libs/grpc/test/cpp/util/cli_credentials.cc | |
parent | 43f5a35593ebc9f6bcea619bb170394ea7ae468e (diff) | |
download | ydb-397cbe258b9e064f49c4ca575279f02f39fef76e.tar.gz |
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/test/cpp/util/cli_credentials.cc')
-rw-r--r-- | contrib/libs/grpc/test/cpp/util/cli_credentials.cc | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/contrib/libs/grpc/test/cpp/util/cli_credentials.cc b/contrib/libs/grpc/test/cpp/util/cli_credentials.cc index efd548eb9b..c377cb6b80 100644 --- a/contrib/libs/grpc/test/cpp/util/cli_credentials.cc +++ b/contrib/libs/grpc/test/cpp/util/cli_credentials.cc @@ -48,13 +48,13 @@ DEFINE_string( "If not empty, load this PEM formatted private key. Requires use of " "--ssl_client_cert"); DEFINE_string( - local_connect_type, "local_tcp", - "The type of local connections for which local channel credentials will " - "be applied. Should be local_tcp or uds."); -DEFINE_string( + local_connect_type, "local_tcp", + "The type of local connections for which local channel credentials will " + "be applied. Should be local_tcp or uds."); +DEFINE_string( channel_creds_type, "", - "The channel creds type: insecure, ssl, gdc (Google Default Credentials), " - "alts, or local."); + "The channel creds type: insecure, ssl, gdc (Google Default Credentials), " + "alts, or local."); DEFINE_string( call_creds, "", "Call credentials to use: none (default), or access_token=<token>. If " @@ -69,21 +69,21 @@ const char ACCESS_TOKEN_PREFIX[] = "access_token="; constexpr int ACCESS_TOKEN_PREFIX_LEN = sizeof(ACCESS_TOKEN_PREFIX) / sizeof(*ACCESS_TOKEN_PREFIX) - 1; -bool IsAccessToken(const TString& auth) { +bool IsAccessToken(const TString& auth) { return auth.length() > ACCESS_TOKEN_PREFIX_LEN && auth.compare(0, ACCESS_TOKEN_PREFIX_LEN, ACCESS_TOKEN_PREFIX) == 0; } -TString AccessToken(const TString& auth) { +TString AccessToken(const TString& auth) { if (!IsAccessToken(auth)) { return ""; } - return TString(auth.c_str(), ACCESS_TOKEN_PREFIX_LEN); + return TString(auth.c_str(), ACCESS_TOKEN_PREFIX_LEN); } } // namespace -TString CliCredentials::GetDefaultChannelCredsType() const { +TString CliCredentials::GetDefaultChannelCredsType() const { // Compatibility logic for --enable_ssl. if (FLAGS_enable_ssl) { fprintf(stderr, @@ -101,12 +101,12 @@ TString CliCredentials::GetDefaultChannelCredsType() const { return "insecure"; } -TString CliCredentials::GetDefaultCallCreds() const { +TString CliCredentials::GetDefaultCallCreds() const { if (!FLAGS_access_token.empty()) { fprintf(stderr, "warning: --access_token is deprecated. Use " "--call_creds=access_token=<token>.\n"); - return TString("access_token=") + FLAGS_access_token; + return TString("access_token=") + FLAGS_access_token; } return "none"; } @@ -142,28 +142,28 @@ CliCredentials::GetChannelCredentials() const { } else if (FLAGS_channel_creds_type.compare("alts") == 0) { return grpc::experimental::AltsCredentials( grpc::experimental::AltsCredentialsOptions()); - } else if (FLAGS_channel_creds_type.compare("local") == 0) { - if (FLAGS_local_connect_type.compare("local_tcp") == 0) { - return grpc::experimental::LocalCredentials(LOCAL_TCP); - } else if (FLAGS_local_connect_type.compare("uds") == 0) { - return grpc::experimental::LocalCredentials(UDS); - } else { - fprintf(stderr, - "--local_connect_type=%s invalid; must be local_tcp or uds.\n", - FLAGS_local_connect_type.c_str()); - } + } else if (FLAGS_channel_creds_type.compare("local") == 0) { + if (FLAGS_local_connect_type.compare("local_tcp") == 0) { + return grpc::experimental::LocalCredentials(LOCAL_TCP); + } else if (FLAGS_local_connect_type.compare("uds") == 0) { + return grpc::experimental::LocalCredentials(UDS); + } else { + fprintf(stderr, + "--local_connect_type=%s invalid; must be local_tcp or uds.\n", + FLAGS_local_connect_type.c_str()); + } } fprintf(stderr, - "--channel_creds_type=%s invalid; must be insecure, ssl, gdc, " - "alts, or local.\n", + "--channel_creds_type=%s invalid; must be insecure, ssl, gdc, " + "alts, or local.\n", FLAGS_channel_creds_type.c_str()); return std::shared_ptr<grpc::ChannelCredentials>(); } std::shared_ptr<grpc::CallCredentials> CliCredentials::GetCallCredentials() const { - if (IsAccessToken(FLAGS_call_creds.c_str())) { - return grpc::AccessTokenCredentials(AccessToken(FLAGS_call_creds.c_str())); + if (IsAccessToken(FLAGS_call_creds.c_str())) { + return grpc::AccessTokenCredentials(AccessToken(FLAGS_call_creds.c_str())); } if (FLAGS_call_creds.compare("none") == 0) { // Nothing to do; creds, if any, are baked into the channel. @@ -180,7 +180,7 @@ std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials() const { if (FLAGS_call_creds.empty()) { FLAGS_call_creds = GetDefaultCallCreds(); - } else if (!FLAGS_access_token.empty() && !IsAccessToken(FLAGS_call_creds.c_str())) { + } else if (!FLAGS_access_token.empty() && !IsAccessToken(FLAGS_call_creds.c_str())) { fprintf(stderr, "warning: ignoring --access_token because --call_creds " "already set to %s.\n", @@ -200,7 +200,7 @@ std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials() FLAGS_channel_creds_type.c_str()); } // Legacy transport upgrade logic for insecure requests. - if (IsAccessToken(FLAGS_call_creds.c_str()) && + if (IsAccessToken(FLAGS_call_creds.c_str()) && FLAGS_channel_creds_type.compare("insecure") == 0) { fprintf(stderr, "warning: --channel_creds_type=insecure upgraded to ssl because " @@ -216,9 +216,9 @@ std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials() : grpc::CompositeChannelCredentials(channel_creds, call_creds); } -const TString CliCredentials::GetCredentialUsage() const { - return " --enable_ssl ; Set whether to use ssl " - "(deprecated)\n" +const TString CliCredentials::GetCredentialUsage() const { + return " --enable_ssl ; Set whether to use ssl " + "(deprecated)\n" " --use_auth ; Set whether to create default google" " credentials\n" " ; (deprecated)\n" @@ -228,14 +228,14 @@ const TString CliCredentials::GetCredentialUsage() const { " --ssl_target ; Set server host for ssl validation\n" " --ssl_client_cert ; Client cert for ssl\n" " --ssl_client_key ; Client private key for ssl\n" - " --local_connect_type ; Set to local_tcp or uds\n" - " --channel_creds_type ; Set to insecure, ssl, gdc, alts, or " - "local\n" + " --local_connect_type ; Set to local_tcp or uds\n" + " --channel_creds_type ; Set to insecure, ssl, gdc, alts, or " + "local\n" " --call_creds ; Set to none, or" " access_token=<token>\n"; } -const TString CliCredentials::GetSslTargetNameOverride() const { +const TString CliCredentials::GetSslTargetNameOverride() const { bool use_ssl = FLAGS_channel_creds_type.compare("ssl") == 0 || FLAGS_channel_creds_type.compare("gdc") == 0; return use_ssl ? FLAGS_ssl_target : ""; |