| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // A packet whose packet number is one to large to be allowed to start a | 523 // A packet whose packet number is one to large to be allowed to start a |
| 524 // connection. | 524 // connection. |
| 525 ProcessPacket(client_address, connection_id, true, SerializeCHLO(), | 525 ProcessPacket(client_address, connection_id, true, SerializeCHLO(), |
| 526 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, | 526 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, |
| 527 QuicDispatcher::kMaxReasonableInitialPacketNumber + 1); | 527 QuicDispatcher::kMaxReasonableInitialPacketNumber + 1); |
| 528 } | 528 } |
| 529 | 529 |
| 530 TEST_F(QuicDispatcherTest, SupportedVersionsChangeInFlight) { | 530 TEST_F(QuicDispatcherTest, SupportedVersionsChangeInFlight) { |
| 531 static_assert(arraysize(kSupportedQuicVersions) == 5u, | 531 static_assert(arraysize(kSupportedQuicVersions) == 5u, |
| 532 "Supported versions out of sync"); | 532 "Supported versions out of sync"); |
| 533 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = true; | |
| 534 FLAGS_quic_reloadable_flag_quic_enable_version_37 = true; | 533 FLAGS_quic_reloadable_flag_quic_enable_version_37 = true; |
| 535 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; | 534 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; |
| 536 base::SetFlag(&FLAGS_quic_enable_version_39, true); | 535 base::SetFlag(&FLAGS_quic_enable_version_39, true); |
| 537 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); | 536 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); |
| 538 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); | 537 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); |
| 539 QuicConnectionId connection_id = 1; | 538 QuicConnectionId connection_id = 1; |
| 540 | 539 |
| 541 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | 540 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) |
| 542 .Times(0); | 541 .Times(0); |
| 543 ProcessPacket(client_address, connection_id, true, | 542 ProcessPacket(client_address, connection_id, true, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 &mock_helper_, &mock_alarm_factory_, &crypto_config_, | 589 &mock_helper_, &mock_alarm_factory_, &crypto_config_, |
| 591 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); | 590 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); |
| 592 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), | 591 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 593 ProcessUdpPacket(_, _, _)) | 592 ProcessUdpPacket(_, _, _)) |
| 594 .WillOnce(testing::WithArgs<2>( | 593 .WillOnce(testing::WithArgs<2>( |
| 595 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, | 594 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, |
| 596 base::Unretained(this), connection_id)))); | 595 base::Unretained(this), connection_id)))); |
| 597 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_39, | 596 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_39, |
| 598 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | 597 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, |
| 599 PACKET_6BYTE_PACKET_NUMBER, 1); | 598 PACKET_6BYTE_PACKET_NUMBER, 1); |
| 600 | |
| 601 // Turn off version 36. | |
| 602 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = false; | |
| 603 ++connection_id; | |
| 604 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | |
| 605 .Times(0); | |
| 606 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_36, | |
| 607 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | |
| 608 PACKET_6BYTE_PACKET_NUMBER, 1); | |
| 609 | |
| 610 // Turn on version 36. | |
| 611 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = true; | |
| 612 ++connection_id; | |
| 613 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | |
| 614 .WillOnce(testing::Return(CreateSession( | |
| 615 dispatcher_.get(), config_, connection_id, client_address, | |
| 616 &mock_helper_, &mock_alarm_factory_, &crypto_config_, | |
| 617 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); | |
| 618 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), | |
| 619 ProcessUdpPacket(_, _, _)) | |
| 620 .WillOnce(testing::WithArgs<2>( | |
| 621 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, | |
| 622 base::Unretained(this), connection_id)))); | |
| 623 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_35, | |
| 624 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | |
| 625 PACKET_6BYTE_PACKET_NUMBER, 1); | |
| 626 } | 599 } |
| 627 | 600 |
| 628 // Enables mocking of the handshake-confirmation for stateless rejects. | 601 // Enables mocking of the handshake-confirmation for stateless rejects. |
| 629 class MockQuicCryptoServerStream : public QuicCryptoServerStream { | 602 class MockQuicCryptoServerStream : public QuicCryptoServerStream { |
| 630 public: | 603 public: |
| 631 MockQuicCryptoServerStream(const QuicCryptoServerConfig& crypto_config, | 604 MockQuicCryptoServerStream(const QuicCryptoServerConfig& crypto_config, |
| 632 QuicCompressedCertsCache* compressed_certs_cache, | 605 QuicCompressedCertsCache* compressed_certs_cache, |
| 633 QuicServerSessionBase* session, | 606 QuicServerSessionBase* session, |
| 634 QuicCryptoServerStream::Helper* helper) | 607 QuicCryptoServerStream::Helper* helper) |
| 635 : QuicCryptoServerStream( | 608 : QuicCryptoServerStream( |
| (...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2067 check.Call(2); | 2040 check.Call(2); |
| 2068 GetFakeProofSource()->InvokePendingCallback(0); | 2041 GetFakeProofSource()->InvokePendingCallback(0); |
| 2069 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); | 2042 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); |
| 2070 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); | 2043 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); |
| 2071 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); | 2044 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); |
| 2072 } | 2045 } |
| 2073 | 2046 |
| 2074 } // namespace | 2047 } // namespace |
| 2075 } // namespace test | 2048 } // namespace test |
| 2076 } // namespace net | 2049 } // namespace net |
| OLD | NEW |