diff options
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc')
-rw-r--r-- | chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc | 226 |
1 files changed, 61 insertions, 165 deletions
diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc index 3240ceb2557..896438a2b73 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc @@ -417,7 +417,7 @@ class QuicDispatcherTest : public QuicTest { TEST_F(QuicDispatcherTest, TlsClientHelloCreatesSession) { if (!QuicVersionUsesCryptoFrames( CurrentSupportedVersions().front().transport_version)) { - // TLS is only supported in versions 47 and greater. + // TLS is only supported in versions with crypto frames. return; } SetQuicReloadableFlag(quic_supports_tls_handshake, true); @@ -684,23 +684,14 @@ TEST_F(QuicDispatcherTest, NoVersionPacketToTimeWaitListManager) { // list manager. EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, QuicStringPiece("hq"), _)) .Times(0); - if (GetQuicReloadableFlag(quic_reject_unprocessable_packets_statelessly)) { - EXPECT_CALL(*time_wait_list_manager_, - ProcessPacket(_, _, connection_id, _, _)) - .Times(0); - EXPECT_CALL(*time_wait_list_manager_, - AddConnectionIdToTimeWait(_, _, _, _, _)) - .Times(0); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) - .Times(1); - } else { - EXPECT_CALL(*time_wait_list_manager_, - ProcessPacket(_, _, connection_id, _, _)) - .Times(1); - EXPECT_CALL(*time_wait_list_manager_, - AddConnectionIdToTimeWait(_, _, _, _, _)) - .Times(1); - } + EXPECT_CALL(*time_wait_list_manager_, + ProcessPacket(_, _, connection_id, _, _)) + .Times(0); + EXPECT_CALL(*time_wait_list_manager_, + AddConnectionIdToTimeWait(_, _, _, _, _)) + .Times(0); + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) + .Times(1); ProcessPacket(client_address, connection_id, false, SerializeCHLO()); } @@ -714,29 +705,16 @@ TEST_F(QuicDispatcherTest, char valid_size_packet[23] = {0x70, 0xa7, 0x02, 0x6c}; QuicReceivedPacket packet2(valid_size_packet, 23, QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _)).Times(0); - if (GetQuicReloadableFlag(quic_reject_unprocessable_packets_statelessly)) { - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)) - .Times(0); - EXPECT_CALL(*time_wait_list_manager_, - AddConnectionIdToTimeWait(_, _, _, _, _)) - .Times(0); - } else { - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)) - .Times(2); - EXPECT_CALL(*time_wait_list_manager_, - AddConnectionIdToTimeWait(_, _, _, _, _)) - .Times(2); - } - if (GetQuicReloadableFlag(quic_reject_unprocessable_packets_statelessly)) { - // Verify small packet is silently dropped. - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) - .Times(0); - } + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); + EXPECT_CALL(*time_wait_list_manager_, + AddConnectionIdToTimeWait(_, _, _, _, _)) + .Times(0); + // Verify small packet is silently dropped. + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) + .Times(0); dispatcher_->ProcessPacket(server_address_, client_address, packet); - if (GetQuicReloadableFlag(quic_reject_unprocessable_packets_statelessly)) { - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) - .Times(1); - } + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) + .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, packet2); } @@ -886,8 +864,8 @@ TEST_F(QuicDispatcherTest, ProcessPacketWithZeroPort) { } TEST_F(QuicDispatcherTest, ProcessPacketWithInvalidShortInitialConnectionId) { - // Enable v47 otherwise we cannot create a packet with a short connection ID. - SetQuicReloadableFlag(quic_enable_version_47, true); + // Enable a version that supports connection IDs of length different than 8. + SetQuicReloadableFlag(quic_enable_version_50, true); CreateTimeWaitListManager(); QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); @@ -931,12 +909,8 @@ TEST_F(QuicDispatcherTest, OKSeqNoPacketProcessed) { } TEST_F(QuicDispatcherTest, SupportedTransportVersionsChangeInFlight) { - static_assert(QUIC_ARRAYSIZE(kSupportedTransportVersions) == 8u, + static_assert(QUIC_ARRAYSIZE(kSupportedTransportVersions) == 6u, "Supported versions out of sync"); - SetQuicReloadableFlag(quic_disable_version_39, false); - SetQuicReloadableFlag(quic_enable_version_47, true); - SetQuicReloadableFlag(quic_enable_version_48_2, true); - SetQuicReloadableFlag(quic_enable_version_49, true); SetQuicReloadableFlag(quic_enable_version_50, true); SetQuicReloadableFlag(quic_enable_version_99, true); @@ -955,73 +929,52 @@ TEST_F(QuicDispatcherTest, SupportedTransportVersionsChangeInFlight) { SetQuicReloadableFlag(quic_enable_version_50, true); VerifyVersionSupported( ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_50)); - - // Turn off version 49. - SetQuicReloadableFlag(quic_enable_version_49, false); - VerifyVersionNotSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_49)); - - // Turn on version 49. - SetQuicReloadableFlag(quic_enable_version_49, true); - VerifyVersionSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_49)); - - // Turn off version 48. - SetQuicReloadableFlag(quic_enable_version_48_2, false); - VerifyVersionNotSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_48)); - - // Turn on version 48. - SetQuicReloadableFlag(quic_enable_version_48_2, true); - VerifyVersionSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_48)); - - // Turn off version 47. - SetQuicReloadableFlag(quic_enable_version_47, false); - VerifyVersionNotSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_47)); - - // Turn on version 47. - SetQuicReloadableFlag(quic_enable_version_47, true); - VerifyVersionSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_47)); - - // Turn off version 39. - SetQuicReloadableFlag(quic_disable_version_39, true); - VerifyVersionNotSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_39)); - - // Turn on version 39. - SetQuicReloadableFlag(quic_disable_version_39, false); - VerifyVersionSupported( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_39)); } TEST_F(QuicDispatcherTest, RejectDeprecatedVersionsWithVersionNegotiation) { - static_assert(QUIC_ARRAYSIZE(kSupportedTransportVersions) == 8u, + 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); + { + char packet47[kMinPacketSizeForVersionNegotiation] = { + 0xC0, 'Q', '0', '4', '7', /*connection ID length byte*/ 0x50}; + QuicReceivedPacket received_packet47( + packet47, kMinPacketSizeForVersionNegotiation, QuicTime::Zero()); + EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _)).Times(0); + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, _, _, _, _, _, _)) + .Times(1); + dispatcher_->ProcessPacket(server_address_, client_address, + received_packet47); + } - char packet44[kMinPacketSizeForVersionNegotiation] = { - 0xFF, 'Q', '0', '4', '4', /*connection ID length byte*/ 0x50}; - QuicReceivedPacket packet2(packet44, kMinPacketSizeForVersionNegotiation, - QuicTime::Zero()); - EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _)).Times(0); - EXPECT_CALL(*time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, _, _, _, _, _, _)) - .Times(1); - dispatcher_->ProcessPacket(server_address_, client_address, packet2); + { + char packet45[kMinPacketSizeForVersionNegotiation] = { + 0xC0, 'Q', '0', '4', '5', /*connection ID length byte*/ 0x50}; + QuicReceivedPacket received_packet45( + 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, + received_packet45); + } + + { + char packet44[kMinPacketSizeForVersionNegotiation] = { + 0xFF, 'Q', '0', '4', '4', /*connection ID length byte*/ 0x50}; + QuicReceivedPacket received_packet44( + packet44, kMinPacketSizeForVersionNegotiation, QuicTime::Zero()); + EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _)).Times(0); + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, _, _, _, _, _, _)) + .Times(1); + dispatcher_->ProcessPacket(server_address_, client_address, + received_packet44); + } } TEST_F(QuicDispatcherTest, VersionNegotiationProbeOld) { @@ -1196,8 +1149,6 @@ TEST_F(QuicDispatcherTest, VersionNegotiationProbeEndToEnd) { TEST_F(QuicDispatcherTest, AndroidConformanceTestOld) { // TODO(b/139691956) Remove this test once the workaround is removed. - // This test requires the workaround behind this flag to pass. - SetQuicReloadableFlag(quic_reply_to_old_android_conformance_test, true); SavingWriter* saving_writer = new SavingWriter(); // dispatcher_ takes ownership of saving_writer. QuicDispatcherPeer::UseWriter(dispatcher_.get(), saving_writer); @@ -1242,63 +1193,9 @@ TEST_F(QuicDispatcherTest, AndroidConformanceTestOld) { sizeof(connection_id_bytes)); } -TEST_F(QuicDispatcherTest, AndroidConformanceTestNewWithWorkaround) { - // TODO(b/139691956) Remove this test once the workaround is removed. - // This test doesn't need the workaround but we make sure that it passes even - // when the flag is true, also see AndroidConformanceTest below. - SetQuicReloadableFlag(quic_reply_to_old_android_conformance_test, true); - SavingWriter* saving_writer = new SavingWriter(); - // dispatcher_ takes ownership of saving_writer. - QuicDispatcherPeer::UseWriter(dispatcher_.get(), saving_writer); - - QuicTimeWaitListManager* time_wait_list_manager = new QuicTimeWaitListManager( - saving_writer, dispatcher_.get(), mock_helper_.GetClock(), - &mock_alarm_factory_); - // dispatcher_ takes ownership of time_wait_list_manager. - QuicDispatcherPeer::SetTimeWaitListManager(dispatcher_.get(), - time_wait_list_manager); - // clang-format off - static const unsigned char packet[1200] = { - // Android UDP network conformance test packet as it was after this change: - // https://android-review.googlesource.com/c/platform/cts/+/1104285 - 0x0d, // public flags: version, 8-byte connection ID, 1-byte packet number - 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, // 8-byte connection ID - 0xaa, 0xda, 0xca, 0xaa, // reserved-space version number - 0x01, // 1-byte packet number - 0x00, // private flags - 0x07, // PING frame - }; - // clang-format on - - QuicEncryptedPacket encrypted(reinterpret_cast<const char*>(packet), - sizeof(packet), false); - std::unique_ptr<QuicReceivedPacket> received_packet( - ConstructReceivedPacket(encrypted, mock_helper_.GetClock()->Now())); - EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _)).Times(0); - - QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); - dispatcher_->ProcessPacket(server_address_, client_address, *received_packet); - ASSERT_EQ(1u, saving_writer->packets()->size()); - - // The Android UDP network conformance test directly checks that bytes 1-9 - // of the response match the connection ID that was sent. - static const char connection_id_bytes[] = {0x71, 0x72, 0x73, 0x74, - 0x75, 0x76, 0x77, 0x78}; - ASSERT_GE((*(saving_writer->packets()))[0]->length(), - 1u + sizeof(connection_id_bytes)); - test::CompareCharArraysWithHexError( - "response connection ID", &(*(saving_writer->packets()))[0]->data()[1], - sizeof(connection_id_bytes), connection_id_bytes, - sizeof(connection_id_bytes)); -} - TEST_F(QuicDispatcherTest, AndroidConformanceTest) { // WARNING: do not remove or modify this test without making sure that we // still have adequate coverage for the Android conformance test. - - // Set the flag to false to make sure this test passes even when the - // workaround is disabled. - SetQuicReloadableFlag(quic_reply_to_old_android_conformance_test, false); SavingWriter* saving_writer = new SavingWriter(); // dispatcher_ takes ownership of saving_writer. QuicDispatcherPeer::UseWriter(dispatcher_.get(), saving_writer); @@ -1345,7 +1242,6 @@ TEST_F(QuicDispatcherTest, AndroidConformanceTest) { } TEST_F(QuicDispatcherTest, DoNotProcessSmallPacket) { - SetQuicReloadableFlag(quic_donot_process_small_initial_packets, true); CreateTimeWaitListManager(); QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); @@ -2161,8 +2057,8 @@ TEST_F(BufferedPacketStoreTest, ReceiveCHLOForBufferedConnection) { /*connection_id=*/TestConnectionId(1))); // CHLO on connection 1 should still be buffered. - ProcessPacket(client_addr_, /*connection_id=*/TestConnectionId(1), true, - SerializeFullCHLO()); + ProcessPacket(client_addr_, /*server_connection_id=*/TestConnectionId(1), + true, SerializeFullCHLO()); EXPECT_TRUE(store->HasChloForConnection( /*connection_id=*/TestConnectionId(1))); } |