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

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

Issue 1565303002: Change IPEndpoint::address() to return a net::IPAddress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android Created 4 years, 11 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 <ostream> 5 #include <ostream>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "crypto/secure_hash.h" 9 #include "crypto/secure_hash.h"
10 #include "net/quic/crypto/cert_compressor.h" 10 #include "net/quic/crypto/cert_compressor.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 server_hello.GetTaglist(kVER, &versions, &num_versions); 246 server_hello.GetTaglist(kVER, &versions, &num_versions);
247 ASSERT_EQ(supported_versions_.size(), num_versions); 247 ASSERT_EQ(supported_versions_.size(), num_versions);
248 for (size_t i = 0; i < num_versions; ++i) { 248 for (size_t i = 0; i < num_versions; ++i) {
249 EXPECT_EQ(QuicVersionToQuicTag(supported_versions_[i]), versions[i]); 249 EXPECT_EQ(QuicVersionToQuicTag(supported_versions_[i]), versions[i]);
250 } 250 }
251 251
252 StringPiece address; 252 StringPiece address;
253 ASSERT_TRUE(server_hello.GetStringPiece(kCADR, &address)); 253 ASSERT_TRUE(server_hello.GetStringPiece(kCADR, &address));
254 QuicSocketAddressCoder decoder; 254 QuicSocketAddressCoder decoder;
255 ASSERT_TRUE(decoder.Decode(address.data(), address.size())); 255 ASSERT_TRUE(decoder.Decode(address.data(), address.size()));
256 EXPECT_EQ(client_address_.address(), decoder.ip()); 256 EXPECT_EQ(client_address_.address_number(), decoder.ip());
257 EXPECT_EQ(client_address_.port(), decoder.port()); 257 EXPECT_EQ(client_address_.port(), decoder.port());
258 } 258 }
259 259
260 void ShouldSucceed(const CryptoHandshakeMessage& message) { 260 void ShouldSucceed(const CryptoHandshakeMessage& message) {
261 bool called = false; 261 bool called = false;
262 IPAddressNumber server_ip; 262 IPAddressNumber server_ip;
263 config_.ValidateClientHello(message, client_address_.address(), server_ip, 263 config_.ValidateClientHello(message, client_address_.address_number(),
264 supported_versions_.front(), &clock_, 264 server_ip, supported_versions_.front(), &clock_,
265 &crypto_proof_, 265 &crypto_proof_,
266 new ValidateCallback(this, true, "", &called)); 266 new ValidateCallback(this, true, "", &called));
267 EXPECT_TRUE(called); 267 EXPECT_TRUE(called);
268 } 268 }
269 269
270 void ShouldFailMentioning(const char* error_substr, 270 void ShouldFailMentioning(const char* error_substr,
271 const CryptoHandshakeMessage& message) { 271 const CryptoHandshakeMessage& message) {
272 bool called = false; 272 bool called = false;
273 ShouldFailMentioning(error_substr, message, &called); 273 ShouldFailMentioning(error_substr, message, &called);
274 EXPECT_TRUE(called); 274 EXPECT_TRUE(called);
275 } 275 }
276 276
277 void ShouldFailMentioning(const char* error_substr, 277 void ShouldFailMentioning(const char* error_substr,
278 const CryptoHandshakeMessage& message, 278 const CryptoHandshakeMessage& message,
279 bool* called) { 279 bool* called) {
280 IPAddressNumber server_ip; 280 IPAddressNumber server_ip;
281 config_.ValidateClientHello( 281 config_.ValidateClientHello(
282 message, client_address_.address(), server_ip, 282 message, client_address_.address_number(), server_ip,
283 supported_versions_.front(), &clock_, &crypto_proof_, 283 supported_versions_.front(), &clock_, &crypto_proof_,
284 new ValidateCallback(this, false, error_substr, called)); 284 new ValidateCallback(this, false, error_substr, called));
285 } 285 }
286 286
287 void ProcessValidationResult(const CryptoHandshakeMessage& message, 287 void ProcessValidationResult(const CryptoHandshakeMessage& message,
288 const ValidateCallback::Result& result, 288 const ValidateCallback::Result& result,
289 bool should_succeed, 289 bool should_succeed,
290 const char* error_substr) { 290 const char* error_substr) {
291 IPAddressNumber server_ip; 291 IPAddressNumber server_ip;
292 string error_details; 292 string error_details;
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 "VER\0", client_version_string_.c_str(), 1132 "VER\0", client_version_string_.c_str(),
1133 "$padding", static_cast<int>(kClientHelloMinimumSize), 1133 "$padding", static_cast<int>(kClientHelloMinimumSize),
1134 nullptr); 1134 nullptr);
1135 // clang-format on 1135 // clang-format on
1136 1136
1137 // Clear the message tag. 1137 // Clear the message tag.
1138 out_.set_tag(0); 1138 out_.set_tag(0);
1139 1139
1140 bool called = false; 1140 bool called = false;
1141 IPAddressNumber server_ip; 1141 IPAddressNumber server_ip;
1142 config_.ValidateClientHello(msg, client_address_.address(), server_ip, 1142 config_.ValidateClientHello(msg, client_address_.address_number(), server_ip,
1143 client_version_, &clock_, &crypto_proof_, 1143 client_version_, &clock_, &crypto_proof_,
1144 new ValidateCallback(this, true, "", &called)); 1144 new ValidateCallback(this, true, "", &called));
1145 // The verification request was queued. 1145 // The verification request was queued.
1146 ASSERT_FALSE(called); 1146 ASSERT_FALSE(called);
1147 EXPECT_EQ(0u, out_.tag()); 1147 EXPECT_EQ(0u, out_.tag());
1148 EXPECT_EQ(1, strike_register_client_->PendingVerifications()); 1148 EXPECT_EQ(1, strike_register_client_->PendingVerifications());
1149 1149
1150 // Continue processing the verification request. 1150 // Continue processing the verification request.
1151 strike_register_client_->RunPendingVerifications(); 1151 strike_register_client_->RunPendingVerifications();
1152 ASSERT_TRUE(called); 1152 ASSERT_TRUE(called);
1153 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); 1153 EXPECT_EQ(0, strike_register_client_->PendingVerifications());
1154 // The message should be accepted now. 1154 // The message should be accepted now.
1155 EXPECT_EQ(kSHLO, out_.tag()); 1155 EXPECT_EQ(kSHLO, out_.tag());
1156 1156
1157 // Rejected if replayed. 1157 // Rejected if replayed.
1158 config_.ValidateClientHello(msg, client_address_.address(), server_ip, 1158 config_.ValidateClientHello(msg, client_address_.address_number(), server_ip,
1159 client_version_, &clock_, &crypto_proof_, 1159 client_version_, &clock_, &crypto_proof_,
1160 new ValidateCallback(this, true, "", &called)); 1160 new ValidateCallback(this, true, "", &called));
1161 // The verification request was queued. 1161 // The verification request was queued.
1162 ASSERT_FALSE(called); 1162 ASSERT_FALSE(called);
1163 EXPECT_EQ(1, strike_register_client_->PendingVerifications()); 1163 EXPECT_EQ(1, strike_register_client_->PendingVerifications());
1164 1164
1165 strike_register_client_->RunPendingVerifications(); 1165 strike_register_client_->RunPendingVerifications();
1166 ASSERT_TRUE(called); 1166 ASSERT_TRUE(called);
1167 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); 1167 EXPECT_EQ(0, strike_register_client_->PendingVerifications());
1168 // The message should be rejected now. 1168 // The message should be rejected now.
1169 CheckRejectTag(); 1169 CheckRejectTag();
1170 } 1170 }
1171 1171
1172 } // namespace test 1172 } // namespace test
1173 } // namespace net 1173 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698