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

Side by Side Diff: net/quic/core/crypto/crypto_server_test.cc

Issue 2907743003: Change CryptoHandshakeMessage::GetTaglist to tag a QuicTagVector* (Closed)
Patch Set: fix QuicConfig Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <algorithm> 5 #include <algorithm>
6 #include <cstdint> 6 #include <cstdint>
7 #include <memory> 7 #include <memory>
8 #include <ostream> 8 #include <ostream>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 private: 211 private:
212 CryptoServerTest* test_; 212 CryptoServerTest* test_;
213 const bool should_succeed_; 213 const bool should_succeed_;
214 const char* const error_substr_; 214 const char* const error_substr_;
215 bool* called_; 215 bool* called_;
216 }; 216 };
217 217
218 void CheckServerHello(const CryptoHandshakeMessage& server_hello) { 218 void CheckServerHello(const CryptoHandshakeMessage& server_hello) {
219 const QuicTag* versions; 219 QuicTagVector versions;
220 size_t num_versions; 220 server_hello.GetTaglist(kVER, &versions);
221 server_hello.GetTaglist(kVER, &versions, &num_versions); 221 ASSERT_EQ(supported_versions_.size(), versions.size());
222 ASSERT_EQ(supported_versions_.size(), num_versions); 222 for (size_t i = 0; i < versions.size(); ++i) {
223 for (size_t i = 0; i < num_versions; ++i) {
224 EXPECT_EQ(QuicVersionToQuicTag(supported_versions_[i]), versions[i]); 223 EXPECT_EQ(QuicVersionToQuicTag(supported_versions_[i]), versions[i]);
225 } 224 }
226 225
227 QuicStringPiece address; 226 QuicStringPiece address;
228 ASSERT_TRUE(server_hello.GetStringPiece(kCADR, &address)); 227 ASSERT_TRUE(server_hello.GetStringPiece(kCADR, &address));
229 QuicSocketAddressCoder decoder; 228 QuicSocketAddressCoder decoder;
230 ASSERT_TRUE(decoder.Decode(address.data(), address.size())); 229 ASSERT_TRUE(decoder.Decode(address.data(), address.size()));
231 EXPECT_EQ(client_address_.host(), decoder.ip()); 230 EXPECT_EQ(client_address_.host(), decoder.ip());
232 EXPECT_EQ(client_address_.port(), decoder.port()); 231 EXPECT_EQ(client_address_.port(), decoder.port());
233 } 232 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 CryptoUtils::GenerateNonce( 332 CryptoUtils::GenerateNonce(
334 clock_.WallNow(), rand_, 333 clock_.WallNow(), rand_,
335 QuicStringPiece(reinterpret_cast<const char*>(orbit_), sizeof(orbit_)), 334 QuicStringPiece(reinterpret_cast<const char*>(orbit_), sizeof(orbit_)),
336 &nonce); 335 &nonce);
337 return nonce; 336 return nonce;
338 } 337 }
339 338
340 void CheckRejectReasons( 339 void CheckRejectReasons(
341 const HandshakeFailureReason* expected_handshake_failures, 340 const HandshakeFailureReason* expected_handshake_failures,
342 size_t expected_count) { 341 size_t expected_count) {
343 const uint32_t* reject_reasons; 342 QuicTagVector reject_reasons;
344 size_t num_reject_reasons;
345 static_assert(sizeof(QuicTag) == sizeof(uint32_t), "header out of sync"); 343 static_assert(sizeof(QuicTag) == sizeof(uint32_t), "header out of sync");
346 QuicErrorCode error_code = 344 QuicErrorCode error_code = out_.GetTaglist(kRREJ, &reject_reasons);
347 out_.GetTaglist(kRREJ, &reject_reasons, &num_reject_reasons);
348 ASSERT_EQ(QUIC_NO_ERROR, error_code); 345 ASSERT_EQ(QUIC_NO_ERROR, error_code);
349 346
350 EXPECT_EQ(expected_count, num_reject_reasons); 347 EXPECT_EQ(expected_count, reject_reasons.size());
351 for (size_t i = 0; i < num_reject_reasons; ++i) { 348 for (size_t i = 0; i < reject_reasons.size(); ++i) {
352 EXPECT_EQ(expected_handshake_failures[i], reject_reasons[i]); 349 EXPECT_EQ(expected_handshake_failures[i], reject_reasons[i]);
353 } 350 }
354 } 351 }
355 352
356 // If the server is rejecting statelessly, make sure it contains a 353 // If the server is rejecting statelessly, make sure it contains a
357 // server-designated connection id. Once the check is complete, 354 // server-designated connection id. Once the check is complete,
358 // allow the random id-generator to move to the next value. 355 // allow the random id-generator to move to the next value.
359 void CheckForServerDesignatedConnectionId() { 356 void CheckForServerDesignatedConnectionId() {
360 QuicConnectionId server_designated_connection_id; 357 QuicConnectionId server_designated_connection_id;
361 if (!RejectsAreStateless()) { 358 if (!RejectsAreStateless()) {
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 // QuicCryptoServerConfig::EvaluateClientHello will leave info.unique as false 1087 // QuicCryptoServerConfig::EvaluateClientHello will leave info.unique as false
1091 // and cause ProcessClientHello to exit early (and generate a REJ message). 1088 // and cause ProcessClientHello to exit early (and generate a REJ message).
1092 config_.set_replay_protection(false); 1089 config_.set_replay_protection(false);
1093 1090
1094 ShouldSucceed(msg); 1091 ShouldSucceed(msg);
1095 EXPECT_EQ(kSHLO, out_.tag()); 1092 EXPECT_EQ(kSHLO, out_.tag());
1096 } 1093 }
1097 1094
1098 } // namespace test 1095 } // namespace test
1099 } // namespace net 1096 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698