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

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

Issue 2516033003: Landing Recent QUIC changes until Mon Nov 14 04:43:50 2016 +0000 (Closed)
Patch Set: Remove unused UpdatePacketGapSentHistogram() function. Created 4 years, 1 month 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/stateless_rejector.cc ('k') | net/tools/quic/test_tools/server_thread.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/stateless_rejector.h" 5 #include "net/tools/quic/stateless_rejector.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 GetParam().flags == ENABLED || GetParam().flags == STATELESS_DISABLED; 96 GetParam().flags == ENABLED || GetParam().flags == STATELESS_DISABLED;
97 97
98 // Add a new primary config. 98 // Add a new primary config.
99 std::unique_ptr<CryptoHandshakeMessage> msg(config_.AddDefaultConfig( 99 std::unique_ptr<CryptoHandshakeMessage> msg(config_.AddDefaultConfig(
100 QuicRandom::GetInstance(), &clock_, config_options_)); 100 QuicRandom::GetInstance(), &clock_, config_options_));
101 101
102 // Save the server config. 102 // Save the server config.
103 scid_hex_ = "#" + QuicUtils::HexEncode(config_peer_.GetPrimaryConfig()->id); 103 scid_hex_ = "#" + QuicUtils::HexEncode(config_peer_.GetPrimaryConfig()->id);
104 104
105 // Encode the QUIC version. 105 // Encode the QUIC version.
106 ver_hex_ = QuicUtils::TagToString(QuicVersionToQuicTag(GetParam().version)); 106 ver_hex_ = QuicTagToString(QuicVersionToQuicTag(GetParam().version));
107 107
108 // Generate a public value. 108 // Generate a public value.
109 char public_value[32]; 109 char public_value[32];
110 memset(public_value, 42, sizeof(public_value)); 110 memset(public_value, 42, sizeof(public_value));
111 pubs_hex_ = "#" + QuicUtils::HexEncode(public_value, sizeof(public_value)); 111 pubs_hex_ = "#" + QuicUtils::HexEncode(public_value, sizeof(public_value));
112 112
113 // Generate a client nonce. 113 // Generate a client nonce.
114 string nonce; 114 string nonce;
115 CryptoUtils::GenerateNonce( 115 CryptoUtils::GenerateNonce(
116 clock_.WallNow(), QuicRandom::GetInstance(), 116 clock_.WallNow(), QuicRandom::GetInstance(),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // clang-format off 169 // clang-format off
170 const CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( 170 const CryptoHandshakeMessage client_hello = CryptoTestUtils::Message(
171 "CHLO", 171 "CHLO",
172 "PDMD", "X509", 172 "PDMD", "X509",
173 "COPT", "SREJ", 173 "COPT", "SREJ",
174 nullptr); 174 nullptr);
175 // clang-format on 175 // clang-format on
176 rejector_->OnChlo(GetParam().version, kConnectionId, 176 rejector_->OnChlo(GetParam().version, kConnectionId,
177 kServerDesignateConnectionId, client_hello); 177 kServerDesignateConnectionId, client_hello);
178 178
179 if (GetParam().flags != ENABLED || GetParam().version <= QUIC_VERSION_32) { 179 if (GetParam().flags != ENABLED) {
180 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state()); 180 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state());
181 return; 181 return;
182 } 182 }
183 183
184 // The StatelessRejector is undecided - proceed with async processing 184 // The StatelessRejector is undecided - proceed with async processing
185 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state()); 185 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state());
186 StatelessRejector::Process(std::move(rejector_), 186 StatelessRejector::Process(std::move(rejector_),
187 base::MakeUnique<ProcessDoneCallback>(this)); 187 base::MakeUnique<ProcessDoneCallback>(this));
188 188
189 EXPECT_EQ(StatelessRejector::FAILED, rejector_->state()); 189 EXPECT_EQ(StatelessRejector::FAILED, rejector_->state());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 "PUBS", pubs_hex_.c_str(), 221 "PUBS", pubs_hex_.c_str(),
222 "NONC", nonc_hex_.c_str(), 222 "NONC", nonc_hex_.c_str(),
223 "#004b5453", stk_hex_.c_str(), 223 "#004b5453", stk_hex_.c_str(),
224 "VER\0", ver_hex_.c_str(), 224 "VER\0", ver_hex_.c_str(),
225 "$padding", static_cast<int>(kClientHelloMinimumSize), 225 "$padding", static_cast<int>(kClientHelloMinimumSize),
226 nullptr); 226 nullptr);
227 // clang-format on 227 // clang-format on
228 228
229 rejector_->OnChlo(GetParam().version, kConnectionId, 229 rejector_->OnChlo(GetParam().version, kConnectionId,
230 kServerDesignateConnectionId, client_hello); 230 kServerDesignateConnectionId, client_hello);
231 if (GetParam().flags != ENABLED || GetParam().version <= QUIC_VERSION_32) { 231 if (GetParam().flags != ENABLED) {
232 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state()); 232 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state());
233 return; 233 return;
234 } 234 }
235 235
236 // The StatelessRejector is undecided - proceed with async processing 236 // The StatelessRejector is undecided - proceed with async processing
237 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state()); 237 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state());
238 StatelessRejector::Process(std::move(rejector_), 238 StatelessRejector::Process(std::move(rejector_),
239 base::MakeUnique<ProcessDoneCallback>(this)); 239 base::MakeUnique<ProcessDoneCallback>(this));
240 240
241 ASSERT_EQ(StatelessRejector::REJECTED, rejector_->state()); 241 ASSERT_EQ(StatelessRejector::REJECTED, rejector_->state());
(...skipping 25 matching lines...) Expand all
267 "NONC", nonc_hex_.c_str(), 267 "NONC", nonc_hex_.c_str(),
268 "#004b5453", stk_hex_.c_str(), 268 "#004b5453", stk_hex_.c_str(),
269 "VER\0", ver_hex_.c_str(), 269 "VER\0", ver_hex_.c_str(),
270 "XLCT", xlct_hex.c_str(), 270 "XLCT", xlct_hex.c_str(),
271 "$padding", static_cast<int>(kClientHelloMinimumSize), 271 "$padding", static_cast<int>(kClientHelloMinimumSize),
272 nullptr); 272 nullptr);
273 // clang-format on 273 // clang-format on
274 274
275 rejector_->OnChlo(GetParam().version, kConnectionId, 275 rejector_->OnChlo(GetParam().version, kConnectionId,
276 kServerDesignateConnectionId, client_hello); 276 kServerDesignateConnectionId, client_hello);
277 if (GetParam().flags != ENABLED || GetParam().version <= QUIC_VERSION_32) { 277 if (GetParam().flags != ENABLED) {
278 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state()); 278 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state());
279 return; 279 return;
280 } 280 }
281 281
282 // The StatelessRejector is undecided - proceed with async processing 282 // The StatelessRejector is undecided - proceed with async processing
283 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state()); 283 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state());
284 StatelessRejector::Process(std::move(rejector_), 284 StatelessRejector::Process(std::move(rejector_),
285 base::MakeUnique<ProcessDoneCallback>(this)); 285 base::MakeUnique<ProcessDoneCallback>(this));
286 286
287 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_->state()); 287 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_->state());
288 } 288 }
289 289
290 } // namespace 290 } // namespace
291 } // namespace test 291 } // namespace test
292 } // namespace net 292 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/stateless_rejector.cc ('k') | net/tools/quic/test_tools/server_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698