Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: net/tools/quic/end_to_end_test.cc

Issue 1038293002: Move test for incoming packets with incorrect connection ID from (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Fix_flaky_QUIC_end_to_end_test_89220759
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/end_to_end_test.cc
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
index d361b0c28c39ba5aefd6e29febc4faed592c88df..d4684a1d6a2d3a6cb0d68a7e9d90d570617f7d88 100644
--- a/net/tools/quic/end_to_end_test.cc
+++ b/net/tools/quic/end_to_end_test.cc
@@ -50,6 +50,7 @@ using base::StringPiece;
using base::WaitableEvent;
using net::EpollServer;
using net::test::GenerateBody;
+using net::test::MockQuicConnectionDebugVisitor;
using net::test::QuicConnectionPeer;
using net::test::QuicFlowControllerPeer;
using net::test::QuicSentPacketManagerPeer;
@@ -1396,6 +1397,93 @@ TEST_P(EndToEndTest, AckNotifierWithPacketLossAndBlockedSocket) {
server_thread_->Resume();
}
+// Send a public reset from the server for a different connection ID.
+// It should be ignored.
+TEST_P(EndToEndTest, ServerSendPublicResetWithDifferentConnectionId) {
+ ASSERT_TRUE(Initialize());
+
+ // Send the public reset.
+ QuicConnectionId incorrect_connection_id =
+ client_->client()->session()->connection()->connection_id() + 1;
+ QuicPublicResetPacket header;
+ header.public_header.connection_id = incorrect_connection_id;
+ header.public_header.reset_flag = true;
+ header.public_header.version_flag = false;
+ header.rejected_sequence_number = 10101;
+ QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
+ Perspective::IS_SERVER);
+ scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header));
+ testing::NiceMock<MockQuicConnectionDebugVisitor> visitor;
+ client_->client()->session()->connection()->set_debug_visitor(&visitor);
+ EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id))
+ .Times(1);
+ server_writer_->WritePacket(packet->data(), packet->length(),
+ server_address_.address(),
+ client_->client()->client_address());
+
+ // The connection should be unaffected.
+ EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
+ EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
+
+ client_->client()->session()->connection()->set_debug_visitor(nullptr);
+}
+
+// Send a public reset from the client for a different connection ID.
+// It should be ignored.
+TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) {
+ ASSERT_TRUE(Initialize());
+
+ // Send the public reset.
+ QuicConnectionId incorrect_connection_id =
+ client_->client()->session()->connection()->connection_id() + 1;
+ QuicPublicResetPacket header;
+ header.public_header.connection_id = incorrect_connection_id;
+ header.public_header.reset_flag = true;
+ header.public_header.version_flag = false;
+ header.rejected_sequence_number = 10101;
+ QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
+ Perspective::IS_CLIENT);
+ scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header));
+ client_writer_->WritePacket(packet->data(), packet->length(),
+ client_->client()->client_address().address(),
+ server_address_);
+
+ // The connection should be unaffected.
+ EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
+ EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
+}
+
+// Send a version negotiation packet from the server for a different
+// connection ID. It should be ignored.
+TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) {
+ ASSERT_TRUE(Initialize());
+
+ // Send the version negotiation packet.
+ QuicConnectionId incorrect_connection_id =
+ client_->client()->session()->connection()->connection_id() + 1;
+ QuicVersionNegotiationPacket header;
+ header.connection_id = incorrect_connection_id;
+ header.reset_flag = true;
+ header.version_flag = true;
+ QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
+ Perspective::IS_SERVER);
+ scoped_ptr<QuicEncryptedPacket> packet(
+ framer.BuildVersionNegotiationPacket(header, server_supported_versions_));
+ testing::NiceMock<MockQuicConnectionDebugVisitor> visitor;
+ client_->client()->session()->connection()->set_debug_visitor(&visitor);
+ EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id))
+ .Times(1);
+ server_writer_->WritePacket(packet->data(), packet->length(),
+ server_address_.address(),
+ client_->client()->client_address());
+
+ // The connection should be unaffected.
+ EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
+ EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
+
+ client_->client()->session()->connection()->set_debug_visitor(nullptr);
+}
+
} // namespace
} // namespace test
} // namespace tools
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698