Index: net/tools/quic/quic_dispatcher_test.cc |
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc |
index a063a2daf66da169b2b1417a5745b81af66ce71d..51521daff7b12290cc1403f273093504f5c80ac3 100644 |
--- a/net/tools/quic/quic_dispatcher_test.cc |
+++ b/net/tools/quic/quic_dispatcher_test.cc |
@@ -660,6 +660,51 @@ TEST_P(QuicDispatcherStatelessRejectTest, CheapRejects) { |
} |
} |
+TEST_P(QuicDispatcherStatelessRejectTest, BufferNonChlo) { |
+ FLAGS_quic_use_cheap_stateless_rejects = true; |
+ CreateTimeWaitListManager(); |
+ |
+ const IPEndPoint client_address(net::test::Loopback4(), 1); |
+ const QuicConnectionId connection_id = 1; |
+ |
+ if (!GetParam().enable_stateless_rejects_via_flag) { |
+ // If stateless rejects are not being used, then a connection will be |
+ // created immediately. |
+ EXPECT_CALL(dispatcher_, CreateQuicSession(connection_id, client_address)) |
+ .WillOnce(testing::Return( |
+ CreateSessionBasedOnTestParams(connection_id, client_address))); |
+ } |
+ ProcessPacket(client_address, connection_id, true, false, |
+ "NOT DATA FOR A CHLO"); |
+ |
+ // Process the first packet for the connection. |
+ // clang-format off |
+ CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( |
+ "CHLO", |
+ "AEAD", "AESG", |
+ "KEXS", "C255", |
+ "NONC", "1234567890123456789012", |
+ "VER\0", "Q025", |
+ "$padding", static_cast<int>(kClientHelloMinimumSize), |
+ nullptr); |
+ // clang-format on |
+ |
+ if (GetParam().enable_stateless_rejects_via_flag) { |
+ // If stateless rejects are enabled then a connection will be created now |
+ // and the buffered packet will be processed |
+ EXPECT_CALL(dispatcher_, CreateQuicSession(connection_id, client_address)) |
+ .WillOnce(testing::Return( |
+ CreateSessionBasedOnTestParams(connection_id, client_address))); |
+ } |
+ EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
+ ProcessUdpPacket(_, client_address, _)) |
+ .RetiresOnSaturation(); |
+ ProcessPacket(client_address, connection_id, true, false, |
+ client_hello.GetSerialized().AsStringPiece().as_string()); |
+ EXPECT_FALSE( |
+ time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); |
+} |
+ |
// Verify the stopgap test: Packets with truncated connection IDs should be |
// dropped. |
class QuicDispatcherTestStrayPacketConnectionId : public QuicDispatcherTest {}; |