| 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 41d7e560ca18a8705761b2c803f45a309b6490b0..6a382ad9aa8d5cea020191dec63f2a2fb1b755ea 100644
|
| --- a/net/tools/quic/quic_dispatcher_test.cc
|
| +++ b/net/tools/quic/quic_dispatcher_test.cc
|
| @@ -266,6 +266,12 @@ class QuicDispatcherTest : public ::testing::Test {
|
| time_wait_list_manager_);
|
| }
|
|
|
| + string SerializeCHLO() {
|
| + CryptoHandshakeMessage client_hello;
|
| + client_hello.set_tag(kCHLO);
|
| + return client_hello.GetSerialized().AsStringPiece().as_string();
|
| + }
|
| +
|
| EpollServer eps_;
|
| QuicEpollConnectionHelper helper_;
|
| MockQuicConnectionHelper mock_helper_;
|
| @@ -290,7 +296,7 @@ TEST_F(QuicDispatcherTest, ProcessPackets) {
|
| &dispatcher_, config_, 1, client_address, &mock_helper_,
|
| &mock_alarm_factory_, &crypto_config_,
|
| QuicDispatcherPeer::GetCache(&dispatcher_), &session1_)));
|
| - ProcessPacket(client_address, 1, true, false, "foo");
|
| + ProcessPacket(client_address, 1, true, false, SerializeCHLO());
|
| EXPECT_EQ(client_address, dispatcher_.current_client_address());
|
| EXPECT_EQ(server_address_, dispatcher_.current_server_address());
|
|
|
| @@ -299,14 +305,14 @@ TEST_F(QuicDispatcherTest, ProcessPackets) {
|
| &dispatcher_, config_, 2, client_address, &mock_helper_,
|
| &mock_alarm_factory_, &crypto_config_,
|
| QuicDispatcherPeer::GetCache(&dispatcher_), &session2_)));
|
| - ProcessPacket(client_address, 2, true, false, "bar");
|
| + ProcessPacket(client_address, 2, true, false, SerializeCHLO());
|
|
|
| EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
|
| ProcessUdpPacket(_, _, _))
|
| .Times(1)
|
| .WillOnce(testing::WithArgs<2>(
|
| Invoke(this, &QuicDispatcherTest::ValidatePacket)));
|
| - ProcessPacket(client_address, 1, false, false, "eep");
|
| + ProcessPacket(client_address, 1, false, false, "data");
|
| }
|
|
|
| TEST_F(QuicDispatcherTest, StatelessVersionNegotiation) {
|
| @@ -315,7 +321,7 @@ TEST_F(QuicDispatcherTest, StatelessVersionNegotiation) {
|
|
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address)).Times(0);
|
| QuicVersion version = static_cast<QuicVersion>(QuicVersionMin() - 1);
|
| - ProcessPacket(client_address, 1, true, version, "foo",
|
| + ProcessPacket(client_address, 1, true, version, SerializeCHLO(),
|
| PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1);
|
| }
|
|
|
| @@ -328,7 +334,7 @@ TEST_F(QuicDispatcherTest, Shutdown) {
|
| &mock_alarm_factory_, &crypto_config_,
|
| QuicDispatcherPeer::GetCache(&dispatcher_), &session1_)));
|
|
|
| - ProcessPacket(client_address, 1, true, false, "foo");
|
| + ProcessPacket(client_address, 1, true, false, SerializeCHLO());
|
|
|
| EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
|
| CloseConnection(QUIC_PEER_GOING_AWAY, _, _));
|
| @@ -347,7 +353,7 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
|
| &dispatcher_, config_, connection_id, client_address, &mock_helper_,
|
| &mock_alarm_factory_, &crypto_config_,
|
| QuicDispatcherPeer::GetCache(&dispatcher_), &session1_)));
|
| - ProcessPacket(client_address, connection_id, true, false, "foo");
|
| + ProcessPacket(client_address, connection_id, true, false, SerializeCHLO());
|
|
|
| // Close the connection by sending public reset packet.
|
| QuicPublicResetPacket packet;
|
| @@ -381,7 +387,7 @@ TEST_F(QuicDispatcherTest, TimeWaitListManager) {
|
| .Times(1);
|
| EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
|
| .Times(0);
|
| - ProcessPacket(client_address, connection_id, true, false, "foo");
|
| + ProcessPacket(client_address, connection_id, true, false, "data");
|
| }
|
|
|
| TEST_F(QuicDispatcherTest, NoVersionPacketToTimeWaitListManager) {
|
| @@ -397,7 +403,62 @@ TEST_F(QuicDispatcherTest, NoVersionPacketToTimeWaitListManager) {
|
| .Times(1);
|
| EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
|
| .Times(1);
|
| - ProcessPacket(client_address, connection_id, false, false, "data");
|
| + ProcessPacket(client_address, connection_id, false, false, SerializeCHLO());
|
| +}
|
| +
|
| +TEST_F(QuicDispatcherTest, ProcessPacketWithZeroPort) {
|
| + CreateTimeWaitListManager();
|
| +
|
| + IPEndPoint client_address(net::test::Loopback4(), 0);
|
| + server_address_ = IPEndPoint(net::test::Any4(), 5);
|
| +
|
| + // dispatcher_ should drop this packet.
|
| + EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address)).Times(0);
|
| + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0);
|
| + EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
|
| + .Times(0);
|
| + ProcessPacket(client_address, 1, true, false, SerializeCHLO());
|
| +}
|
| +
|
| +TEST_F(QuicDispatcherTest, OKSeqNoPacketProcessed) {
|
| + IPEndPoint client_address(net::test::Loopback4(), 1);
|
| + QuicConnectionId connection_id = 1;
|
| + server_address_ = IPEndPoint(net::test::Any4(), 5);
|
| +
|
| + EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address))
|
| + .WillOnce(testing::Return(CreateSession(
|
| + &dispatcher_, config_, 1, client_address, &mock_helper_,
|
| + &mock_alarm_factory_, &crypto_config_,
|
| + QuicDispatcherPeer::GetCache(&dispatcher_), &session1_)));
|
| + // A packet whose packet number is the largest that is allowed to start a
|
| + // connection.
|
| + ProcessPacket(client_address, connection_id, true, false, SerializeCHLO(),
|
| + PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER,
|
| + kDefaultPathId,
|
| + QuicDispatcher::kMaxReasonableInitialPacketNumber);
|
| + EXPECT_EQ(client_address, dispatcher_.current_client_address());
|
| + EXPECT_EQ(server_address_, dispatcher_.current_server_address());
|
| +}
|
| +
|
| +TEST_F(QuicDispatcherTest, TooBigSeqNoPacketToTimeWaitListManager) {
|
| + CreateTimeWaitListManager();
|
| +
|
| + IPEndPoint client_address(net::test::Loopback4(), 1);
|
| + QuicConnectionId connection_id = 1;
|
| + // Dispatcher forwards this packet for this connection_id to the time wait
|
| + // list manager.
|
| + EXPECT_CALL(dispatcher_, CreateQuicSession(_, _)).Times(0);
|
| + EXPECT_CALL(*time_wait_list_manager_,
|
| + ProcessPacket(_, _, connection_id, _, _))
|
| + .Times(1);
|
| + EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
|
| + .Times(1);
|
| + // A packet whose packet number is one to large to be allowed to start a
|
| + // connection.
|
| + ProcessPacket(client_address, connection_id, true, false, SerializeCHLO(),
|
| + PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER,
|
| + kDefaultPathId,
|
| + QuicDispatcher::kMaxReasonableInitialPacketNumber + 1);
|
| }
|
|
|
| // Enables mocking of the handshake-confirmation for stateless rejects.
|
| @@ -510,61 +571,6 @@ class QuicDispatcherStatelessRejectTest
|
| MockQuicCryptoServerStream* crypto_stream1_;
|
| };
|
|
|
| -TEST_F(QuicDispatcherTest, ProcessPacketWithZeroPort) {
|
| - CreateTimeWaitListManager();
|
| -
|
| - IPEndPoint client_address(net::test::Loopback4(), 0);
|
| - server_address_ = IPEndPoint(net::test::Any4(), 5);
|
| -
|
| - // dispatcher_ should drop this packet.
|
| - EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address)).Times(0);
|
| - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0);
|
| - EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
|
| - .Times(0);
|
| - ProcessPacket(client_address, 1, true, false, "foo");
|
| -}
|
| -
|
| -TEST_F(QuicDispatcherTest, OKSeqNoPacketProcessed) {
|
| - IPEndPoint client_address(net::test::Loopback4(), 1);
|
| - QuicConnectionId connection_id = 1;
|
| - server_address_ = IPEndPoint(net::test::Any4(), 5);
|
| -
|
| - EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address))
|
| - .WillOnce(testing::Return(CreateSession(
|
| - &dispatcher_, config_, 1, client_address, &mock_helper_,
|
| - &mock_alarm_factory_, &crypto_config_,
|
| - QuicDispatcherPeer::GetCache(&dispatcher_), &session1_)));
|
| - // A packet whose packet number is the largest that is allowed to start a
|
| - // connection.
|
| - ProcessPacket(client_address, connection_id, true, false, "data",
|
| - PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER,
|
| - kDefaultPathId,
|
| - QuicDispatcher::kMaxReasonableInitialPacketNumber);
|
| - EXPECT_EQ(client_address, dispatcher_.current_client_address());
|
| - EXPECT_EQ(server_address_, dispatcher_.current_server_address());
|
| -}
|
| -
|
| -TEST_F(QuicDispatcherTest, TooBigSeqNoPacketToTimeWaitListManager) {
|
| - CreateTimeWaitListManager();
|
| -
|
| - IPEndPoint client_address(net::test::Loopback4(), 1);
|
| - QuicConnectionId connection_id = 1;
|
| - // Dispatcher forwards this packet for this connection_id to the time wait
|
| - // list manager.
|
| - EXPECT_CALL(dispatcher_, CreateQuicSession(_, _)).Times(0);
|
| - EXPECT_CALL(*time_wait_list_manager_,
|
| - ProcessPacket(_, _, connection_id, _, _))
|
| - .Times(1);
|
| - EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
|
| - .Times(1);
|
| - // A packet whose packet number is one to large to be allowed to start a
|
| - // connection.
|
| - ProcessPacket(client_address, connection_id, true, false, "data",
|
| - PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER,
|
| - kDefaultPathId,
|
| - QuicDispatcher::kMaxReasonableInitialPacketNumber + 1);
|
| -}
|
| -
|
| INSTANTIATE_TEST_CASE_P(QuicDispatcherStatelessRejectTests,
|
| QuicDispatcherStatelessRejectTest,
|
| ::testing::ValuesIn(GetStatelessRejectTestParams()));
|
| @@ -582,7 +588,7 @@ TEST_P(QuicDispatcherStatelessRejectTest, ParameterizedBasicTest) {
|
| CreateSessionBasedOnTestParams(connection_id, client_address)));
|
|
|
| // Process the first packet for the connection.
|
| - ProcessPacket(client_address, connection_id, true, false, "foo");
|
| + ProcessPacket(client_address, connection_id, true, false, SerializeCHLO());
|
| if (ExpectStatelessReject()) {
|
| // If this is a stateless reject, the crypto stream will close the
|
| // connection.
|
| @@ -608,7 +614,7 @@ TEST_P(QuicDispatcherStatelessRejectTest, ParameterizedBasicTest) {
|
| .WillOnce(testing::WithArgs<2>(
|
| Invoke(this, &QuicDispatcherTest::ValidatePacket)));
|
| }
|
| - ProcessPacket(client_address, connection_id, true, false, "foo");
|
| + ProcessPacket(client_address, connection_id, true, false, "data");
|
| }
|
|
|
| // Verify the stopgap test: Packets with truncated connection IDs should be
|
| @@ -668,14 +674,14 @@ class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest {
|
| &dispatcher_, config_, 1, client_address, &helper_, &alarm_factory_,
|
| &crypto_config_, QuicDispatcherPeer::GetCache(&dispatcher_),
|
| &session1_)));
|
| - ProcessPacket(client_address, 1, true, false, "foo");
|
| + ProcessPacket(client_address, 1, true, false, SerializeCHLO());
|
|
|
| EXPECT_CALL(dispatcher_, CreateQuicSession(_, client_address))
|
| .WillOnce(testing::Return(CreateSession(
|
| &dispatcher_, config_, 2, client_address, &helper_, &alarm_factory_,
|
| &crypto_config_, QuicDispatcherPeer::GetCache(&dispatcher_),
|
| &session2_)));
|
| - ProcessPacket(client_address, 2, true, false, "bar");
|
| + ProcessPacket(client_address, 2, true, false, SerializeCHLO());
|
|
|
| blocked_list_ = QuicDispatcherPeer::GetWriteBlockedList(&dispatcher_);
|
| }
|
|
|