| 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 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 // A dispatcher whose stateless rejector will always ACCEPTs CHLO. | 1059 // A dispatcher whose stateless rejector will always ACCEPTs CHLO. |
| 1060 class BufferedPacketStoreTest | 1060 class BufferedPacketStoreTest |
| 1061 : public QuicDispatcherTest, | 1061 : public QuicDispatcherTest, |
| 1062 public ::testing::WithParamInterface<BufferedPacketStoreTestParams> { | 1062 public ::testing::WithParamInterface<BufferedPacketStoreTestParams> { |
| 1063 public: | 1063 public: |
| 1064 BufferedPacketStoreTest() | 1064 BufferedPacketStoreTest() |
| 1065 : QuicDispatcherTest(), | 1065 : QuicDispatcherTest(), |
| 1066 client_addr_(Loopback4(), 1234), | 1066 client_addr_(Loopback4(), 1234), |
| 1067 proof_(new QuicCryptoProof) { | 1067 signed_config_(new QuicSignedServerConfig) { |
| 1068 FLAGS_quic_use_cheap_stateless_rejects = | 1068 FLAGS_quic_use_cheap_stateless_rejects = |
| 1069 GetParam().support_cheap_stateless_reject; | 1069 GetParam().support_cheap_stateless_reject; |
| 1070 FLAGS_enable_quic_stateless_reject_support = | 1070 FLAGS_enable_quic_stateless_reject_support = |
| 1071 GetParam().enable_stateless_rejects_via_flag; | 1071 GetParam().enable_stateless_rejects_via_flag; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 void SetUp() override { | 1074 void SetUp() override { |
| 1075 QuicDispatcherTest::SetUp(); | 1075 QuicDispatcherTest::SetUp(); |
| 1076 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); | 1076 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); |
| 1077 | 1077 |
| 1078 QuicVersion version = AllSupportedVersions().front(); | 1078 QuicVersion version = AllSupportedVersions().front(); |
| 1079 CryptoHandshakeMessage chlo = CryptoTestUtils::GenerateDefaultInchoateCHLO( | 1079 CryptoHandshakeMessage chlo = CryptoTestUtils::GenerateDefaultInchoateCHLO( |
| 1080 clock_, version, &crypto_config_); | 1080 clock_, version, &crypto_config_); |
| 1081 chlo.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); | 1081 chlo.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); |
| 1082 // Pass an inchoate CHLO. | 1082 // Pass an inchoate CHLO. |
| 1083 CryptoTestUtils::GenerateFullCHLO( | 1083 CryptoTestUtils::GenerateFullCHLO( |
| 1084 chlo, &crypto_config_, server_ip_, client_addr_, version, clock_, | 1084 chlo, &crypto_config_, server_ip_, client_addr_, version, clock_, |
| 1085 proof_, QuicDispatcherPeer::GetCache(dispatcher_.get()), &full_chlo_); | 1085 signed_config_, QuicDispatcherPeer::GetCache(dispatcher_.get()), |
| 1086 &full_chlo_); |
| 1086 } | 1087 } |
| 1087 | 1088 |
| 1088 string SerializeFullCHLO() { | 1089 string SerializeFullCHLO() { |
| 1089 return full_chlo_.GetSerialized().AsStringPiece().as_string(); | 1090 return full_chlo_.GetSerialized().AsStringPiece().as_string(); |
| 1090 } | 1091 } |
| 1091 | 1092 |
| 1092 protected: | 1093 protected: |
| 1093 IPAddress server_ip_; | 1094 IPAddress server_ip_; |
| 1094 IPEndPoint client_addr_; | 1095 IPEndPoint client_addr_; |
| 1095 scoped_refptr<QuicCryptoProof> proof_; | 1096 scoped_refptr<QuicSignedServerConfig> signed_config_; |
| 1096 const QuicClock* clock_; | 1097 const QuicClock* clock_; |
| 1097 CryptoHandshakeMessage full_chlo_; | 1098 CryptoHandshakeMessage full_chlo_; |
| 1098 }; | 1099 }; |
| 1099 | 1100 |
| 1100 INSTANTIATE_TEST_CASE_P( | 1101 INSTANTIATE_TEST_CASE_P( |
| 1101 BufferedPacketStoreTests, | 1102 BufferedPacketStoreTests, |
| 1102 BufferedPacketStoreTest, | 1103 BufferedPacketStoreTest, |
| 1103 ::testing::ValuesIn(GetBufferedPacketStoreTestParams())); | 1104 ::testing::ValuesIn(GetBufferedPacketStoreTestParams())); |
| 1104 | 1105 |
| 1105 TEST_P(BufferedPacketStoreTest, ProcessNonChloPacketsUptoLimitAndProcessChlo) { | 1106 TEST_P(BufferedPacketStoreTest, ProcessNonChloPacketsUptoLimitAndProcessChlo) { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 | 1506 |
| 1506 // Test which exercises the async GetProof codepaths, especially in the context | 1507 // Test which exercises the async GetProof codepaths, especially in the context |
| 1507 // of stateless rejection. | 1508 // of stateless rejection. |
| 1508 class AsyncGetProofTest : public QuicDispatcherTest { | 1509 class AsyncGetProofTest : public QuicDispatcherTest { |
| 1509 public: | 1510 public: |
| 1510 AsyncGetProofTest() | 1511 AsyncGetProofTest() |
| 1511 : QuicDispatcherTest( | 1512 : QuicDispatcherTest( |
| 1512 std::unique_ptr<FakeProofSource>(new FakeProofSource())), | 1513 std::unique_ptr<FakeProofSource>(new FakeProofSource())), |
| 1513 client_addr_(net::test::Loopback4(), 1234), | 1514 client_addr_(net::test::Loopback4(), 1234), |
| 1514 crypto_config_peer_(&crypto_config_), | 1515 crypto_config_peer_(&crypto_config_), |
| 1515 proof_(new QuicCryptoProof) { | 1516 signed_config_(new QuicSignedServerConfig) { |
| 1516 FLAGS_enable_async_get_proof = true; | 1517 FLAGS_enable_async_get_proof = true; |
| 1517 FLAGS_enable_quic_stateless_reject_support = true; | 1518 FLAGS_enable_quic_stateless_reject_support = true; |
| 1518 FLAGS_quic_use_cheap_stateless_rejects = true; | 1519 FLAGS_quic_use_cheap_stateless_rejects = true; |
| 1519 FLAGS_quic_create_session_after_insertion = true; | 1520 FLAGS_quic_create_session_after_insertion = true; |
| 1520 } | 1521 } |
| 1521 | 1522 |
| 1522 void SetUp() override { | 1523 void SetUp() override { |
| 1523 QuicDispatcherTest::SetUp(); | 1524 QuicDispatcherTest::SetUp(); |
| 1524 | 1525 |
| 1525 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); | 1526 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); |
| 1526 QuicVersion version = AllSupportedVersions().front(); | 1527 QuicVersion version = AllSupportedVersions().front(); |
| 1527 chlo_ = CryptoTestUtils::GenerateDefaultInchoateCHLO(clock_, version, | 1528 chlo_ = CryptoTestUtils::GenerateDefaultInchoateCHLO(clock_, version, |
| 1528 &crypto_config_); | 1529 &crypto_config_); |
| 1529 chlo_.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); | 1530 chlo_.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); |
| 1530 // Pass an inchoate CHLO. | 1531 // Pass an inchoate CHLO. |
| 1531 CryptoTestUtils::GenerateFullCHLO( | 1532 CryptoTestUtils::GenerateFullCHLO( |
| 1532 chlo_, &crypto_config_, server_ip_, client_addr_, version, clock_, | 1533 chlo_, &crypto_config_, server_ip_, client_addr_, version, clock_, |
| 1533 proof_, QuicDispatcherPeer::GetCache(dispatcher_.get()), &full_chlo_); | 1534 signed_config_, QuicDispatcherPeer::GetCache(dispatcher_.get()), |
| 1535 &full_chlo_); |
| 1534 | 1536 |
| 1535 GetFakeProofSource()->Activate(); | 1537 GetFakeProofSource()->Activate(); |
| 1536 } | 1538 } |
| 1537 | 1539 |
| 1538 FakeProofSource* GetFakeProofSource() const { | 1540 FakeProofSource* GetFakeProofSource() const { |
| 1539 return static_cast<FakeProofSource*>(crypto_config_peer_.GetProofSource()); | 1541 return static_cast<FakeProofSource*>(crypto_config_peer_.GetProofSource()); |
| 1540 } | 1542 } |
| 1541 | 1543 |
| 1542 string SerializeFullCHLO() { | 1544 string SerializeFullCHLO() { |
| 1543 return full_chlo_.GetSerialized().AsStringPiece().as_string(); | 1545 return full_chlo_.GetSerialized().AsStringPiece().as_string(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1573 CHECK(ok); | 1575 CHECK(ok); |
| 1574 return session; | 1576 return session; |
| 1575 } | 1577 } |
| 1576 | 1578 |
| 1577 protected: | 1579 protected: |
| 1578 const IPEndPoint client_addr_; | 1580 const IPEndPoint client_addr_; |
| 1579 | 1581 |
| 1580 private: | 1582 private: |
| 1581 QuicCryptoServerConfigPeer crypto_config_peer_; | 1583 QuicCryptoServerConfigPeer crypto_config_peer_; |
| 1582 IPAddress server_ip_; | 1584 IPAddress server_ip_; |
| 1583 scoped_refptr<QuicCryptoProof> proof_; | 1585 scoped_refptr<QuicSignedServerConfig> signed_config_; |
| 1584 const QuicClock* clock_; | 1586 const QuicClock* clock_; |
| 1585 CryptoHandshakeMessage chlo_; | 1587 CryptoHandshakeMessage chlo_; |
| 1586 CryptoHandshakeMessage full_chlo_; | 1588 CryptoHandshakeMessage full_chlo_; |
| 1587 | 1589 |
| 1588 struct SessionInfo { | 1590 struct SessionInfo { |
| 1589 TestQuicSpdyServerSession* session; | 1591 TestQuicSpdyServerSession* session; |
| 1590 std::unique_ptr<MockQuicCryptoServerStream> crypto_stream; | 1592 std::unique_ptr<MockQuicCryptoServerStream> crypto_stream; |
| 1591 }; | 1593 }; |
| 1592 std::map<QuicConnectionId, SessionInfo> sessions_; | 1594 std::map<QuicConnectionId, SessionInfo> sessions_; |
| 1593 }; | 1595 }; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1984 check.Call(2); | 1986 check.Call(2); |
| 1985 GetFakeProofSource()->InvokePendingCallback(0); | 1987 GetFakeProofSource()->InvokePendingCallback(0); |
| 1986 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); | 1988 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); |
| 1987 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); | 1989 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); |
| 1988 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); | 1990 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); |
| 1989 } | 1991 } |
| 1990 | 1992 |
| 1991 } // namespace | 1993 } // namespace |
| 1992 } // namespace test | 1994 } // namespace test |
| 1993 } // namespace net | 1995 } // namespace net |
| OLD | NEW |