Copilot commented on code in PR #3664:
URL: https://github.com/apache/brpc/pull/3664#discussion_r4373564037
##########
test/brpc_builtin_service_unittest.cpp:
##########
@@ -259,7 +259,20 @@ class BuiltinServiceTest : public ::testing::Test{
service.default_method(&cntl, &req, &res, &done);
EXPECT_FALSE(cntl.Failed());
EXPECT_EQ(expect_type, cntl.http_response().content_type());
- CheckContent(cntl, buf);
+ if (brpc::FLAGS_show_hostname_instead_of_ip) {
+ char hostname[256];
Review Comment:
This expectation uses a 256-byte resolution buffer, but `NameOfPoint` uses
128 bytes. If loopback resolves to a sufficiently long hostname, production can
fall back to the IP address or truncate the appended port while this test
expects the full hostname and port, causing a false failure. Use the same
buffer size as the formatter so both paths have identical resolution and
truncation behavior.
##########
test/brpc_builtin_service_unittest.cpp:
##########
@@ -693,6 +706,13 @@ TEST_F(BuiltinServiceTest, connections) {
TestConnections(true);
}
+TEST_F(BuiltinServiceTest, connections_with_hostnames) {
+ GFLAGS_NAMESPACE::FlagSaver flag_saver;
+ brpc::FLAGS_show_hostname_instead_of_ip = true;
+ TestConnections(false);
+ TestConnections(true);
Review Comment:
The test depends on loopback resolution, which normally returns `localhost`
or falls back to an IP address, so it can pass even with the escaping removed.
Add a deterministic resolved name containing `<`, `>` and `&`, using a resolver
stub or a testable rendering helper. Assert that HTML contains the escaped
value and excludes the raw value, while plain text preserves it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]