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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _)) | 521 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _)) |
522 .Times(1); | 522 .Times(1); |
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) == 6u, | 531 static_assert(arraysize(kSupportedQuicVersions) == 5u, |
532 "Supported versions out of sync"); | 532 "Supported versions out of sync"); |
533 FLAGS_quic_reloadable_flag_quic_disable_version_34 = false; | |
534 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = true; | 533 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3 = true; |
535 FLAGS_quic_reloadable_flag_quic_enable_version_37 = true; | 534 FLAGS_quic_reloadable_flag_quic_enable_version_37 = true; |
536 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; | 535 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true; |
537 base::SetFlag(&FLAGS_quic_enable_version_39, true); | 536 base::SetFlag(&FLAGS_quic_enable_version_39, true); |
538 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); | 537 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); |
539 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); | 538 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); |
540 QuicConnectionId connection_id = 1; | 539 QuicConnectionId connection_id = 1; |
541 | 540 |
542 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | 541 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) |
543 .Times(0); | 542 .Times(0); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 &mock_helper_, &mock_alarm_factory_, &crypto_config_, | 616 &mock_helper_, &mock_alarm_factory_, &crypto_config_, |
618 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); | 617 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); |
619 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), | 618 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
620 ProcessUdpPacket(_, _, _)) | 619 ProcessUdpPacket(_, _, _)) |
621 .WillOnce(testing::WithArgs<2>( | 620 .WillOnce(testing::WithArgs<2>( |
622 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, | 621 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, |
623 base::Unretained(this), connection_id)))); | 622 base::Unretained(this), connection_id)))); |
624 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_35, | 623 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_35, |
625 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | 624 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, |
626 PACKET_6BYTE_PACKET_NUMBER, 1); | 625 PACKET_6BYTE_PACKET_NUMBER, 1); |
627 | |
628 // Turn off version 34. | |
629 FLAGS_quic_reloadable_flag_quic_disable_version_34 = true; | |
630 ++connection_id; | |
631 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | |
632 .Times(0); | |
633 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_34, | |
634 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | |
635 PACKET_6BYTE_PACKET_NUMBER, 1); | |
636 | |
637 // Turn on version 34. | |
638 FLAGS_quic_reloadable_flag_quic_disable_version_34 = false; | |
639 ++connection_id; | |
640 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | |
641 .WillOnce(testing::Return(CreateSession( | |
642 dispatcher_.get(), config_, connection_id, client_address, | |
643 &mock_helper_, &mock_alarm_factory_, &crypto_config_, | |
644 QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_))); | |
645 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), | |
646 ProcessUdpPacket(_, _, _)) | |
647 .WillOnce(testing::WithArgs<2>( | |
648 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, | |
649 base::Unretained(this), connection_id)))); | |
650 ProcessPacket(client_address, connection_id, true, QUIC_VERSION_34, | |
651 SerializeCHLO(), PACKET_8BYTE_CONNECTION_ID, | |
652 PACKET_6BYTE_PACKET_NUMBER, 1); | |
653 } | 626 } |
654 | 627 |
655 // Enables mocking of the handshake-confirmation for stateless rejects. | 628 // Enables mocking of the handshake-confirmation for stateless rejects. |
656 class MockQuicCryptoServerStream : public QuicCryptoServerStream { | 629 class MockQuicCryptoServerStream : public QuicCryptoServerStream { |
657 public: | 630 public: |
658 MockQuicCryptoServerStream(const QuicCryptoServerConfig& crypto_config, | 631 MockQuicCryptoServerStream(const QuicCryptoServerConfig& crypto_config, |
659 QuicCompressedCertsCache* compressed_certs_cache, | 632 QuicCompressedCertsCache* compressed_certs_cache, |
660 QuicServerSessionBase* session, | 633 QuicServerSessionBase* session, |
661 QuicCryptoServerStream::Helper* helper) | 634 QuicCryptoServerStream::Helper* helper) |
662 : QuicCryptoServerStream( | 635 : QuicCryptoServerStream( |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2094 check.Call(2); | 2067 check.Call(2); |
2095 GetFakeProofSource()->InvokePendingCallback(0); | 2068 GetFakeProofSource()->InvokePendingCallback(0); |
2096 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); | 2069 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); |
2097 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); | 2070 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); |
2098 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); | 2071 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); |
2099 } | 2072 } |
2100 | 2073 |
2101 } // namespace | 2074 } // namespace |
2102 } // namespace test | 2075 } // namespace test |
2103 } // namespace net | 2076 } // namespace net |
OLD | NEW |