Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: net/tools/quic/quic_dispatcher_test.cc

Issue 2681793002: Landing Recent QUIC changes until 5:30 PM, Feb 3, 2017 UTC-5 (Closed)
Patch Set: sync and rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_server_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 "Unregistering."); 159 "Unregistering.");
160 } 160 }
161 161
162 private: 162 private:
163 QuicDispatcher* dispatcher_; 163 QuicDispatcher* dispatcher_;
164 }; 164 };
165 165
166 class QuicDispatcherTest : public ::testing::Test { 166 class QuicDispatcherTest : public ::testing::Test {
167 public: 167 public:
168 QuicDispatcherTest() 168 QuicDispatcherTest()
169 : QuicDispatcherTest(CryptoTestUtils::ProofSourceForTesting()) {} 169 : QuicDispatcherTest(crypto_test_utils::ProofSourceForTesting()) {}
170 170
171 explicit QuicDispatcherTest(std::unique_ptr<ProofSource> proof_source) 171 explicit QuicDispatcherTest(std::unique_ptr<ProofSource> proof_source)
172 : helper_(&eps_, QuicAllocator::BUFFER_POOL), 172 : helper_(&eps_, QuicAllocator::BUFFER_POOL),
173 alarm_factory_(&eps_), 173 alarm_factory_(&eps_),
174 version_manager_(AllSupportedVersions()), 174 version_manager_(AllSupportedVersions()),
175 crypto_config_(QuicCryptoServerConfig::TESTING, 175 crypto_config_(QuicCryptoServerConfig::TESTING,
176 QuicRandom::GetInstance(), 176 QuicRandom::GetInstance(),
177 std::move(proof_source)), 177 std::move(proof_source)),
178 dispatcher_(new TestDispatcher(config_, 178 dispatcher_(new TestDispatcher(config_,
179 &crypto_config_, 179 &crypto_config_,
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 CreateSessionBasedOnTestParams(connection_id, client_address))); 812 CreateSessionBasedOnTestParams(connection_id, client_address)));
813 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), 813 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
814 ProcessUdpPacket(_, _, _)) 814 ProcessUdpPacket(_, _, _))
815 .WillOnce(testing::WithArgs<2>(Invoke(CreateFunctor( 815 .WillOnce(testing::WithArgs<2>(Invoke(CreateFunctor(
816 &QuicDispatcherTest::ValidatePacket, base::Unretained(this), 1)))); 816 &QuicDispatcherTest::ValidatePacket, base::Unretained(this), 1))));
817 } 817 }
818 818
819 QUIC_LOG(INFO) << "ExpectStatelessReject: " << ExpectStatelessReject(); 819 QUIC_LOG(INFO) << "ExpectStatelessReject: " << ExpectStatelessReject();
820 QUIC_LOG(INFO) << "Params: " << GetParam(); 820 QUIC_LOG(INFO) << "Params: " << GetParam();
821 // Process the first packet for the connection. 821 // Process the first packet for the connection.
822 // clang-format off 822 CryptoHandshakeMessage client_hello =
823 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( 823 crypto_test_utils::CreateCHLO({{"AEAD", "AESG"},
824 "CHLO", 824 {"KEXS", "C255"},
825 "AEAD", "AESG", 825 {"COPT", "SREJ"},
826 "KEXS", "C255", 826 {"NONC", "1234567890123456789012"},
827 "COPT", "SREJ", 827 {"VER\0", "Q025"}},
828 "NONC", "1234567890123456789012", 828 kClientHelloMinimumSize);
829 "VER\0", "Q025",
830 "$padding", static_cast<int>(kClientHelloMinimumSize),
831 nullptr);
832 // clang-format on
833 829
834 ProcessPacket(client_address, connection_id, true, false, 830 ProcessPacket(client_address, connection_id, true, false,
835 client_hello.GetSerialized().AsStringPiece().as_string()); 831 client_hello.GetSerialized().AsStringPiece().as_string());
836 832
837 if (GetParam().enable_stateless_rejects_via_flag) { 833 if (GetParam().enable_stateless_rejects_via_flag) {
838 EXPECT_EQ(true, 834 EXPECT_EQ(true,
839 time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); 835 time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
840 } 836 }
841 } 837 }
842 838
843 TEST_P(QuicDispatcherStatelessRejectTest, BufferNonChlo) { 839 TEST_P(QuicDispatcherStatelessRejectTest, BufferNonChlo) {
844 FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects = true; 840 FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects = true;
845 CreateTimeWaitListManager(); 841 CreateTimeWaitListManager();
846 842
847 const QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); 843 const QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1);
848 const QuicConnectionId connection_id = 1; 844 const QuicConnectionId connection_id = 1;
849 845
850 ProcessPacket(client_address, connection_id, true, false, 846 ProcessPacket(client_address, connection_id, true, false,
851 "NOT DATA FOR A CHLO"); 847 "NOT DATA FOR A CHLO");
852 848
853 // Process the first packet for the connection. 849 // Process the first packet for the connection.
854 // clang-format off 850 CryptoHandshakeMessage client_hello =
855 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( 851 crypto_test_utils::CreateCHLO({{"AEAD", "AESG"},
856 "CHLO", 852 {"KEXS", "C255"},
857 "AEAD", "AESG", 853 {"NONC", "1234567890123456789012"},
858 "KEXS", "C255", 854 {"VER\0", "Q025"}},
859 "NONC", "1234567890123456789012", 855 kClientHelloMinimumSize);
860 "VER\0", "Q025",
861 "$padding", static_cast<int>(kClientHelloMinimumSize),
862 nullptr);
863 // clang-format on
864 856
865 // If stateless rejects are enabled then a connection will be created now 857 // If stateless rejects are enabled then a connection will be created now
866 // and the buffered packet will be processed 858 // and the buffered packet will be processed
867 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) 859 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address))
868 .WillOnce(testing::Return( 860 .WillOnce(testing::Return(
869 CreateSessionBasedOnTestParams(connection_id, client_address))); 861 CreateSessionBasedOnTestParams(connection_id, client_address)));
870 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), 862 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
871 ProcessUdpPacket(_, client_address, _)) 863 ProcessUdpPacket(_, client_address, _))
872 .WillOnce(testing::WithArg<2>( 864 .WillOnce(testing::WithArg<2>(
873 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, 865 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 GetParam().support_cheap_stateless_reject; 1155 GetParam().support_cheap_stateless_reject;
1164 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support = 1156 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support =
1165 GetParam().enable_stateless_rejects_via_flag; 1157 GetParam().enable_stateless_rejects_via_flag;
1166 } 1158 }
1167 1159
1168 void SetUp() override { 1160 void SetUp() override {
1169 QuicDispatcherTest::SetUp(); 1161 QuicDispatcherTest::SetUp();
1170 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); 1162 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock();
1171 1163
1172 QuicVersion version = AllSupportedVersions().front(); 1164 QuicVersion version = AllSupportedVersions().front();
1173 CryptoHandshakeMessage chlo = CryptoTestUtils::GenerateDefaultInchoateCHLO( 1165 CryptoHandshakeMessage chlo =
1174 clock_, version, &crypto_config_); 1166 crypto_test_utils::GenerateDefaultInchoateCHLO(clock_, version,
1167 &crypto_config_);
1175 chlo.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); 1168 chlo.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ});
1176 // Pass an inchoate CHLO. 1169 // Pass an inchoate CHLO.
1177 CryptoTestUtils::GenerateFullCHLO( 1170 crypto_test_utils::GenerateFullCHLO(
1178 chlo, &crypto_config_, server_addr_, client_addr_, version, clock_, 1171 chlo, &crypto_config_, server_addr_, client_addr_, version, clock_,
1179 signed_config_, QuicDispatcherPeer::GetCache(dispatcher_.get()), 1172 signed_config_, QuicDispatcherPeer::GetCache(dispatcher_.get()),
1180 &full_chlo_); 1173 &full_chlo_);
1181 } 1174 }
1182 1175
1183 string SerializeFullCHLO() { 1176 string SerializeFullCHLO() {
1184 return full_chlo_.GetSerialized().AsStringPiece().as_string(); 1177 return full_chlo_.GetSerialized().AsStringPiece().as_string();
1185 } 1178 }
1186 1179
1187 protected: 1180 protected:
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 // Test which exercises the async GetProof codepaths, especially in the context 1596 // Test which exercises the async GetProof codepaths, especially in the context
1604 // of stateless rejection. 1597 // of stateless rejection.
1605 class AsyncGetProofTest : public QuicDispatcherTest { 1598 class AsyncGetProofTest : public QuicDispatcherTest {
1606 public: 1599 public:
1607 AsyncGetProofTest() 1600 AsyncGetProofTest()
1608 : QuicDispatcherTest( 1601 : QuicDispatcherTest(
1609 std::unique_ptr<FakeProofSource>(new FakeProofSource())), 1602 std::unique_ptr<FakeProofSource>(new FakeProofSource())),
1610 client_addr_(QuicIpAddress::Loopback4(), 1234), 1603 client_addr_(QuicIpAddress::Loopback4(), 1234),
1611 crypto_config_peer_(&crypto_config_), 1604 crypto_config_peer_(&crypto_config_),
1612 signed_config_(new QuicSignedServerConfig) { 1605 signed_config_(new QuicSignedServerConfig) {
1613 FLAGS_quic_reloadable_flag_enable_async_get_proof = true;
1614 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support = true; 1606 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support = true;
1615 FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects = true; 1607 FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects = true;
1616 FLAGS_quic_reloadable_flag_quic_create_session_after_insertion = true; 1608 FLAGS_quic_reloadable_flag_quic_create_session_after_insertion = true;
1617 } 1609 }
1618 1610
1619 void SetUp() override { 1611 void SetUp() override {
1620 QuicDispatcherTest::SetUp(); 1612 QuicDispatcherTest::SetUp();
1621 1613
1622 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); 1614 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock();
1623 QuicVersion version = AllSupportedVersions().front(); 1615 QuicVersion version = AllSupportedVersions().front();
1624 chlo_ = CryptoTestUtils::GenerateDefaultInchoateCHLO(clock_, version, 1616 chlo_ = crypto_test_utils::GenerateDefaultInchoateCHLO(clock_, version,
1625 &crypto_config_); 1617 &crypto_config_);
1626 chlo_.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ}); 1618 chlo_.SetVector(net::kCOPT, net::QuicTagVector{net::kSREJ});
1627 // Pass an inchoate CHLO. 1619 // Pass an inchoate CHLO.
1628 CryptoTestUtils::GenerateFullCHLO( 1620 crypto_test_utils::GenerateFullCHLO(
1629 chlo_, &crypto_config_, server_addr_, client_addr_, version, clock_, 1621 chlo_, &crypto_config_, server_addr_, client_addr_, version, clock_,
1630 signed_config_, QuicDispatcherPeer::GetCache(dispatcher_.get()), 1622 signed_config_, QuicDispatcherPeer::GetCache(dispatcher_.get()),
1631 &full_chlo_); 1623 &full_chlo_);
1632 1624
1633 GetFakeProofSource()->Activate(); 1625 GetFakeProofSource()->Activate();
1634 } 1626 }
1635 1627
1636 FakeProofSource* GetFakeProofSource() const { 1628 FakeProofSource* GetFakeProofSource() const {
1637 return static_cast<FakeProofSource*>(crypto_config_peer_.GetProofSource()); 1629 return static_cast<FakeProofSource*>(crypto_config_peer_.GetProofSource());
1638 } 1630 }
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 check.Call(2); 2074 check.Call(2);
2083 GetFakeProofSource()->InvokePendingCallback(0); 2075 GetFakeProofSource()->InvokePendingCallback(0);
2084 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); 2076 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0);
2085 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); 2077 EXPECT_FALSE(store->HasBufferedPackets(conn_id));
2086 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); 2078 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id));
2087 } 2079 }
2088 2080
2089 } // namespace 2081 } // namespace
2090 } // namespace test 2082 } // namespace test
2091 } // namespace net 2083 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698