aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/test
diff options
context:
space:
mode:
authorneksard <neksard@yandex-team.ru>2022-02-10 16:45:33 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:33 +0300
commit1d9c550e7c38e051d7961f576013a482003a70d9 (patch)
treeb2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /contrib/libs/grpc/test
parent8f7cf138264e0caa318144bf8a2c950e0b0a8593 (diff)
downloadydb-1d9c550e7c38e051d7961f576013a482003a70d9.tar.gz
Restoring authorship annotation for <neksard@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/grpc/test')
-rw-r--r--contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.cc24
-rw-r--r--contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.h12
-rw-r--r--contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc14
-rw-r--r--contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc114
-rw-r--r--contrib/libs/grpc/test/cpp/util/cli_call.cc2
-rw-r--r--contrib/libs/grpc/test/cpp/util/cli_call.h2
-rw-r--r--contrib/libs/grpc/test/cpp/util/cli_call_test.cc2
-rw-r--r--contrib/libs/grpc/test/cpp/util/cli_credentials.cc332
-rw-r--r--contrib/libs/grpc/test/cpp/util/cli_credentials.h30
-rw-r--r--contrib/libs/grpc/test/cpp/util/grpc_tool.cc162
-rw-r--r--contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc836
-rw-r--r--contrib/libs/grpc/test/cpp/util/proto_file_parser.cc82
-rw-r--r--contrib/libs/grpc/test/cpp/util/proto_file_parser.h54
-rw-r--r--contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.cc14
-rw-r--r--contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.h2
-rw-r--r--contrib/libs/grpc/test/cpp/util/string_ref_test.cc2
-rw-r--r--contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc4
-rw-r--r--contrib/libs/grpc/test/cpp/util/test_credentials_provider.h2
18 files changed, 845 insertions, 845 deletions
diff --git a/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.cc b/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.cc
index f81103bb94..5971b53075 100644
--- a/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.cc
+++ b/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.cc
@@ -40,18 +40,18 @@ std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
return std::unique_ptr<ByteBuffer>(new ByteBuffer(&slice, 1));
}
-bool SerializeToByteBufferInPlace(grpc::protobuf::Message* message,
- ByteBuffer* buffer) {
+bool SerializeToByteBufferInPlace(grpc::protobuf::Message* message,
+ ByteBuffer* buffer) {
TString buf;
- if (!message->SerializeToString(&buf)) {
- return false;
- }
- buffer->Clear();
- Slice slice(buf);
- ByteBuffer tmp(&slice, 1);
- buffer->Swap(&tmp);
- return true;
-}
-
+ if (!message->SerializeToString(&buf)) {
+ return false;
+ }
+ buffer->Clear();
+ Slice slice(buf);
+ ByteBuffer tmp(&slice, 1);
+ buffer->Swap(&tmp);
+ return true;
+}
+
} // namespace testing
} // namespace grpc
diff --git a/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.h b/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.h
index 00b5fc7252..3d01fb2468 100644
--- a/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.h
+++ b/contrib/libs/grpc/test/cpp/util/byte_buffer_proto_helper.h
@@ -27,15 +27,15 @@
namespace grpc {
namespace testing {
-bool ParseFromByteBuffer(ByteBuffer* buffer,
- ::grpc::protobuf::Message* message);
+bool ParseFromByteBuffer(ByteBuffer* buffer,
+ ::grpc::protobuf::Message* message);
std::unique_ptr<ByteBuffer> SerializeToByteBuffer(
- ::grpc::protobuf::Message* message);
+ ::grpc::protobuf::Message* message);
+
+bool SerializeToByteBufferInPlace(::grpc::protobuf::Message* message,
+ ByteBuffer* buffer);
-bool SerializeToByteBufferInPlace(::grpc::protobuf::Message* message,
- ByteBuffer* buffer);
-
} // namespace testing
} // namespace grpc
diff --git a/contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc b/contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc
index 3c4b73e267..c63f351a8f 100644
--- a/contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc
+++ b/contrib/libs/grpc/test/cpp/util/byte_buffer_test.cc
@@ -45,13 +45,13 @@ class ByteBufferTest : public ::testing::Test {
static void TearDownTestCase() { grpc_shutdown(); }
};
-TEST_F(ByteBufferTest, CopyCtor) {
- ByteBuffer buffer1;
- EXPECT_FALSE(buffer1.Valid());
- const ByteBuffer& buffer2 = buffer1;
- EXPECT_FALSE(buffer2.Valid());
-}
-
+TEST_F(ByteBufferTest, CopyCtor) {
+ ByteBuffer buffer1;
+ EXPECT_FALSE(buffer1.Valid());
+ const ByteBuffer& buffer2 = buffer1;
+ EXPECT_FALSE(buffer2.Valid());
+}
+
TEST_F(ByteBufferTest, CreateFromSingleSlice) {
Slice s(kContent1);
ByteBuffer buffer(&s, 1);
diff --git a/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc b/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc
index 97d20abf64..d4b4026774 100644
--- a/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc
+++ b/contrib/libs/grpc/test/cpp/util/channel_trace_proto_helper.cc
@@ -16,14 +16,14 @@
*
*/
-#include <grpc/support/port_platform.h>
-
+#include <grpc/support/port_platform.h>
+
#include "test/cpp/util/channel_trace_proto_helper.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
-#include <grpcpp/impl/codegen/config.h>
-#include <grpcpp/impl/codegen/config_protobuf.h>
+#include <grpcpp/impl/codegen/config.h>
+#include <grpcpp/impl/codegen/config_protobuf.h>
#include <gtest/gtest.h>
#include "src/core/lib/iomgr/error.h"
@@ -32,30 +32,30 @@
namespace grpc {
-namespace {
-
-// Generic helper that takes in a json string, converts it to a proto, and
-// then back to json. This ensures that the json string was correctly formatted
-// according to https://developers.google.com/protocol-buffers/docs/proto3#json
-template <typename Message>
+namespace {
+
+// Generic helper that takes in a json string, converts it to a proto, and
+// then back to json. This ensures that the json string was correctly formatted
+// according to https://developers.google.com/protocol-buffers/docs/proto3#json
+template <typename Message>
void VaidateProtoJsonTranslation(const TString& json_str) {
- Message msg;
- grpc::protobuf::json::JsonParseOptions parse_options;
+ Message msg;
+ grpc::protobuf::json::JsonParseOptions parse_options;
// If the following line is failing, then uncomment the last line of the
// comment, and uncomment the lines that print the two strings. You can
// then compare the output, and determine what fields are missing.
//
- // parse_options.ignore_unknown_fields = true;
- grpc::protobuf::util::Status s =
- grpc::protobuf::json::JsonStringToMessage(json_str, &msg, parse_options);
- EXPECT_TRUE(s.ok());
+ // parse_options.ignore_unknown_fields = true;
+ grpc::protobuf::util::Status s =
+ grpc::protobuf::json::JsonStringToMessage(json_str, &msg, parse_options);
+ EXPECT_TRUE(s.ok());
TString proto_json_str;
- grpc::protobuf::json::JsonPrintOptions print_options;
- // We usually do not want this to be true, however it can be helpful to
- // uncomment and see the output produced then all fields are printed.
- // print_options.always_print_primitive_fields = true;
- s = grpc::protobuf::json::MessageToJsonString(msg, &proto_json_str);
- EXPECT_TRUE(s.ok());
+ grpc::protobuf::json::JsonPrintOptions print_options;
+ // We usually do not want this to be true, however it can be helpful to
+ // uncomment and see the output produced then all fields are printed.
+ // print_options.always_print_primitive_fields = true;
+ s = grpc::protobuf::json::MessageToJsonString(msg, &proto_json_str);
+ EXPECT_TRUE(s.ok());
// Parse JSON and re-dump to string, to make sure formatting is the
// same as what would be generated by our JSON library.
grpc_error* error = GRPC_ERROR_NONE;
@@ -64,52 +64,52 @@ void VaidateProtoJsonTranslation(const TString& json_str) {
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error);
ASSERT_EQ(parsed_json.type(), grpc_core::Json::Type::OBJECT);
proto_json_str = parsed_json.Dump();
- // uncomment these to compare the json strings.
- // gpr_log(GPR_ERROR, "tracer json: %s", json_str.c_str());
+ // uncomment these to compare the json strings.
+ // gpr_log(GPR_ERROR, "tracer json: %s", json_str.c_str());
// gpr_log(GPR_ERROR, "proto json: %s", proto_json_str.c_str());
- EXPECT_EQ(json_str, proto_json_str);
+ EXPECT_EQ(json_str, proto_json_str);
}
-} // namespace
-
-namespace testing {
-
+} // namespace
+
+namespace testing {
+
void ValidateChannelTraceProtoJsonTranslation(const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::ChannelTrace>(json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::ChannelTrace>(json_c_str);
+}
+
void ValidateChannelProtoJsonTranslation(const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::Channel>(json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::Channel>(json_c_str);
+}
+
void ValidateGetTopChannelsResponseProtoJsonTranslation(
const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::GetTopChannelsResponse>(
- json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::GetTopChannelsResponse>(
+ json_c_str);
+}
+
void ValidateGetChannelResponseProtoJsonTranslation(const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::GetChannelResponse>(
- json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::GetChannelResponse>(
+ json_c_str);
+}
+
void ValidateGetServerResponseProtoJsonTranslation(const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::GetServerResponse>(
- json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::GetServerResponse>(
+ json_c_str);
+}
+
void ValidateSubchannelProtoJsonTranslation(const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::Subchannel>(json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::Subchannel>(json_c_str);
+}
+
void ValidateServerProtoJsonTranslation(const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::Server>(json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::Server>(json_c_str);
+}
+
void ValidateGetServersResponseProtoJsonTranslation(const char* json_c_str) {
- VaidateProtoJsonTranslation<grpc::channelz::v1::GetServersResponse>(
- json_c_str);
-}
-
+ VaidateProtoJsonTranslation<grpc::channelz::v1::GetServersResponse>(
+ json_c_str);
+}
+
} // namespace testing
} // namespace grpc
diff --git a/contrib/libs/grpc/test/cpp/util/cli_call.cc b/contrib/libs/grpc/test/cpp/util/cli_call.cc
index 8bc3c16e96..5b3631667f 100644
--- a/contrib/libs/grpc/test/cpp/util/cli_call.cc
+++ b/contrib/libs/grpc/test/cpp/util/cli_call.cc
@@ -50,7 +50,7 @@ Status CliCall::Call(const std::shared_ptr<grpc::Channel>& channel,
return call.Finish(server_trailing_metadata);
}
-CliCall::CliCall(const std::shared_ptr<grpc::Channel>& channel,
+CliCall::CliCall(const std::shared_ptr<grpc::Channel>& channel,
const TString& method,
const OutgoingMetadataContainer& metadata, CliArgs args)
: stub_(new grpc::GenericStub(channel)) {
diff --git a/contrib/libs/grpc/test/cpp/util/cli_call.h b/contrib/libs/grpc/test/cpp/util/cli_call.h
index cb1c1bb869..79d00d99f4 100644
--- a/contrib/libs/grpc/test/cpp/util/cli_call.h
+++ b/contrib/libs/grpc/test/cpp/util/cli_call.h
@@ -46,7 +46,7 @@ class CliCall final {
typedef std::multimap<grpc::string_ref, grpc::string_ref>
IncomingMetadataContainer;
- CliCall(const std::shared_ptr<grpc::Channel>& channel,
+ CliCall(const std::shared_ptr<grpc::Channel>& channel,
const TString& method, const OutgoingMetadataContainer& metadata,
CliArgs args);
CliCall(const std::shared_ptr<grpc::Channel>& channel,
diff --git a/contrib/libs/grpc/test/cpp/util/cli_call_test.cc b/contrib/libs/grpc/test/cpp/util/cli_call_test.cc
index ac3f287061..4f0544b2e5 100644
--- a/contrib/libs/grpc/test/cpp/util/cli_call_test.cc
+++ b/contrib/libs/grpc/test/cpp/util/cli_call_test.cc
@@ -122,7 +122,7 @@ TEST_F(CliCallTest, SimpleRpc) {
} // namespace grpc
int main(int argc, char** argv) {
- grpc::testing::TestEnvironment env(argc, argv);
+ grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/contrib/libs/grpc/test/cpp/util/cli_credentials.cc b/contrib/libs/grpc/test/cpp/util/cli_credentials.cc
index 33502efb07..efd548eb9b 100644
--- a/contrib/libs/grpc/test/cpp/util/cli_credentials.cc
+++ b/contrib/libs/grpc/test/cpp/util/cli_credentials.cc
@@ -19,129 +19,129 @@
#include "test/cpp/util/cli_credentials.h"
#include <gflags/gflags.h>
-#include <grpc/slice.h>
-#include <grpc/support/log.h>
-#include <grpcpp/impl/codegen/slice.h>
-
-#include "src/core/lib/iomgr/load_file.h"
-
-DEFINE_bool(
- enable_ssl, false,
- "Whether to use ssl/tls. Deprecated. Use --channel_creds_type=ssl.");
-DEFINE_bool(use_auth, false,
- "Whether to create default google credentials. Deprecated. Use "
- "--channel_creds_type=gdc.");
+#include <grpc/slice.h>
+#include <grpc/support/log.h>
+#include <grpcpp/impl/codegen/slice.h>
+
+#include "src/core/lib/iomgr/load_file.h"
+
+DEFINE_bool(
+ enable_ssl, false,
+ "Whether to use ssl/tls. Deprecated. Use --channel_creds_type=ssl.");
+DEFINE_bool(use_auth, false,
+ "Whether to create default google credentials. Deprecated. Use "
+ "--channel_creds_type=gdc.");
DEFINE_string(
access_token, "",
- "The access token that will be sent to the server to authenticate RPCs. "
- "Deprecated. Use --call_creds=access_token=<token>.");
-DEFINE_string(
- ssl_target, "",
- "If not empty, treat the server host name as this for ssl/tls certificate "
- "validation.");
-DEFINE_string(
- ssl_client_cert, "",
+ "The access token that will be sent to the server to authenticate RPCs. "
+ "Deprecated. Use --call_creds=access_token=<token>.");
+DEFINE_string(
+ ssl_target, "",
+ "If not empty, treat the server host name as this for ssl/tls certificate "
+ "validation.");
+DEFINE_string(
+ ssl_client_cert, "",
"If not empty, load this PEM formatted client certificate file. Requires "
- "use of --ssl_client_key.");
-DEFINE_string(
- ssl_client_key, "",
+ "use of --ssl_client_key.");
+DEFINE_string(
+ ssl_client_key, "",
"If not empty, load this PEM formatted private key. Requires use of "
- "--ssl_client_cert");
-DEFINE_string(
+ "--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(
- channel_creds_type, "",
+ channel_creds_type, "",
"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 "
- "provided, the call creds are composited on top of channel creds.");
+DEFINE_string(
+ call_creds, "",
+ "Call credentials to use: none (default), or access_token=<token>. If "
+ "provided, the call creds are composited on top of channel creds.");
namespace grpc {
namespace testing {
-namespace {
+namespace {
+
+const char ACCESS_TOKEN_PREFIX[] = "access_token=";
+constexpr int ACCESS_TOKEN_PREFIX_LEN =
+ sizeof(ACCESS_TOKEN_PREFIX) / sizeof(*ACCESS_TOKEN_PREFIX) - 1;
-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) {
- return auth.length() > ACCESS_TOKEN_PREFIX_LEN &&
- auth.compare(0, ACCESS_TOKEN_PREFIX_LEN, ACCESS_TOKEN_PREFIX) == 0;
-}
-
+ return auth.length() > ACCESS_TOKEN_PREFIX_LEN &&
+ auth.compare(0, ACCESS_TOKEN_PREFIX_LEN, ACCESS_TOKEN_PREFIX) == 0;
+}
+
TString AccessToken(const TString& auth) {
- if (!IsAccessToken(auth)) {
- return "";
+ if (!IsAccessToken(auth)) {
+ return "";
}
return TString(auth.c_str(), ACCESS_TOKEN_PREFIX_LEN);
-}
+}
+
+} // namespace
-} // namespace
-
TString CliCredentials::GetDefaultChannelCredsType() const {
- // Compatibility logic for --enable_ssl.
- if (FLAGS_enable_ssl) {
- fprintf(stderr,
- "warning: --enable_ssl is deprecated. Use "
- "--channel_creds_type=ssl.\n");
- return "ssl";
- }
- // Compatibility logic for --use_auth.
- if (FLAGS_access_token.empty() && FLAGS_use_auth) {
- fprintf(stderr,
- "warning: --use_auth is deprecated. Use "
- "--channel_creds_type=gdc.\n");
- return "gdc";
- }
- return "insecure";
-}
-
+ // Compatibility logic for --enable_ssl.
+ if (FLAGS_enable_ssl) {
+ fprintf(stderr,
+ "warning: --enable_ssl is deprecated. Use "
+ "--channel_creds_type=ssl.\n");
+ return "ssl";
+ }
+ // Compatibility logic for --use_auth.
+ if (FLAGS_access_token.empty() && FLAGS_use_auth) {
+ fprintf(stderr,
+ "warning: --use_auth is deprecated. Use "
+ "--channel_creds_type=gdc.\n");
+ return "gdc";
+ }
+ return "insecure";
+}
+
TString CliCredentials::GetDefaultCallCreds() const {
- if (!FLAGS_access_token.empty()) {
- fprintf(stderr,
- "warning: --access_token is deprecated. Use "
- "--call_creds=access_token=<token>.\n");
+ 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 "none";
-}
-
-std::shared_ptr<grpc::ChannelCredentials>
-CliCredentials::GetChannelCredentials() const {
- if (FLAGS_channel_creds_type.compare("insecure") == 0) {
- return grpc::InsecureChannelCredentials();
- } else if (FLAGS_channel_creds_type.compare("ssl") == 0) {
- grpc::SslCredentialsOptions ssl_creds_options;
- // TODO(@Capstan): This won't affect Google Default Credentials using SSL.
- if (!FLAGS_ssl_client_cert.empty()) {
- grpc_slice cert_slice = grpc_empty_slice();
- GRPC_LOG_IF_ERROR(
- "load_file",
- grpc_load_file(FLAGS_ssl_client_cert.c_str(), 1, &cert_slice));
- ssl_creds_options.pem_cert_chain =
- grpc::StringFromCopiedSlice(cert_slice);
- grpc_slice_unref(cert_slice);
- }
- if (!FLAGS_ssl_client_key.empty()) {
- grpc_slice key_slice = grpc_empty_slice();
- GRPC_LOG_IF_ERROR(
- "load_file",
- grpc_load_file(FLAGS_ssl_client_key.c_str(), 1, &key_slice));
- ssl_creds_options.pem_private_key =
- grpc::StringFromCopiedSlice(key_slice);
- grpc_slice_unref(key_slice);
- }
- return grpc::SslCredentials(ssl_creds_options);
- } else if (FLAGS_channel_creds_type.compare("gdc") == 0) {
+ }
+ return "none";
+}
+
+std::shared_ptr<grpc::ChannelCredentials>
+CliCredentials::GetChannelCredentials() const {
+ if (FLAGS_channel_creds_type.compare("insecure") == 0) {
+ return grpc::InsecureChannelCredentials();
+ } else if (FLAGS_channel_creds_type.compare("ssl") == 0) {
+ grpc::SslCredentialsOptions ssl_creds_options;
+ // TODO(@Capstan): This won't affect Google Default Credentials using SSL.
+ if (!FLAGS_ssl_client_cert.empty()) {
+ grpc_slice cert_slice = grpc_empty_slice();
+ GRPC_LOG_IF_ERROR(
+ "load_file",
+ grpc_load_file(FLAGS_ssl_client_cert.c_str(), 1, &cert_slice));
+ ssl_creds_options.pem_cert_chain =
+ grpc::StringFromCopiedSlice(cert_slice);
+ grpc_slice_unref(cert_slice);
+ }
+ if (!FLAGS_ssl_client_key.empty()) {
+ grpc_slice key_slice = grpc_empty_slice();
+ GRPC_LOG_IF_ERROR(
+ "load_file",
+ grpc_load_file(FLAGS_ssl_client_key.c_str(), 1, &key_slice));
+ ssl_creds_options.pem_private_key =
+ grpc::StringFromCopiedSlice(key_slice);
+ grpc_slice_unref(key_slice);
+ }
+ return grpc::SslCredentials(ssl_creds_options);
+ } else if (FLAGS_channel_creds_type.compare("gdc") == 0) {
return grpc::GoogleDefaultCredentials();
- } else if (FLAGS_channel_creds_type.compare("alts") == 0) {
- return grpc::experimental::AltsCredentials(
- grpc::experimental::AltsCredentialsOptions());
+ } 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);
@@ -153,67 +153,67 @@ CliCredentials::GetChannelCredentials() const {
FLAGS_local_connect_type.c_str());
}
}
- fprintf(stderr,
+ fprintf(stderr,
"--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>();
-}
+ FLAGS_channel_creds_type.c_str());
+ return std::shared_ptr<grpc::ChannelCredentials>();
+}
-std::shared_ptr<grpc::CallCredentials> CliCredentials::GetCallCredentials()
- const {
+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 (FLAGS_call_creds.compare("none") == 0) {
- // Nothing to do; creds, if any, are baked into the channel.
- return std::shared_ptr<grpc::CallCredentials>();
- }
- fprintf(stderr,
- "--call_creds=%s invalid; must be none "
- "or access_token=<token>.\n",
- FLAGS_call_creds.c_str());
- return std::shared_ptr<grpc::CallCredentials>();
-}
-
-std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials()
- const {
- if (FLAGS_call_creds.empty()) {
- FLAGS_call_creds = GetDefaultCallCreds();
+ if (FLAGS_call_creds.compare("none") == 0) {
+ // Nothing to do; creds, if any, are baked into the channel.
+ return std::shared_ptr<grpc::CallCredentials>();
+ }
+ fprintf(stderr,
+ "--call_creds=%s invalid; must be none "
+ "or access_token=<token>.\n",
+ FLAGS_call_creds.c_str());
+ return std::shared_ptr<grpc::CallCredentials>();
+}
+
+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())) {
- fprintf(stderr,
- "warning: ignoring --access_token because --call_creds "
- "already set to %s.\n",
- FLAGS_call_creds.c_str());
- }
- if (FLAGS_channel_creds_type.empty()) {
- FLAGS_channel_creds_type = GetDefaultChannelCredsType();
- } else if (FLAGS_enable_ssl && FLAGS_channel_creds_type.compare("ssl") != 0) {
- fprintf(stderr,
- "warning: ignoring --enable_ssl because "
- "--channel_creds_type already set to %s.\n",
- FLAGS_channel_creds_type.c_str());
- } else if (FLAGS_use_auth && FLAGS_channel_creds_type.compare("gdc") != 0) {
- fprintf(stderr,
- "warning: ignoring --use_auth because "
- "--channel_creds_type already set to %s.\n",
- FLAGS_channel_creds_type.c_str());
- }
- // Legacy transport upgrade logic for insecure requests.
+ fprintf(stderr,
+ "warning: ignoring --access_token because --call_creds "
+ "already set to %s.\n",
+ FLAGS_call_creds.c_str());
+ }
+ if (FLAGS_channel_creds_type.empty()) {
+ FLAGS_channel_creds_type = GetDefaultChannelCredsType();
+ } else if (FLAGS_enable_ssl && FLAGS_channel_creds_type.compare("ssl") != 0) {
+ fprintf(stderr,
+ "warning: ignoring --enable_ssl because "
+ "--channel_creds_type already set to %s.\n",
+ FLAGS_channel_creds_type.c_str());
+ } else if (FLAGS_use_auth && FLAGS_channel_creds_type.compare("gdc") != 0) {
+ fprintf(stderr,
+ "warning: ignoring --use_auth because "
+ "--channel_creds_type already set to %s.\n",
+ FLAGS_channel_creds_type.c_str());
+ }
+ // Legacy transport upgrade logic for insecure requests.
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 "
- "an access token was provided.\n");
- FLAGS_channel_creds_type = "ssl";
- }
- std::shared_ptr<grpc::ChannelCredentials> channel_creds =
- GetChannelCredentials();
- // Composite any call-type credentials on top of the base channel.
- std::shared_ptr<grpc::CallCredentials> call_creds = GetCallCredentials();
- return (channel_creds == nullptr || call_creds == nullptr)
- ? channel_creds
- : grpc::CompositeChannelCredentials(channel_creds, call_creds);
+ FLAGS_channel_creds_type.compare("insecure") == 0) {
+ fprintf(stderr,
+ "warning: --channel_creds_type=insecure upgraded to ssl because "
+ "an access token was provided.\n");
+ FLAGS_channel_creds_type = "ssl";
+ }
+ std::shared_ptr<grpc::ChannelCredentials> channel_creds =
+ GetChannelCredentials();
+ // Composite any call-type credentials on top of the base channel.
+ std::shared_ptr<grpc::CallCredentials> call_creds = GetCallCredentials();
+ return (channel_creds == nullptr || call_creds == nullptr)
+ ? channel_creds
+ : grpc::CompositeChannelCredentials(channel_creds, call_creds);
}
const TString CliCredentials::GetCredentialUsage() const {
@@ -221,25 +221,25 @@ const TString CliCredentials::GetCredentialUsage() const {
"(deprecated)\n"
" --use_auth ; Set whether to create default google"
" credentials\n"
- " ; (deprecated)\n"
+ " ; (deprecated)\n"
" --access_token ; Set the access token in metadata,"
- " overrides --use_auth\n"
- " ; (deprecated)\n"
- " --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"
+ " overrides --use_auth\n"
+ " ; (deprecated)\n"
+ " --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"
- " --call_creds ; Set to none, or"
- " access_token=<token>\n";
+ " --call_creds ; Set to none, or"
+ " access_token=<token>\n";
}
-
+
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 : "";
-}
-
+ bool use_ssl = FLAGS_channel_creds_type.compare("ssl") == 0 ||
+ FLAGS_channel_creds_type.compare("gdc") == 0;
+ return use_ssl ? FLAGS_ssl_target : "";
+}
+
} // namespace testing
} // namespace grpc
diff --git a/contrib/libs/grpc/test/cpp/util/cli_credentials.h b/contrib/libs/grpc/test/cpp/util/cli_credentials.h
index 7a1435600c..3e695692fa 100644
--- a/contrib/libs/grpc/test/cpp/util/cli_credentials.h
+++ b/contrib/libs/grpc/test/cpp/util/cli_credentials.h
@@ -28,25 +28,25 @@ namespace testing {
class CliCredentials {
public:
virtual ~CliCredentials() {}
- std::shared_ptr<grpc::ChannelCredentials> GetCredentials() const;
+ std::shared_ptr<grpc::ChannelCredentials> GetCredentials() const;
virtual const TString GetCredentialUsage() const;
virtual const TString GetSslTargetNameOverride() const;
-
- protected:
- // Returns the appropriate channel_creds_type value for the set of legacy
- // flag arguments.
+
+ protected:
+ // Returns the appropriate channel_creds_type value for the set of legacy
+ // flag arguments.
virtual TString GetDefaultChannelCredsType() const;
- // Returns the appropriate call_creds value for the set of legacy flag
- // arguments.
+ // Returns the appropriate call_creds value for the set of legacy flag
+ // arguments.
virtual TString GetDefaultCallCreds() const;
- // Returns the base transport channel credentials. Child classes can override
- // to support additional channel_creds_types unknown to this base class.
- virtual std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials()
- const;
- // Returns call credentials to composite onto the base transport channel
- // credentials. Child classes can override to support additional
- // authentication flags unknown to this base class.
- virtual std::shared_ptr<grpc::CallCredentials> GetCallCredentials() const;
+ // Returns the base transport channel credentials. Child classes can override
+ // to support additional channel_creds_types unknown to this base class.
+ virtual std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials()
+ const;
+ // Returns call credentials to composite onto the base transport channel
+ // credentials. Child classes can override to support additional
+ // authentication flags unknown to this base class.
+ virtual std::shared_ptr<grpc::CallCredentials> GetCallCredentials() const;
};
} // namespace testing
diff --git a/contrib/libs/grpc/test/cpp/util/grpc_tool.cc b/contrib/libs/grpc/test/cpp/util/grpc_tool.cc
index 019e5e40f1..30f3024e25 100644
--- a/contrib/libs/grpc/test/cpp/util/grpc_tool.cc
+++ b/contrib/libs/grpc/test/cpp/util/grpc_tool.cc
@@ -66,8 +66,8 @@ DEFINE_bool(
display_peer_address, false,
"Log the peer socket address of the connection that each RPC is made "
"on to stderr.");
-DEFINE_bool(json_input, false, "Input in json format");
-DEFINE_bool(json_output, false, "Output in json format");
+DEFINE_bool(json_input, false, "Input in json format");
+DEFINE_bool(json_output, false, "Output in json format");
DEFINE_string(infile, "", "Input file (default is stdin)");
DEFINE_bool(batch, false,
"Input contains multiple requests. Please do not use this to send "
@@ -102,8 +102,8 @@ class GrpcTool {
GrpcToolOutputCallback callback);
bool ToText(int argc, const char** argv, const CliCredentials& cred,
GrpcToolOutputCallback callback);
- bool ToJson(int argc, const char** argv, const CliCredentials& cred,
- GrpcToolOutputCallback callback);
+ bool ToJson(int argc, const char** argv, const CliCredentials& cred,
+ GrpcToolOutputCallback callback);
bool ToBinary(int argc, const char** argv, const CliCredentials& cred,
GrpcToolOutputCallback callback);
@@ -205,9 +205,9 @@ void ReadResponse(CliCall* call, const TString& method_name,
fprintf(stderr, "got response.\n");
if (!FLAGS_binary_output) {
gpr_mu_lock(parser_mu);
- serialized_response_proto = parser->GetFormattedStringFromMethod(
- method_name, serialized_response_proto, false /* is_request */,
- FLAGS_json_output);
+ serialized_response_proto = parser->GetFormattedStringFromMethod(
+ method_name, serialized_response_proto, false /* is_request */,
+ FLAGS_json_output);
if (parser->HasError() && print_mode) {
fprintf(stderr, "Failed to parse response.\n");
}
@@ -223,20 +223,20 @@ void ReadResponse(CliCall* call, const TString& method_name,
}
}
-std::shared_ptr<grpc::Channel> CreateCliChannel(
+std::shared_ptr<grpc::Channel> CreateCliChannel(
const TString& server_address, const CliCredentials& cred) {
- grpc::ChannelArguments args;
- if (!cred.GetSslTargetNameOverride().empty()) {
- args.SetSslTargetNameOverride(cred.GetSslTargetNameOverride());
- }
+ grpc::ChannelArguments args;
+ if (!cred.GetSslTargetNameOverride().empty()) {
+ args.SetSslTargetNameOverride(cred.GetSslTargetNameOverride());
+ }
if (!FLAGS_default_service_config.empty()) {
args.SetString(GRPC_ARG_SERVICE_CONFIG,
FLAGS_default_service_config.c_str());
}
return ::grpc::CreateCustomChannel(server_address, cred.GetCredentials(),
args);
-}
-
+}
+
struct Command {
const char* command;
std::function<bool(GrpcTool*, int, const char**, const CliCredentials&,
@@ -255,7 +255,7 @@ const Command ops[] = {
{"parse", BindWith5Args(&GrpcTool::ParseMessage), 2, 3},
{"totext", BindWith5Args(&GrpcTool::ToText), 2, 3},
{"tobinary", BindWith5Args(&GrpcTool::ToBinary), 2, 3},
- {"tojson", BindWith5Args(&GrpcTool::ToJson), 2, 3},
+ {"tojson", BindWith5Args(&GrpcTool::ToJson), 2, 3},
};
void Usage(const TString& msg) {
@@ -267,7 +267,7 @@ void Usage(const TString& msg) {
" grpc_cli type ... ; Print type\n"
" grpc_cli parse ... ; Parse message\n"
" grpc_cli totext ... ; Convert binary message to text\n"
- " grpc_cli tojson ... ; Convert binary message to json\n"
+ " grpc_cli tojson ... ; Convert binary message to json\n"
" grpc_cli tobinary ... ; Convert text message to binary\n"
" grpc_cli help ... ; Print this message, or per-command usage\n"
"\n",
@@ -357,7 +357,7 @@ bool GrpcTool::ListServices(int argc, const char** argv,
TString server_address(argv[0]);
std::shared_ptr<grpc::Channel> channel =
- CreateCliChannel(server_address, cred);
+ CreateCliChannel(server_address, cred);
grpc::ProtoReflectionDescriptorDatabase desc_db(channel);
grpc::protobuf::DescriptorPool desc_pool(&desc_db);
@@ -455,7 +455,7 @@ bool GrpcTool::PrintType(int /*argc*/, const char** argv,
TString server_address(argv[0]);
std::shared_ptr<grpc::Channel> channel =
- CreateCliChannel(server_address, cred);
+ CreateCliChannel(server_address, cred);
grpc::ProtoReflectionDescriptorDatabase desc_db(channel);
grpc::protobuf::DescriptorPool desc_pool(&desc_db);
@@ -491,8 +491,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
" --infile ; Input filename (defaults to stdin)\n"
" --outfile ; Output filename (defaults to stdout)\n"
" --binary_input ; Input in binary format\n"
- " --binary_output ; Output in binary format\n"
- " --json_input ; Input in json format\n"
+ " --binary_output ; Output in binary format\n"
+ " --json_input ; Input in json format\n"
" --json_output ; Output in json format\n"
" --timeout ; Specify timeout (in seconds), used to "
"set the deadline for RPCs. The default value of -1 means no "
@@ -511,28 +511,28 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
bool print_mode = false;
std::shared_ptr<grpc::Channel> channel =
- CreateCliChannel(server_address, cred);
+ CreateCliChannel(server_address, cred);
- if (!FLAGS_binary_input || !FLAGS_binary_output) {
- parser.reset(
- new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
+ if (!FLAGS_binary_input || !FLAGS_binary_output) {
+ parser.reset(
+ new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
FLAGS_proto_path.c_str(), FLAGS_protofiles.c_str()));
- if (parser->HasError()) {
- fprintf(
- stderr,
- "Failed to find remote reflection service and local proto files.\n");
- return false;
- }
- }
+ if (parser->HasError()) {
+ fprintf(
+ stderr,
+ "Failed to find remote reflection service and local proto files.\n");
+ return false;
+ }
+ }
if (FLAGS_binary_input) {
formatted_method_name = method_name;
} else {
formatted_method_name = parser->GetFormattedMethodName(method_name);
- if (parser->HasError()) {
- fprintf(stderr, "Failed to find method %s in proto files.\n",
- method_name.c_str());
- }
+ if (parser->HasError()) {
+ fprintf(stderr, "Failed to find method %s in proto files.\n",
+ method_name.c_str());
+ }
}
if (argc == 3) {
@@ -585,8 +585,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
} else {
gpr_mu_lock(&parser_mu);
serialized_request_proto = parser->GetSerializedProtoFromMethod(
- method_name, request_text, true /* is_request */,
- FLAGS_json_input);
+ method_name, request_text, true /* is_request */,
+ FLAGS_json_input);
request_text.clear();
if (parser->HasError()) {
if (print_mode) {
@@ -671,8 +671,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
request_text.clear();
} else {
serialized_request_proto = parser->GetSerializedProtoFromMethod(
- method_name, request_text, true /* is_request */,
- FLAGS_json_input);
+ method_name, request_text, true /* is_request */,
+ FLAGS_json_input);
request_text.clear();
if (parser->HasError()) {
if (print_mode) {
@@ -716,8 +716,8 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
} else {
TString response_text = parser->GetFormattedStringFromMethod(
method_name, serialized_response_proto,
- false /* is_request */, FLAGS_json_output);
-
+ false /* is_request */, FLAGS_json_output);
+
if (parser->HasError() && print_mode) {
fprintf(stderr, "Failed to parse response.\n");
} else {
@@ -774,9 +774,9 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
serialized_request_proto = request_text;
} else {
serialized_request_proto = parser->GetSerializedProtoFromMethod(
- method_name, request_text, true /* is_request */, FLAGS_json_input);
+ method_name, request_text, true /* is_request */, FLAGS_json_input);
if (parser->HasError()) {
- fprintf(stderr, "Failed to parse request.\n");
+ fprintf(stderr, "Failed to parse request.\n");
return false;
}
}
@@ -802,15 +802,15 @@ bool GrpcTool::CallMethod(int argc, const char** argv,
receive_initial_metadata ? &server_initial_metadata : nullptr);
receive_initial_metadata = false) {
if (!FLAGS_binary_output) {
- serialized_response_proto = parser->GetFormattedStringFromMethod(
- method_name, serialized_response_proto, false /* is_request */,
- FLAGS_json_output);
+ serialized_response_proto = parser->GetFormattedStringFromMethod(
+ method_name, serialized_response_proto, false /* is_request */,
+ FLAGS_json_output);
if (parser->HasError()) {
- fprintf(stderr, "Failed to parse response.\n");
+ fprintf(stderr, "Failed to parse response.\n");
return false;
}
}
-
+
if (receive_initial_metadata) {
PrintMetadata(server_initial_metadata,
"Received initial metadata from server:");
@@ -852,9 +852,9 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
" --infile ; Input filename (defaults to stdin)\n"
" --outfile ; Output filename (defaults to stdout)\n"
" --binary_input ; Input in binary format\n"
- " --binary_output ; Output in binary format\n"
- " --json_input ; Input in json format\n"
- " --json_output ; Output in json format\n" +
+ " --binary_output ; Output in binary format\n"
+ " --json_input ; Input in json format\n"
+ " --json_output ; Output in json format\n" +
cred.GetCredentialUsage());
std::stringstream output_ss;
@@ -886,14 +886,14 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
if (!FLAGS_binary_input || !FLAGS_binary_output) {
std::shared_ptr<grpc::Channel> channel =
- CreateCliChannel(server_address, cred);
+ CreateCliChannel(server_address, cred);
parser.reset(
new grpc::testing::ProtoFileParser(FLAGS_remotedb ? channel : nullptr,
FLAGS_proto_path.c_str(), FLAGS_protofiles.c_str()));
if (parser->HasError()) {
- fprintf(
- stderr,
- "Failed to find remote reflection service and local proto files.\n");
+ fprintf(
+ stderr,
+ "Failed to find remote reflection service and local proto files.\n");
return false;
}
}
@@ -901,10 +901,10 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
if (FLAGS_binary_input) {
serialized_request_proto = message_text;
} else {
- serialized_request_proto = parser->GetSerializedProtoFromMessageType(
- type_name, message_text, FLAGS_json_input);
+ serialized_request_proto = parser->GetSerializedProtoFromMessageType(
+ type_name, message_text, FLAGS_json_input);
if (parser->HasError()) {
- fprintf(stderr, "Failed to serialize the message.\n");
+ fprintf(stderr, "Failed to serialize the message.\n");
return false;
}
}
@@ -913,13 +913,13 @@ bool GrpcTool::ParseMessage(int argc, const char** argv,
output_ss << serialized_request_proto;
} else {
TString output_text;
- output_text = parser->GetFormattedStringFromMessageType(
- type_name, serialized_request_proto, FLAGS_json_output);
+ output_text = parser->GetFormattedStringFromMessageType(
+ type_name, serialized_request_proto, FLAGS_json_output);
if (parser->HasError()) {
- fprintf(stderr, "Failed to deserialize the message.\n");
+ fprintf(stderr, "Failed to deserialize the message.\n");
return false;
}
-
+
output_ss << output_text << std::endl;
}
@@ -944,25 +944,25 @@ bool GrpcTool::ToText(int argc, const char** argv, const CliCredentials& cred,
return ParseMessage(argc, argv, cred, callback);
}
-bool GrpcTool::ToJson(int argc, const char** argv, const CliCredentials& cred,
- GrpcToolOutputCallback callback) {
- CommandUsage(
- "Convert binary message to json\n"
- " grpc_cli tojson <protofiles> <type>\n"
- " <protofiles> ; Comma separated list of proto files\n"
- " <type> ; Protocol buffer type name\n"
- " --proto_path ; The search path of proto files\n"
- " --infile ; Input filename (defaults to stdin)\n"
- " --outfile ; Output filename (defaults to stdout)\n");
-
- FLAGS_protofiles = argv[0];
- FLAGS_remotedb = false;
- FLAGS_binary_input = true;
- FLAGS_binary_output = false;
- FLAGS_json_output = true;
- return ParseMessage(argc, argv, cred, callback);
-}
-
+bool GrpcTool::ToJson(int argc, const char** argv, const CliCredentials& cred,
+ GrpcToolOutputCallback callback) {
+ CommandUsage(
+ "Convert binary message to json\n"
+ " grpc_cli tojson <protofiles> <type>\n"
+ " <protofiles> ; Comma separated list of proto files\n"
+ " <type> ; Protocol buffer type name\n"
+ " --proto_path ; The search path of proto files\n"
+ " --infile ; Input filename (defaults to stdin)\n"
+ " --outfile ; Output filename (defaults to stdout)\n");
+
+ FLAGS_protofiles = argv[0];
+ FLAGS_remotedb = false;
+ FLAGS_binary_input = true;
+ FLAGS_binary_output = false;
+ FLAGS_json_output = true;
+ return ParseMessage(argc, argv, cred, callback);
+}
+
bool GrpcTool::ToBinary(int argc, const char** argv, const CliCredentials& cred,
GrpcToolOutputCallback callback) {
CommandUsage(
diff --git a/contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc b/contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc
index 1b217226cd..ff610daadd 100644
--- a/contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc
+++ b/contrib/libs/grpc/test/cpp/util/grpc_tool_test.cc
@@ -57,7 +57,7 @@ using grpc::testing::EchoResponse;
"Echo2\n" \
"CheckDeadlineUpperBound\n" \
"CheckDeadlineSet\n" \
- "CheckClientInitialMetadata\n" \
+ "CheckClientInitialMetadata\n" \
"RequestStream\n" \
"ResponseStream\n" \
"BidiStream\n" \
@@ -94,32 +94,32 @@ using grpc::testing::EchoResponse;
" rpc Echo(grpc.testing.EchoRequest) returns (grpc.testing.EchoResponse) " \
"{}\n"
-#define ECHO_RESPONSE_MESSAGE_TEXT_FORMAT \
- "message: \"echo\"\n" \
- "param {\n" \
- " host: \"localhost\"\n" \
- " peer: \"peer\"\n" \
+#define ECHO_RESPONSE_MESSAGE_TEXT_FORMAT \
+ "message: \"echo\"\n" \
+ "param {\n" \
+ " host: \"localhost\"\n" \
+ " peer: \"peer\"\n" \
"}\n\n"
-#define ECHO_RESPONSE_MESSAGE_JSON_FORMAT \
- "{\n" \
- " \"message\": \"echo\",\n" \
- " \"param\": {\n" \
- " \"host\": \"localhost\",\n" \
- " \"peer\": \"peer\"\n" \
- " }\n" \
- "}\n\n"
-
-DECLARE_string(channel_creds_type);
-DECLARE_string(ssl_target);
-
+#define ECHO_RESPONSE_MESSAGE_JSON_FORMAT \
+ "{\n" \
+ " \"message\": \"echo\",\n" \
+ " \"param\": {\n" \
+ " \"host\": \"localhost\",\n" \
+ " \"peer\": \"peer\"\n" \
+ " }\n" \
+ "}\n\n"
+
+DECLARE_string(channel_creds_type);
+DECLARE_string(ssl_target);
+
namespace grpc {
namespace testing {
DECLARE_bool(binary_input);
DECLARE_bool(binary_output);
-DECLARE_bool(json_input);
-DECLARE_bool(json_output);
+DECLARE_bool(json_input);
+DECLARE_bool(json_output);
DECLARE_bool(l);
DECLARE_bool(batch);
DECLARE_string(metadata);
@@ -134,27 +134,27 @@ const int kServerDefaultResponseStreamsToSend = 3;
class TestCliCredentials final : public grpc::testing::CliCredentials {
public:
- TestCliCredentials(bool secure = false) : secure_(secure) {}
- std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials()
- const override {
- if (!secure_) {
- return InsecureChannelCredentials();
- }
+ TestCliCredentials(bool secure = false) : secure_(secure) {}
+ std::shared_ptr<grpc::ChannelCredentials> GetChannelCredentials()
+ const override {
+ if (!secure_) {
+ return InsecureChannelCredentials();
+ }
grpc_slice ca_slice;
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(CA_CERT_PATH, 1, &ca_slice)));
const char* test_root_cert =
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(ca_slice);
- SslCredentialsOptions ssl_opts = {test_root_cert, "", ""};
+ SslCredentialsOptions ssl_opts = {test_root_cert, "", ""};
std::shared_ptr<grpc::ChannelCredentials> credential_ptr =
grpc::SslCredentials(grpc::SslCredentialsOptions(ssl_opts));
grpc_slice_unref(ca_slice);
return credential_ptr;
}
const TString GetCredentialUsage() const override { return ""; }
-
- private:
- const bool secure_;
+
+ private:
+ const bool secure_;
};
bool PrintStream(std::stringstream* ss, const TString& output) {
@@ -289,7 +289,7 @@ class GrpcToolTest : public ::testing::Test {
server_address << "localhost:" << port;
// Setup server
ServerBuilder builder;
- std::shared_ptr<grpc::ServerCredentials> creds;
+ std::shared_ptr<grpc::ServerCredentials> creds;
grpc_slice cert_slice, key_slice;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file", grpc_load_file(SERVER_CERT_PATH, 1, &cert_slice)));
@@ -301,15 +301,15 @@ class GrpcToolTest : public ::testing::Test {
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice);
SslServerCredentialsOptions::PemKeyCertPair pkcp = {server_key,
server_cert};
- if (secure) {
- SslServerCredentialsOptions ssl_opts;
- ssl_opts.pem_root_certs = "";
- ssl_opts.pem_key_cert_pairs.push_back(pkcp);
- creds = SslServerCredentials(ssl_opts);
- } else {
- creds = InsecureServerCredentials();
- }
- builder.AddListeningPort(server_address.str(), creds);
+ if (secure) {
+ SslServerCredentialsOptions ssl_opts;
+ ssl_opts.pem_root_certs = "";
+ ssl_opts.pem_key_cert_pairs.push_back(pkcp);
+ creds = SslServerCredentials(ssl_opts);
+ } else {
+ creds = InsecureServerCredentials();
+ }
+ builder.AddListeningPort(server_address.str(), creds);
builder.RegisterService(&service_);
server_ = builder.BuildAndStart();
grpc_slice_unref(cert_slice);
@@ -491,64 +491,64 @@ TEST_F(GrpcToolTest, CallCommand) {
// Expected output: "message: \"Hello\""
EXPECT_TRUE(nullptr !=
strstr(output_stream.str().c_str(), "message: \"Hello\""));
-
- // with json_output
+
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
-
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
-
- // Expected output:
- // {
- // "message": "Hello"
- // }
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "{\n \"message\": \"Hello\"\n}"));
-
+ output_stream.clear();
+
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+
+ // Expected output:
+ // {
+ // "message": "Hello"
+ // }
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "{\n \"message\": \"Hello\"\n}"));
+
ShutdownServer();
}
-TEST_F(GrpcToolTest, CallCommandJsonInput) {
- // Test input "grpc_cli call localhost:<port> Echo "{ \"message\": \"Hello\"}"
- std::stringstream output_stream;
-
+TEST_F(GrpcToolTest, CallCommandJsonInput) {
+ // Test input "grpc_cli call localhost:<port> Echo "{ \"message\": \"Hello\"}"
+ std::stringstream output_stream;
+
const TString server_address = SetUpServer();
- const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
- "{ \"message\": \"Hello\"}"};
-
- FLAGS_json_input = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- // Expected output: "message: \"Hello\""
- EXPECT_TRUE(nullptr !=
- strstr(output_stream.str().c_str(), "message: \"Hello\""));
-
- // with json_output
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
+ "{ \"message\": \"Hello\"}"};
+
+ FLAGS_json_input = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ // Expected output: "message: \"Hello\""
+ EXPECT_TRUE(nullptr !=
+ strstr(output_stream.str().c_str(), "message: \"Hello\""));
+
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
-
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
- FLAGS_json_input = false;
-
- // Expected output:
- // {
- // "message": "Hello"
- // }
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "{\n \"message\": \"Hello\"\n}"));
-
- ShutdownServer();
-}
-
+ output_stream.clear();
+
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+ FLAGS_json_input = false;
+
+ // Expected output:
+ // {
+ // "message": "Hello"
+ // }
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "{\n \"message\": \"Hello\"\n}"));
+
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, CallCommandBatch) {
// Test input "grpc_cli call Echo"
std::stringstream output_stream;
@@ -573,105 +573,105 @@ TEST_F(GrpcToolTest, CallCommandBatch) {
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
"message: \"Hello0\"\nmessage: "
"\"Hello1\"\nmessage: \"Hello2\"\n"));
- // with json_output
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
- ss.clear();
- ss.seekg(0);
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_batch = true;
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
- FLAGS_batch = false;
-
- // Expected output:
- // {
- // "message": "Hello0"
- // }
- // {
- // "message": "Hello1"
- // }
- // {
- // "message": "Hello2"
- // }
- // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
- // "Hello2"\n"
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "{\n \"message\": \"Hello0\"\n}\n"
- "{\n \"message\": \"Hello1\"\n}\n"
- "{\n \"message\": \"Hello2\"\n}\n"));
-
+ output_stream.clear();
+ ss.clear();
+ ss.seekg(0);
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_batch = true;
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+ FLAGS_batch = false;
+
+ // Expected output:
+ // {
+ // "message": "Hello0"
+ // }
+ // {
+ // "message": "Hello1"
+ // }
+ // {
+ // "message": "Hello2"
+ // }
+ // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
+ // "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "{\n \"message\": \"Hello0\"\n}\n"
+ "{\n \"message\": \"Hello1\"\n}\n"
+ "{\n \"message\": \"Hello2\"\n}\n"));
+
std::cin.rdbuf(orig);
ShutdownServer();
}
-TEST_F(GrpcToolTest, CallCommandBatchJsonInput) {
- // Test input "grpc_cli call Echo"
- std::stringstream output_stream;
-
+TEST_F(GrpcToolTest, CallCommandBatchJsonInput) {
+ // Test input "grpc_cli call Echo"
+ std::stringstream output_stream;
+
const TString server_address = SetUpServer();
- const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
- "{\"message\": \"Hello0\"}"};
-
- // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n"
- std::streambuf* orig = std::cin.rdbuf();
- std::istringstream ss(
- "{\"message\": \"Hello1\"}\n\n{\"message\": \"Hello2\" }\n\n");
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_json_input = true;
- FLAGS_batch = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_batch = false;
-
- // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
- // "Hello2"\n"
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "message: \"Hello0\"\nmessage: "
- "\"Hello1\"\nmessage: \"Hello2\"\n"));
- // with json_output
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
+ "{\"message\": \"Hello0\"}"};
+
+ // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n"
+ std::streambuf* orig = std::cin.rdbuf();
+ std::istringstream ss(
+ "{\"message\": \"Hello1\"}\n\n{\"message\": \"Hello2\" }\n\n");
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_json_input = true;
+ FLAGS_batch = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_batch = false;
+
+ // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
+ // "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0\"\nmessage: "
+ "\"Hello1\"\nmessage: \"Hello2\"\n"));
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
- ss.clear();
- ss.seekg(0);
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_batch = true;
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
- FLAGS_batch = false;
- FLAGS_json_input = false;
-
- // Expected output:
- // {
- // "message": "Hello0"
- // }
- // {
- // "message": "Hello1"
- // }
- // {
- // "message": "Hello2"
- // }
- // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
- // "Hello2"\n"
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "{\n \"message\": \"Hello0\"\n}\n"
- "{\n \"message\": \"Hello1\"\n}\n"
- "{\n \"message\": \"Hello2\"\n}\n"));
-
- std::cin.rdbuf(orig);
- ShutdownServer();
-}
-
+ output_stream.clear();
+ ss.clear();
+ ss.seekg(0);
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_batch = true;
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+ FLAGS_batch = false;
+ FLAGS_json_input = false;
+
+ // Expected output:
+ // {
+ // "message": "Hello0"
+ // }
+ // {
+ // "message": "Hello1"
+ // }
+ // {
+ // "message": "Hello2"
+ // }
+ // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
+ // "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "{\n \"message\": \"Hello0\"\n}\n"
+ "{\n \"message\": \"Hello1\"\n}\n"
+ "{\n \"message\": \"Hello2\"\n}\n"));
+
+ std::cin.rdbuf(orig);
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) {
// Test input "grpc_cli call Echo"
std::stringstream output_stream;
@@ -694,99 +694,99 @@ TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) {
// Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
"message: \"Hello0\"\nmessage: \"Hello2\"\n"));
-
- // with json_output
+
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
- ss.clear();
- ss.seekg(0);
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_batch = true;
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
- FLAGS_batch = false;
-
- // Expected output:
- // {
- // "message": "Hello0"
- // }
- // {
- // "message": "Hello2"
- // }
- // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
- // "Hello2"\n"
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "{\n \"message\": \"Hello0\"\n}\n"
- "{\n \"message\": \"Hello2\"\n}\n"));
-
+ output_stream.clear();
+ ss.clear();
+ ss.seekg(0);
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_batch = true;
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+ FLAGS_batch = false;
+
+ // Expected output:
+ // {
+ // "message": "Hello0"
+ // }
+ // {
+ // "message": "Hello2"
+ // }
+ // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
+ // "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "{\n \"message\": \"Hello0\"\n}\n"
+ "{\n \"message\": \"Hello2\"\n}\n"));
+
std::cin.rdbuf(orig);
ShutdownServer();
}
-TEST_F(GrpcToolTest, CallCommandBatchJsonInputWithBadRequest) {
- // Test input "grpc_cli call Echo"
- std::stringstream output_stream;
-
+TEST_F(GrpcToolTest, CallCommandBatchJsonInputWithBadRequest) {
+ // Test input "grpc_cli call Echo"
+ std::stringstream output_stream;
+
const TString server_address = SetUpServer();
- const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
- "{ \"message\": \"Hello0\"}"};
-
- // Mock std::cin input "message: 1\n\n message: 'Hello2'\n\n"
- std::streambuf* orig = std::cin.rdbuf();
- std::istringstream ss(
- "{ \"message\": 1 }\n\n { \"message\": \"Hello2\" }\n\n");
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_batch = true;
- FLAGS_json_input = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_input = false;
- FLAGS_batch = false;
-
- // Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "message: \"Hello0\"\nmessage: \"Hello2\"\n"));
-
- // with json_output
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(), "Echo",
+ "{ \"message\": \"Hello0\"}"};
+
+ // Mock std::cin input "message: 1\n\n message: 'Hello2'\n\n"
+ std::streambuf* orig = std::cin.rdbuf();
+ std::istringstream ss(
+ "{ \"message\": 1 }\n\n { \"message\": \"Hello2\" }\n\n");
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_batch = true;
+ FLAGS_json_input = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_input = false;
+ FLAGS_batch = false;
+
+ // Expected output: "message: "Hello0"\nmessage: "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0\"\nmessage: \"Hello2\"\n"));
+
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
- ss.clear();
- ss.seekg(0);
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_batch = true;
- FLAGS_json_input = true;
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
- FLAGS_json_input = false;
- FLAGS_batch = false;
-
- // Expected output:
- // {
- // "message": "Hello0"
- // }
- // {
- // "message": "Hello2"
- // }
- // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
- // "Hello2"\n"
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "{\n \"message\": \"Hello0\"\n}\n"
- "{\n \"message\": \"Hello2\"\n}\n"));
-
- std::cin.rdbuf(orig);
- ShutdownServer();
-}
-
+ output_stream.clear();
+ ss.clear();
+ ss.seekg(0);
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_batch = true;
+ FLAGS_json_input = true;
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+ FLAGS_json_input = false;
+ FLAGS_batch = false;
+
+ // Expected output:
+ // {
+ // "message": "Hello0"
+ // }
+ // {
+ // "message": "Hello2"
+ // }
+ // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
+ // "Hello2"\n"
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "{\n \"message\": \"Hello0\"\n}\n"
+ "{\n \"message\": \"Hello2\"\n}\n"));
+
+ std::cin.rdbuf(orig);
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, CallCommandRequestStream) {
// Test input: grpc_cli call localhost:<port> RequestStream "message:
// 'Hello0'"
@@ -812,34 +812,34 @@ TEST_F(GrpcToolTest, CallCommandRequestStream) {
ShutdownServer();
}
-TEST_F(GrpcToolTest, CallCommandRequestStreamJsonInput) {
- // Test input: grpc_cli call localhost:<port> RequestStream "{ \"message\":
- // \"Hello0\"}"
- std::stringstream output_stream;
-
+TEST_F(GrpcToolTest, CallCommandRequestStreamJsonInput) {
+ // Test input: grpc_cli call localhost:<port> RequestStream "{ \"message\":
+ // \"Hello0\"}"
+ std::stringstream output_stream;
+
const TString server_address = SetUpServer();
- const char* argv[] = {"grpc_cli", "call", server_address.c_str(),
- "RequestStream", "{ \"message\": \"Hello0\" }"};
-
- // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n"
- std::streambuf* orig = std::cin.rdbuf();
- std::istringstream ss(
- "{ \"message\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n");
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_json_input = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_input = false;
-
- // Expected output: "message: \"Hello0Hello1Hello2\""
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- "message: \"Hello0Hello1Hello2\""));
- std::cin.rdbuf(orig);
- ShutdownServer();
-}
-
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(),
+ "RequestStream", "{ \"message\": \"Hello0\" }"};
+
+ // Mock std::cin input "message: 'Hello1'\n\n message: 'Hello2'\n\n"
+ std::streambuf* orig = std::cin.rdbuf();
+ std::istringstream ss(
+ "{ \"message\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n");
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_json_input = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_input = false;
+
+ // Expected output: "message: \"Hello0Hello1Hello2\""
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ "message: \"Hello0Hello1Hello2\""));
+ std::cin.rdbuf(orig);
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequest) {
// Test input: grpc_cli call localhost:<port> RequestStream "message:
// 'Hello0'"
@@ -865,34 +865,34 @@ TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequest) {
ShutdownServer();
}
-TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequestJsonInput) {
- // Test input: grpc_cli call localhost:<port> RequestStream "message:
- // 'Hello0'"
- std::stringstream output_stream;
-
+TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequestJsonInput) {
+ // Test input: grpc_cli call localhost:<port> RequestStream "message:
+ // 'Hello0'"
+ std::stringstream output_stream;
+
const TString server_address = SetUpServer();
- const char* argv[] = {"grpc_cli", "call", server_address.c_str(),
- "RequestStream", "{ \"message\": \"Hello0\" }"};
-
- // Mock std::cin input "bad_field: 'Hello1'\n\n message: 'Hello2'\n\n"
- std::streambuf* orig = std::cin.rdbuf();
- std::istringstream ss(
- "{ \"bad_field\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n");
- std::cin.rdbuf(ss.rdbuf());
-
- FLAGS_json_input = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_input = false;
-
- // Expected output: "message: \"Hello0Hello2\""
- EXPECT_TRUE(nullptr !=
- strstr(output_stream.str().c_str(), "message: \"Hello0Hello2\""));
- std::cin.rdbuf(orig);
- ShutdownServer();
-}
-
+ const char* argv[] = {"grpc_cli", "call", server_address.c_str(),
+ "RequestStream", "{ \"message\": \"Hello0\" }"};
+
+ // Mock std::cin input "bad_field: 'Hello1'\n\n message: 'Hello2'\n\n"
+ std::streambuf* orig = std::cin.rdbuf();
+ std::istringstream ss(
+ "{ \"bad_field\": \"Hello1\" }\n\n{ \"message\": \"Hello2\" }\n\n");
+ std::cin.rdbuf(ss.rdbuf());
+
+ FLAGS_json_input = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_input = false;
+
+ // Expected output: "message: \"Hello0Hello2\""
+ EXPECT_TRUE(nullptr !=
+ strstr(output_stream.str().c_str(), "message: \"Hello0Hello2\""));
+ std::cin.rdbuf(orig);
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, CallCommandWithTimeoutDeadlineSet) {
// Test input "grpc_cli call CheckDeadlineSet --timeout=5000.25"
std::stringstream output_stream;
@@ -1001,24 +1001,24 @@ TEST_F(GrpcToolTest, CallCommandResponseStream) {
expected_response_text.c_str()));
}
- // with json_output
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
-
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
-
- // Expected output: "{\n \"message\": \"Hello{n}\"\n}\n"
- for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) {
+ output_stream.clear();
+
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+
+ // Expected output: "{\n \"message\": \"Hello{n}\"\n}\n"
+ for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) {
TString expected_response_text =
"{\n \"message\": \"Hello" + ToString(i) + "\"\n}\n";
- EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
- expected_response_text.c_str()));
- }
-
+ EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(),
+ expected_response_text.c_str()));
+ }
+
ShutdownServer();
}
@@ -1082,32 +1082,32 @@ TEST_F(GrpcToolTest, ParseCommand) {
const TString server_address = SetUpServer();
const char* argv[] = {"grpc_cli", "parse", server_address.c_str(),
- "grpc.testing.EchoResponse",
- ECHO_RESPONSE_MESSAGE_TEXT_FORMAT};
+ "grpc.testing.EchoResponse",
+ ECHO_RESPONSE_MESSAGE_TEXT_FORMAT};
FLAGS_binary_input = false;
FLAGS_binary_output = false;
EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
std::bind(PrintStream, &output_stream,
std::placeholders::_1)));
- // Expected output: ECHO_RESPONSE_MESSAGE_TEXT_FORMAT
- EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
- ECHO_RESPONSE_MESSAGE_TEXT_FORMAT));
+ // Expected output: ECHO_RESPONSE_MESSAGE_TEXT_FORMAT
+ EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
+ ECHO_RESPONSE_MESSAGE_TEXT_FORMAT));
- // with json_output
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
-
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
-
- // Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
- EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
- ECHO_RESPONSE_MESSAGE_JSON_FORMAT));
-
+ output_stream.clear();
+
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+
+ // Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
+ EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
+ ECHO_RESPONSE_MESSAGE_JSON_FORMAT));
+
// Parse text message to binary message and then parse it back to text message
output_stream.str(TString());
output_stream.clear();
@@ -1126,52 +1126,52 @@ TEST_F(GrpcToolTest, ParseCommand) {
std::placeholders::_1)));
// Expected output: ECHO_RESPONSE_MESSAGE
- EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
- ECHO_RESPONSE_MESSAGE_TEXT_FORMAT));
+ EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
+ ECHO_RESPONSE_MESSAGE_TEXT_FORMAT));
FLAGS_binary_input = false;
FLAGS_binary_output = false;
ShutdownServer();
}
-TEST_F(GrpcToolTest, ParseCommandJsonFormat) {
- // Test input "grpc_cli parse localhost:<port> grpc.testing.EchoResponse
- // ECHO_RESPONSE_MESSAGE_JSON_FORMAT"
- std::stringstream output_stream;
- std::stringstream binary_output_stream;
-
+TEST_F(GrpcToolTest, ParseCommandJsonFormat) {
+ // Test input "grpc_cli parse localhost:<port> grpc.testing.EchoResponse
+ // ECHO_RESPONSE_MESSAGE_JSON_FORMAT"
+ std::stringstream output_stream;
+ std::stringstream binary_output_stream;
+
const TString server_address = SetUpServer();
- const char* argv[] = {"grpc_cli", "parse", server_address.c_str(),
- "grpc.testing.EchoResponse",
- ECHO_RESPONSE_MESSAGE_JSON_FORMAT};
-
- FLAGS_json_input = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
-
- // Expected output: ECHO_RESPONSE_MESSAGE_TEXT_FORMAT
- EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
- ECHO_RESPONSE_MESSAGE_TEXT_FORMAT));
-
- // with json_output
+ const char* argv[] = {"grpc_cli", "parse", server_address.c_str(),
+ "grpc.testing.EchoResponse",
+ ECHO_RESPONSE_MESSAGE_JSON_FORMAT};
+
+ FLAGS_json_input = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+
+ // Expected output: ECHO_RESPONSE_MESSAGE_TEXT_FORMAT
+ EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
+ ECHO_RESPONSE_MESSAGE_TEXT_FORMAT));
+
+ // with json_output
output_stream.str(TString());
- output_stream.clear();
-
- FLAGS_json_output = true;
- EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
- std::bind(PrintStream, &output_stream,
- std::placeholders::_1)));
- FLAGS_json_output = false;
- FLAGS_json_input = false;
-
- // Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
- EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
- ECHO_RESPONSE_MESSAGE_JSON_FORMAT));
-
- ShutdownServer();
-}
-
+ output_stream.clear();
+
+ FLAGS_json_output = true;
+ EXPECT_TRUE(0 == GrpcToolMainLib(ArraySize(argv), argv, TestCliCredentials(),
+ std::bind(PrintStream, &output_stream,
+ std::placeholders::_1)));
+ FLAGS_json_output = false;
+ FLAGS_json_input = false;
+
+ // Expected output: ECHO_RESPONSE_MESSAGE_JSON_FORMAT
+ EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
+ ECHO_RESPONSE_MESSAGE_JSON_FORMAT));
+
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, TooFewArguments) {
// Test input "grpc_cli call Echo"
std::stringstream output_stream;
@@ -1288,29 +1288,29 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) {
gpr_free(test_srcdir);
}
-TEST_F(GrpcToolTest, ListCommand_OverrideSslHostName) {
+TEST_F(GrpcToolTest, ListCommand_OverrideSslHostName) {
const TString server_address = SetUpServer(true);
-
- // Test input "grpc_cli ls localhost:<port> --channel_creds_type=ssl
- // --ssl_target=z.test.google.fr"
- std::stringstream output_stream;
- const char* argv[] = {"grpc_cli", "ls", server_address.c_str()};
- FLAGS_l = false;
- FLAGS_channel_creds_type = "ssl";
- FLAGS_ssl_target = "z.test.google.fr";
- EXPECT_TRUE(
- 0 == GrpcToolMainLib(
- ArraySize(argv), argv, TestCliCredentials(true),
- std::bind(PrintStream, &output_stream, std::placeholders::_1)));
- EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
- "grpc.testing.EchoTestService\n"
- "grpc.reflection.v1alpha.ServerReflection\n"));
-
- FLAGS_channel_creds_type = "";
- FLAGS_ssl_target = "";
- ShutdownServer();
-}
-
+
+ // Test input "grpc_cli ls localhost:<port> --channel_creds_type=ssl
+ // --ssl_target=z.test.google.fr"
+ std::stringstream output_stream;
+ const char* argv[] = {"grpc_cli", "ls", server_address.c_str()};
+ FLAGS_l = false;
+ FLAGS_channel_creds_type = "ssl";
+ FLAGS_ssl_target = "z.test.google.fr";
+ EXPECT_TRUE(
+ 0 == GrpcToolMainLib(
+ ArraySize(argv), argv, TestCliCredentials(true),
+ std::bind(PrintStream, &output_stream, std::placeholders::_1)));
+ EXPECT_TRUE(0 == strcmp(output_stream.str().c_str(),
+ "grpc.testing.EchoTestService\n"
+ "grpc.reflection.v1alpha.ServerReflection\n"));
+
+ FLAGS_channel_creds_type = "";
+ FLAGS_ssl_target = "";
+ ShutdownServer();
+}
+
TEST_F(GrpcToolTest, ConfiguringDefaultServiceConfig) {
// Test input "grpc_cli list localhost:<port>
// --default_service_config={\"loadBalancingConfig\":[{\"pick_first\":{}}]}"
@@ -1337,7 +1337,7 @@ TEST_F(GrpcToolTest, ConfiguringDefaultServiceConfig) {
} // namespace grpc
int main(int argc, char** argv) {
- grpc::testing::TestEnvironment env(argc, argv);
+ grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
::testing::FLAGS_gtest_death_test_style = "threadsafe";
return RUN_ALL_TESTS();
diff --git a/contrib/libs/grpc/test/cpp/util/proto_file_parser.cc b/contrib/libs/grpc/test/cpp/util/proto_file_parser.cc
index 4b10c67e97..b0912a712c 100644
--- a/contrib/libs/grpc/test/cpp/util/proto_file_parser.cc
+++ b/contrib/libs/grpc/test/cpp/util/proto_file_parser.cc
@@ -63,7 +63,7 @@ class ErrorPrinter : public protobuf::compiler::MultiFileErrorCollector {
ProtoFileParser* parser_; // not owned
};
-ProtoFileParser::ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
+ProtoFileParser::ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
const TString& proto_path,
const TString& protofiles)
: has_error_(false),
@@ -217,31 +217,31 @@ bool ProtoFileParser::IsStreaming(const TString& method, bool is_request) {
TString ProtoFileParser::GetSerializedProtoFromMethod(
const TString& method, const TString& formatted_proto,
- bool is_request, bool is_json_format) {
+ bool is_request, bool is_json_format) {
has_error_ = false;
TString message_type_name = GetMessageTypeFromMethod(method, is_request);
if (has_error_) {
return "";
}
- return GetSerializedProtoFromMessageType(message_type_name, formatted_proto,
- is_json_format);
+ return GetSerializedProtoFromMessageType(message_type_name, formatted_proto,
+ is_json_format);
}
TString ProtoFileParser::GetFormattedStringFromMethod(
const TString& method, const TString& serialized_proto,
- bool is_request, bool is_json_format) {
+ bool is_request, bool is_json_format) {
has_error_ = false;
TString message_type_name = GetMessageTypeFromMethod(method, is_request);
if (has_error_) {
return "";
}
- return GetFormattedStringFromMessageType(message_type_name, serialized_proto,
- is_json_format);
+ return GetFormattedStringFromMessageType(message_type_name, serialized_proto,
+ is_json_format);
}
TString ProtoFileParser::GetSerializedProtoFromMessageType(
const TString& message_type_name, const TString& formatted_proto,
- bool is_json_format) {
+ bool is_json_format) {
has_error_ = false;
google::protobuf::string serialized;
const protobuf::Descriptor* desc =
@@ -252,22 +252,22 @@ TString ProtoFileParser::GetSerializedProtoFromMessageType(
}
std::unique_ptr<grpc::protobuf::Message> msg(
dynamic_factory_->GetPrototype(desc)->New());
- bool ok;
- if (is_json_format) {
- ok = grpc::protobuf::json::JsonStringToMessage(google::protobuf::string(formatted_proto), msg.get())
- .ok();
- if (!ok) {
- LogError("Failed to convert json format to proto.");
- return "";
- }
- } else {
- ok = protobuf::TextFormat::ParseFromString(google::protobuf::string(formatted_proto), msg.get());
- if (!ok) {
- LogError("Failed to convert text format to proto.");
- return "";
- }
+ bool ok;
+ if (is_json_format) {
+ ok = grpc::protobuf::json::JsonStringToMessage(google::protobuf::string(formatted_proto), msg.get())
+ .ok();
+ if (!ok) {
+ LogError("Failed to convert json format to proto.");
+ return "";
+ }
+ } else {
+ ok = protobuf::TextFormat::ParseFromString(google::protobuf::string(formatted_proto), msg.get());
+ if (!ok) {
+ LogError("Failed to convert text format to proto.");
+ return "";
+ }
}
-
+
ok = msg->SerializeToString(&serialized);
if (!ok) {
LogError("Failed to serialize proto.");
@@ -278,7 +278,7 @@ TString ProtoFileParser::GetSerializedProtoFromMessageType(
TString ProtoFileParser::GetFormattedStringFromMessageType(
const TString& message_type_name, const TString& serialized_proto,
- bool is_json_format) {
+ bool is_json_format) {
has_error_ = false;
const protobuf::Descriptor* desc =
desc_pool_->FindMessageTypeByName(google::protobuf::string(message_type_name));
@@ -292,24 +292,24 @@ TString ProtoFileParser::GetFormattedStringFromMessageType(
LogError("Failed to deserialize proto.");
return "";
}
- google::protobuf::string formatted_string;
-
- if (is_json_format) {
- grpc::protobuf::json::JsonPrintOptions jsonPrintOptions;
- jsonPrintOptions.add_whitespace = true;
- if (!grpc::protobuf::json::MessageToJsonString(
- *msg.get(), &formatted_string, jsonPrintOptions)
- .ok()) {
- LogError("Failed to print proto message to json format");
- return "";
- }
- } else {
- if (!protobuf::TextFormat::PrintToString(*msg.get(), &formatted_string)) {
- LogError("Failed to print proto message to text format");
- return "";
- }
+ google::protobuf::string formatted_string;
+
+ if (is_json_format) {
+ grpc::protobuf::json::JsonPrintOptions jsonPrintOptions;
+ jsonPrintOptions.add_whitespace = true;
+ if (!grpc::protobuf::json::MessageToJsonString(
+ *msg.get(), &formatted_string, jsonPrintOptions)
+ .ok()) {
+ LogError("Failed to print proto message to json format");
+ return "";
+ }
+ } else {
+ if (!protobuf::TextFormat::PrintToString(*msg.get(), &formatted_string)) {
+ LogError("Failed to print proto message to text format");
+ return "";
+ }
}
- return formatted_string;
+ return formatted_string;
}
void ProtoFileParser::LogError(const TString& error_msg) {
diff --git a/contrib/libs/grpc/test/cpp/util/proto_file_parser.h b/contrib/libs/grpc/test/cpp/util/proto_file_parser.h
index d482f9c3de..c0445641c7 100644
--- a/contrib/libs/grpc/test/cpp/util/proto_file_parser.h
+++ b/contrib/libs/grpc/test/cpp/util/proto_file_parser.h
@@ -36,7 +36,7 @@ class ProtoFileParser {
// The parser will search proto files using the server reflection service
// provided on the given channel. The given protofiles in a source tree rooted
// from proto_path will also be searched.
- ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
+ ProtoFileParser(const std::shared_ptr<grpc::Channel>& channel,
const TString& proto_path, const TString& protofiles);
~ProtoFileParser();
@@ -52,47 +52,47 @@ class ProtoFileParser {
// used as the argument of Stub::Call()
TString GetFormattedMethodName(const TString& method);
- /// Converts a text or json string to its binary proto representation for the
- /// given method's input or return type.
- /// \param method the name of the method (does not need to be fully qualified
- /// name)
- /// \param formatted_proto the text- or json-formatted proto string
- /// \param is_request if \c true the resolved type is that of the input
- /// parameter of the method, otherwise it is the output type
- /// \param is_json_format if \c true the \c formatted_proto is treated as a
- /// json-formatted proto, otherwise it is treated as a text-formatted
- /// proto
+ /// Converts a text or json string to its binary proto representation for the
+ /// given method's input or return type.
+ /// \param method the name of the method (does not need to be fully qualified
+ /// name)
+ /// \param formatted_proto the text- or json-formatted proto string
+ /// \param is_request if \c true the resolved type is that of the input
+ /// parameter of the method, otherwise it is the output type
+ /// \param is_json_format if \c true the \c formatted_proto is treated as a
+ /// json-formatted proto, otherwise it is treated as a text-formatted
+ /// proto
/// \return the serialised binary proto representation of \c formatted_proto
TString GetSerializedProtoFromMethod(const TString& method,
const TString& formatted_proto,
bool is_request,
bool is_json_format);
- /// Converts a text or json string to its proto representation for the given
- /// message type.
- /// \param formatted_proto the text- or json-formatted proto string
+ /// Converts a text or json string to its proto representation for the given
+ /// message type.
+ /// \param formatted_proto the text- or json-formatted proto string
/// \return the serialised binary proto representation of \c formatted_proto
TString GetSerializedProtoFromMessageType(
const TString& message_type_name, const TString& formatted_proto,
bool is_json_format);
- /// Converts a binary proto string to its text or json string representation
- /// for the given method's input or return type.
- /// \param method the name of the method (does not need to be a fully
- /// qualified name)
- /// \param the serialised binary proto representation of type
- /// \c message_type_name
- /// \return the text- or json-formatted proto string of \c serialized_proto
+ /// Converts a binary proto string to its text or json string representation
+ /// for the given method's input or return type.
+ /// \param method the name of the method (does not need to be a fully
+ /// qualified name)
+ /// \param the serialised binary proto representation of type
+ /// \c message_type_name
+ /// \return the text- or json-formatted proto string of \c serialized_proto
TString GetFormattedStringFromMethod(const TString& method,
const TString& serialized_proto,
bool is_request,
bool is_json_format);
-
- /// Converts a binary proto string to its text or json string representation
- /// for the given message type.
- /// \param the serialised binary proto representation of type
- /// \c message_type_name
- /// \return the text- or json-formatted proto string of \c serialized_proto
+
+ /// Converts a binary proto string to its text or json string representation
+ /// for the given message type.
+ /// \param the serialised binary proto representation of type
+ /// \c message_type_name
+ /// \return the text- or json-formatted proto string of \c serialized_proto
TString GetFormattedStringFromMessageType(
const TString& message_type_name, const TString& serialized_proto,
bool is_json_format);
diff --git a/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.cc b/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.cc
index 0d4e49224f..27a4c1e4cf 100644
--- a/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.cc
+++ b/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.cc
@@ -35,7 +35,7 @@ ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase(
: stub_(std::move(stub)) {}
ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase(
- const std::shared_ptr<grpc::Channel>& channel)
+ const std::shared_ptr<grpc::Channel>& channel)
: stub_(ServerReflection::NewStub(channel)) {}
ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() {
@@ -82,7 +82,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse& error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)",
filename.c_str());
@@ -129,7 +129,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse& error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
missing_symbols_.insert(symbol_name);
gpr_log(GPR_INFO,
@@ -185,7 +185,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
AddFileFromResponse(response.file_descriptor_response());
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse& error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
if (missing_extensions_.find(containing_type) ==
missing_extensions_.end()) {
@@ -241,7 +241,7 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers(
return true;
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse& error = response.error_response();
+ const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)",
extendee_type.c_str());
@@ -268,14 +268,14 @@ bool ProtoReflectionDescriptorDatabase::GetServices(
if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kListServicesResponse) {
- const ListServiceResponse& ls_response = response.list_services_response();
+ const ListServiceResponse& ls_response = response.list_services_response();
for (int i = 0; i < ls_response.service_size(); ++i) {
(*output).push_back(ls_response.service(i).name());
}
return true;
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
- const ErrorResponse& error = response.error_response();
+ const ErrorResponse& error = response.error_response();
gpr_log(GPR_INFO,
"Error on GetServices()\n\tError code: %d\n"
"\tError Message: %s",
diff --git a/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.h b/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.h
index bdc905cbb9..cdd6f0cccd 100644
--- a/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.h
+++ b/contrib/libs/grpc/test/cpp/util/proto_reflection_descriptor_database.h
@@ -38,7 +38,7 @@ class ProtoReflectionDescriptorDatabase : public protobuf::DescriptorDatabase {
std::unique_ptr<reflection::v1alpha::ServerReflection::Stub> stub);
explicit ProtoReflectionDescriptorDatabase(
- const std::shared_ptr<grpc::Channel>& channel);
+ const std::shared_ptr<grpc::Channel>& channel);
virtual ~ProtoReflectionDescriptorDatabase();
diff --git a/contrib/libs/grpc/test/cpp/util/string_ref_test.cc b/contrib/libs/grpc/test/cpp/util/string_ref_test.cc
index cb8b545379..8e3259b764 100644
--- a/contrib/libs/grpc/test/cpp/util/string_ref_test.cc
+++ b/contrib/libs/grpc/test/cpp/util/string_ref_test.cc
@@ -62,7 +62,7 @@ TEST_F(StringRefTest, FromString) {
TEST_F(StringRefTest, CopyConstructor) {
string_ref s1(kTestString);
;
- const string_ref& s2(s1);
+ const string_ref& s2(s1);
EXPECT_EQ(s1.length(), s2.length());
EXPECT_EQ(s1.data(), s2.data());
}
diff --git a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc b/contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc
index baac88eb52..f7134b773f 100644
--- a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc
+++ b/contrib/libs/grpc/test/cpp/util/test_credentials_provider.cc
@@ -93,8 +93,8 @@ class DefaultCredentialsProvider : public CredentialsProvider {
SslCredentialsOptions ssl_opts = {test_root_cert, "", ""};
args->SetSslTargetNameOverride("foo.test.google.fr");
return grpc::SslCredentials(ssl_opts);
- } else if (type == grpc::testing::kGoogleDefaultCredentialsType) {
- return grpc::GoogleDefaultCredentials();
+ } else if (type == grpc::testing::kGoogleDefaultCredentialsType) {
+ return grpc::GoogleDefaultCredentials();
} else {
std::unique_lock<std::mutex> lock(mu_);
auto it(std::find(added_secure_type_names_.begin(),
diff --git a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.h b/contrib/libs/grpc/test/cpp/util/test_credentials_provider.h
index d29814f764..acba277ada 100644
--- a/contrib/libs/grpc/test/cpp/util/test_credentials_provider.h
+++ b/contrib/libs/grpc/test/cpp/util/test_credentials_provider.h
@@ -33,7 +33,7 @@ const char kInsecureCredentialsType[] = "INSECURE_CREDENTIALS";
// property "transport_security_type".
const char kTlsCredentialsType[] = "ssl";
const char kAltsCredentialsType[] = "alts";
-const char kGoogleDefaultCredentialsType[] = "google_default_credentials";
+const char kGoogleDefaultCredentialsType[] = "google_default_credentials";
// Provide test credentials of a particular type.
class CredentialTypeProvider {