Add a test to ensure packets of deprecated QUIC versions are rejected by QuicDispatcher via version negotiation.
gfe-relnote: n/a (test only)
PiperOrigin-RevId: 255983338
Change-Id: I5b45d18586fea8e18942b03896b36e050b214270
diff --git a/quic/core/quic_dispatcher_test.cc b/quic/core/quic_dispatcher_test.cc
index 8e014b0..66d066a 100644
--- a/quic/core/quic_dispatcher_test.cc
+++ b/quic/core/quic_dispatcher_test.cc
@@ -924,6 +924,23 @@
ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_39));
}
+TEST_F(QuicDispatcherTest, RejectDeprecatedVersionsWithVersionNegotiation) {
+ static_assert(QUIC_ARRAYSIZE(kSupportedTransportVersions) == 6u,
+ "Please add deprecated versions to this test");
+ QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1);
+ CreateTimeWaitListManager();
+
+ char packet45[kMinPacketSizeForVersionNegotiation] = {
+ 0xC0, 'Q', '0', '4', '5', /*connection ID length byte*/ 0x50};
+ QuicReceivedPacket packet(packet45, kMinPacketSizeForVersionNegotiation,
+ QuicTime::Zero());
+ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _)).Times(0);
+ EXPECT_CALL(*time_wait_list_manager_,
+ SendVersionNegotiationPacket(_, _, _, _, _, _, _))
+ .Times(1);
+ dispatcher_->ProcessPacket(server_address_, client_address, packet);
+}
+
// Verify the stopgap test: Packets with truncated connection IDs should be
// dropped.
class QuicDispatcherTestStrayPacketConnectionId : public QuicDispatcherTest {};