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

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: Feedback eroman 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().bytes(), 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().bytes(),
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().bytes(), 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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 "VER\0", client_version_string_.c_str(), 1160 "VER\0", client_version_string_.c_str(),
1161 "$padding", static_cast<int>(kClientHelloMinimumSize), 1161 "$padding", static_cast<int>(kClientHelloMinimumSize),
1162 nullptr); 1162 nullptr);
1163 // clang-format on 1163 // clang-format on
1164 1164
1165 // Clear the message tag. 1165 // Clear the message tag.
1166 out_.set_tag(0); 1166 out_.set_tag(0);
1167 1167
1168 bool called = false; 1168 bool called = false;
1169 IPAddressNumber server_ip; 1169 IPAddressNumber server_ip;
1170 config_.ValidateClientHello(msg, client_address_.address(), server_ip, 1170 config_.ValidateClientHello(msg, client_address_.address().bytes(), server_ip,
1171 client_version_, &clock_, &crypto_proof_, 1171 client_version_, &clock_, &crypto_proof_,
1172 new ValidateCallback(this, true, "", &called)); 1172 new ValidateCallback(this, true, "", &called));
1173 // The verification request was queued. 1173 // The verification request was queued.
1174 ASSERT_FALSE(called); 1174 ASSERT_FALSE(called);
1175 EXPECT_EQ(0u, out_.tag()); 1175 EXPECT_EQ(0u, out_.tag());
1176 EXPECT_EQ(1, strike_register_client_->PendingVerifications()); 1176 EXPECT_EQ(1, strike_register_client_->PendingVerifications());
1177 1177
1178 // Continue processing the verification request. 1178 // Continue processing the verification request.
1179 strike_register_client_->RunPendingVerifications(); 1179 strike_register_client_->RunPendingVerifications();
1180 ASSERT_TRUE(called); 1180 ASSERT_TRUE(called);
1181 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); 1181 EXPECT_EQ(0, strike_register_client_->PendingVerifications());
1182 // The message should be accepted now. 1182 // The message should be accepted now.
1183 EXPECT_EQ(kSHLO, out_.tag()); 1183 EXPECT_EQ(kSHLO, out_.tag());
1184 1184
1185 // Rejected if replayed. 1185 // Rejected if replayed.
1186 config_.ValidateClientHello(msg, client_address_.address(), server_ip, 1186 config_.ValidateClientHello(msg, client_address_.address().bytes(), server_ip,
1187 client_version_, &clock_, &crypto_proof_, 1187 client_version_, &clock_, &crypto_proof_,
1188 new ValidateCallback(this, true, "", &called)); 1188 new ValidateCallback(this, true, "", &called));
1189 // The verification request was queued. 1189 // The verification request was queued.
1190 ASSERT_FALSE(called); 1190 ASSERT_FALSE(called);
1191 EXPECT_EQ(1, strike_register_client_->PendingVerifications()); 1191 EXPECT_EQ(1, strike_register_client_->PendingVerifications());
1192 1192
1193 strike_register_client_->RunPendingVerifications(); 1193 strike_register_client_->RunPendingVerifications();
1194 ASSERT_TRUE(called); 1194 ASSERT_TRUE(called);
1195 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); 1195 EXPECT_EQ(0, strike_register_client_->PendingVerifications());
1196 // The message should be rejected now. 1196 // The message should be rejected now.
1197 CheckRejectTag(); 1197 CheckRejectTag();
1198 } 1198 }
1199 1199
1200 } // namespace test 1200 } // namespace test
1201 } // namespace net 1201 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698