| 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 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 } | 1093 } |
| 1094 return params; | 1094 return params; |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 // A dispatcher whose stateless rejector will always ACCEPTs CHLO. | 1097 // A dispatcher whose stateless rejector will always ACCEPTs CHLO. |
| 1098 class BufferedPacketStoreTest | 1098 class BufferedPacketStoreTest |
| 1099 : public QuicDispatcherTest, | 1099 : public QuicDispatcherTest, |
| 1100 public ::testing::WithParamInterface<BufferedPacketStoreTestParams> { | 1100 public ::testing::WithParamInterface<BufferedPacketStoreTestParams> { |
| 1101 public: | 1101 public: |
| 1102 BufferedPacketStoreTest() | 1102 BufferedPacketStoreTest() |
| 1103 : QuicDispatcherTest(), client_addr_(Loopback4(), 1234) { | 1103 : QuicDispatcherTest(), |
| 1104 client_addr_(Loopback4(), 1234), |
| 1105 proof_(new QuicCryptoProof) { |
| 1104 FLAGS_quic_buffer_packet_till_chlo = true; | 1106 FLAGS_quic_buffer_packet_till_chlo = true; |
| 1105 FLAGS_quic_use_cheap_stateless_rejects = | 1107 FLAGS_quic_use_cheap_stateless_rejects = |
| 1106 GetParam().support_cheap_stateless_reject; | 1108 GetParam().support_cheap_stateless_reject; |
| 1107 FLAGS_enable_quic_stateless_reject_support = | 1109 FLAGS_enable_quic_stateless_reject_support = |
| 1108 GetParam().enable_stateless_rejects_via_flag; | 1110 GetParam().enable_stateless_rejects_via_flag; |
| 1109 } | 1111 } |
| 1110 | 1112 |
| 1111 void SetUp() override { | 1113 void SetUp() override { |
| 1112 QuicDispatcherTest::SetUp(); | 1114 QuicDispatcherTest::SetUp(); |
| 1113 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); | 1115 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); |
| 1114 | 1116 |
| 1115 QuicVersion version = AllSupportedVersions().front(); | 1117 QuicVersion version = AllSupportedVersions().front(); |
| 1116 CryptoHandshakeMessage chlo = CryptoTestUtils::GenerateDefaultInchoateCHLO( | 1118 CryptoHandshakeMessage chlo = CryptoTestUtils::GenerateDefaultInchoateCHLO( |
| 1117 clock_, version, &crypto_config_); | 1119 clock_, version, &crypto_config_); |
| 1118 chlo.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); | 1120 chlo.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); |
| 1119 // Pass an inchoate CHLO. | 1121 // Pass an inchoate CHLO. |
| 1120 CryptoTestUtils::GenerateFullCHLO( | 1122 CryptoTestUtils::GenerateFullCHLO( |
| 1121 chlo, &crypto_config_, server_ip_, client_addr_, version, clock_, | 1123 chlo, &crypto_config_, server_ip_, client_addr_, version, clock_, |
| 1122 &proof_, QuicDispatcherPeer::GetCache(dispatcher_.get()), &full_chlo_); | 1124 proof_, QuicDispatcherPeer::GetCache(dispatcher_.get()), &full_chlo_); |
| 1123 } | 1125 } |
| 1124 | 1126 |
| 1125 string SerializeFullCHLO() { | 1127 string SerializeFullCHLO() { |
| 1126 return full_chlo_.GetSerialized().AsStringPiece().as_string(); | 1128 return full_chlo_.GetSerialized().AsStringPiece().as_string(); |
| 1127 } | 1129 } |
| 1128 | 1130 |
| 1129 protected: | 1131 protected: |
| 1130 IPAddress server_ip_; | 1132 IPAddress server_ip_; |
| 1131 IPEndPoint client_addr_; | 1133 IPEndPoint client_addr_; |
| 1132 QuicCryptoProof proof_; | 1134 scoped_refptr<QuicCryptoProof> proof_; |
| 1133 const QuicClock* clock_; | 1135 const QuicClock* clock_; |
| 1134 CryptoHandshakeMessage full_chlo_; | 1136 CryptoHandshakeMessage full_chlo_; |
| 1135 }; | 1137 }; |
| 1136 | 1138 |
| 1137 INSTANTIATE_TEST_CASE_P( | 1139 INSTANTIATE_TEST_CASE_P( |
| 1138 BufferedPacketStoreTests, | 1140 BufferedPacketStoreTests, |
| 1139 BufferedPacketStoreTest, | 1141 BufferedPacketStoreTest, |
| 1140 ::testing::ValuesIn(GetBufferedPacketStoreTestParams())); | 1142 ::testing::ValuesIn(GetBufferedPacketStoreTestParams())); |
| 1141 | 1143 |
| 1142 TEST_P(BufferedPacketStoreTest, ProcessNonChloPacketsUptoLimitAndProcessChlo) { | 1144 TEST_P(BufferedPacketStoreTest, ProcessNonChloPacketsUptoLimitAndProcessChlo) { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 } | 1543 } |
| 1542 | 1544 |
| 1543 // Test which exercises the async GetProof codepaths, especially in the context | 1545 // Test which exercises the async GetProof codepaths, especially in the context |
| 1544 // of stateless rejection. | 1546 // of stateless rejection. |
| 1545 class AsyncGetProofTest : public QuicDispatcherTest { | 1547 class AsyncGetProofTest : public QuicDispatcherTest { |
| 1546 public: | 1548 public: |
| 1547 AsyncGetProofTest() | 1549 AsyncGetProofTest() |
| 1548 : QuicDispatcherTest( | 1550 : QuicDispatcherTest( |
| 1549 std::unique_ptr<FakeProofSource>(new FakeProofSource())), | 1551 std::unique_ptr<FakeProofSource>(new FakeProofSource())), |
| 1550 client_addr_(net::test::Loopback4(), 1234), | 1552 client_addr_(net::test::Loopback4(), 1234), |
| 1551 crypto_config_peer_(&crypto_config_) { | 1553 crypto_config_peer_(&crypto_config_), |
| 1554 proof_(new QuicCryptoProof) { |
| 1552 FLAGS_enable_async_get_proof = true; | 1555 FLAGS_enable_async_get_proof = true; |
| 1553 FLAGS_quic_buffer_packet_till_chlo = true; | 1556 FLAGS_quic_buffer_packet_till_chlo = true; |
| 1554 FLAGS_enable_quic_stateless_reject_support = true; | 1557 FLAGS_enable_quic_stateless_reject_support = true; |
| 1555 FLAGS_quic_use_cheap_stateless_rejects = true; | 1558 FLAGS_quic_use_cheap_stateless_rejects = true; |
| 1556 FLAGS_quic_create_session_after_insertion = true; | 1559 FLAGS_quic_create_session_after_insertion = true; |
| 1557 } | 1560 } |
| 1558 | 1561 |
| 1559 void SetUp() override { | 1562 void SetUp() override { |
| 1560 QuicDispatcherTest::SetUp(); | 1563 QuicDispatcherTest::SetUp(); |
| 1561 | 1564 |
| 1562 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); | 1565 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); |
| 1563 QuicVersion version = AllSupportedVersions().front(); | 1566 QuicVersion version = AllSupportedVersions().front(); |
| 1564 chlo_ = CryptoTestUtils::GenerateDefaultInchoateCHLO(clock_, version, | 1567 chlo_ = CryptoTestUtils::GenerateDefaultInchoateCHLO(clock_, version, |
| 1565 &crypto_config_); | 1568 &crypto_config_); |
| 1566 chlo_.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); | 1569 chlo_.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); |
| 1567 // Pass an inchoate CHLO. | 1570 // Pass an inchoate CHLO. |
| 1568 CryptoTestUtils::GenerateFullCHLO( | 1571 CryptoTestUtils::GenerateFullCHLO( |
| 1569 chlo_, &crypto_config_, server_ip_, client_addr_, version, clock_, | 1572 chlo_, &crypto_config_, server_ip_, client_addr_, version, clock_, |
| 1570 &proof_, QuicDispatcherPeer::GetCache(dispatcher_.get()), &full_chlo_); | 1573 proof_, QuicDispatcherPeer::GetCache(dispatcher_.get()), &full_chlo_); |
| 1571 | 1574 |
| 1572 GetFakeProofSource()->Activate(); | 1575 GetFakeProofSource()->Activate(); |
| 1573 } | 1576 } |
| 1574 | 1577 |
| 1575 FakeProofSource* GetFakeProofSource() const { | 1578 FakeProofSource* GetFakeProofSource() const { |
| 1576 return static_cast<FakeProofSource*>(crypto_config_peer_.GetProofSource()); | 1579 return static_cast<FakeProofSource*>(crypto_config_peer_.GetProofSource()); |
| 1577 } | 1580 } |
| 1578 | 1581 |
| 1579 string SerializeFullCHLO() { | 1582 string SerializeFullCHLO() { |
| 1580 return full_chlo_.GetSerialized().AsStringPiece().as_string(); | 1583 return full_chlo_.GetSerialized().AsStringPiece().as_string(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1610 CHECK(ok); | 1613 CHECK(ok); |
| 1611 return session; | 1614 return session; |
| 1612 } | 1615 } |
| 1613 | 1616 |
| 1614 protected: | 1617 protected: |
| 1615 const IPEndPoint client_addr_; | 1618 const IPEndPoint client_addr_; |
| 1616 | 1619 |
| 1617 private: | 1620 private: |
| 1618 QuicCryptoServerConfigPeer crypto_config_peer_; | 1621 QuicCryptoServerConfigPeer crypto_config_peer_; |
| 1619 IPAddress server_ip_; | 1622 IPAddress server_ip_; |
| 1620 QuicCryptoProof proof_; | 1623 scoped_refptr<QuicCryptoProof> proof_; |
| 1621 const QuicClock* clock_; | 1624 const QuicClock* clock_; |
| 1622 CryptoHandshakeMessage chlo_; | 1625 CryptoHandshakeMessage chlo_; |
| 1623 CryptoHandshakeMessage full_chlo_; | 1626 CryptoHandshakeMessage full_chlo_; |
| 1624 | 1627 |
| 1625 struct SessionInfo { | 1628 struct SessionInfo { |
| 1626 TestQuicSpdyServerSession* session; | 1629 TestQuicSpdyServerSession* session; |
| 1627 std::unique_ptr<MockQuicCryptoServerStream> crypto_stream; | 1630 std::unique_ptr<MockQuicCryptoServerStream> crypto_stream; |
| 1628 }; | 1631 }; |
| 1629 std::map<QuicConnectionId, SessionInfo> sessions_; | 1632 std::map<QuicConnectionId, SessionInfo> sessions_; |
| 1630 }; | 1633 }; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 check.Call(2); | 2024 check.Call(2); |
| 2022 GetFakeProofSource()->InvokePendingCallback(0); | 2025 GetFakeProofSource()->InvokePendingCallback(0); |
| 2023 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); | 2026 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); |
| 2024 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); | 2027 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); |
| 2025 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); | 2028 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); |
| 2026 } | 2029 } |
| 2027 | 2030 |
| 2028 } // namespace | 2031 } // namespace |
| 2029 } // namespace test | 2032 } // namespace test |
| 2030 } // namespace net | 2033 } // namespace net |
| OLD | NEW |