| OLD | NEW |
| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 bool should_succeed, | 194 bool should_succeed, |
| 195 const char* error_substr, | 195 const char* error_substr, |
| 196 bool* called) | 196 bool* called) |
| 197 : test_(test), | 197 : test_(test), |
| 198 should_succeed_(should_succeed), | 198 should_succeed_(should_succeed), |
| 199 error_substr_(error_substr), | 199 error_substr_(error_substr), |
| 200 called_(called) { | 200 called_(called) { |
| 201 *called_ = false; | 201 *called_ = false; |
| 202 } | 202 } |
| 203 | 203 |
| 204 void RunImpl(const CryptoHandshakeMessage& client_hello, | 204 void RunImpl(std::unique_ptr<Result> result, |
| 205 const Result& result, | |
| 206 std::unique_ptr<ProofSource::Details> /* details */) override { | 205 std::unique_ptr<ProofSource::Details> /* details */) override { |
| 207 { | 206 { |
| 208 // Ensure that the strike register client lock is not held. | 207 // Ensure that the strike register client lock is not held. |
| 209 QuicCryptoServerConfigPeer peer(&test_->config_); | 208 QuicCryptoServerConfigPeer peer(&test_->config_); |
| 210 base::Lock* m = peer.GetStrikeRegisterClientLock(); | 209 base::Lock* m = peer.GetStrikeRegisterClientLock(); |
| 211 // In Chromium, we will dead lock if the lock is held by the current | 210 // In Chromium, we will dead lock if the lock is held by the current |
| 212 // thread. Chromium doesn't have AssertNotHeld API call. | 211 // thread. Chromium doesn't have AssertNotHeld API call. |
| 213 // m->AssertNotHeld(); | 212 // m->AssertNotHeld(); |
| 214 base::AutoLock lock(*m); | 213 base::AutoLock lock(*m); |
| 215 } | 214 } |
| 216 ASSERT_FALSE(*called_); | 215 ASSERT_FALSE(*called_); |
| 217 test_->ProcessValidationResult(client_hello, result, should_succeed_, | 216 test_->ProcessValidationResult(*result, should_succeed_, error_substr_); |
| 218 error_substr_); | |
| 219 *called_ = true; | 217 *called_ = true; |
| 220 } | 218 } |
| 221 | 219 |
| 222 private: | 220 private: |
| 223 CryptoServerTest* test_; | 221 CryptoServerTest* test_; |
| 224 bool should_succeed_; | 222 bool should_succeed_; |
| 225 const char* error_substr_; | 223 const char* error_substr_; |
| 226 bool* called_; | 224 bool* called_; |
| 227 }; | 225 }; |
| 228 | 226 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 void ShouldFailMentioning(const char* error_substr, | 261 void ShouldFailMentioning(const char* error_substr, |
| 264 const CryptoHandshakeMessage& message, | 262 const CryptoHandshakeMessage& message, |
| 265 bool* called) { | 263 bool* called) { |
| 266 IPAddress server_ip; | 264 IPAddress server_ip; |
| 267 config_.ValidateClientHello( | 265 config_.ValidateClientHello( |
| 268 message, client_address_.address(), server_ip, | 266 message, client_address_.address(), server_ip, |
| 269 supported_versions_.front(), &clock_, &crypto_proof_, | 267 supported_versions_.front(), &clock_, &crypto_proof_, |
| 270 new ValidateCallback(this, false, error_substr, called)); | 268 new ValidateCallback(this, false, error_substr, called)); |
| 271 } | 269 } |
| 272 | 270 |
| 273 void ProcessValidationResult(const CryptoHandshakeMessage& message, | 271 void ProcessValidationResult(const ValidateCallback::Result& result, |
| 274 const ValidateCallback::Result& result, | |
| 275 bool should_succeed, | 272 bool should_succeed, |
| 276 const char* error_substr) { | 273 const char* error_substr) { |
| 277 IPAddress server_ip; | 274 IPAddress server_ip; |
| 278 DiversificationNonce diversification_nonce; | 275 DiversificationNonce diversification_nonce; |
| 279 string error_details; | 276 string error_details; |
| 280 QuicConnectionId server_designated_connection_id = | 277 QuicConnectionId server_designated_connection_id = |
| 281 rand_for_id_generation_.RandUint64(); | 278 rand_for_id_generation_.RandUint64(); |
| 282 QuicErrorCode error = config_.ProcessClientHello( | 279 QuicErrorCode error = config_.ProcessClientHello( |
| 283 result, /*reject_only=*/false, /*connection_id=*/1, server_ip, | 280 result, /*reject_only=*/false, /*connection_id=*/1, server_ip, |
| 284 client_address_, supported_versions_.front(), supported_versions_, | 281 client_address_, supported_versions_.front(), supported_versions_, |
| 285 use_stateless_rejects_, server_designated_connection_id, &clock_, rand_, | 282 use_stateless_rejects_, server_designated_connection_id, &clock_, rand_, |
| 286 &compressed_certs_cache_, ¶ms_, &crypto_proof_, | 283 &compressed_certs_cache_, ¶ms_, &crypto_proof_, |
| 287 /*total_framing_overhead=*/50, chlo_packet_size_, &out_, | 284 /*total_framing_overhead=*/50, chlo_packet_size_, &out_, |
| 288 &diversification_nonce, &error_details); | 285 &diversification_nonce, &error_details); |
| 289 | 286 |
| 290 if (should_succeed) { | 287 if (should_succeed) { |
| 291 ASSERT_EQ(error, QUIC_NO_ERROR) << "Message failed with error " | 288 ASSERT_EQ(error, QUIC_NO_ERROR) << "Message failed with error " |
| 292 << error_details << ": " | 289 << error_details << ": " |
| 293 << message.DebugString(); | 290 << result.client_hello.DebugString(); |
| 294 } else { | 291 } else { |
| 295 ASSERT_NE(error, QUIC_NO_ERROR) << "Message didn't fail: " | 292 ASSERT_NE(error, QUIC_NO_ERROR) << "Message didn't fail: " |
| 296 << message.DebugString(); | 293 << result.client_hello.DebugString(); |
| 297 | 294 |
| 298 EXPECT_TRUE(error_details.find(error_substr) != string::npos) | 295 EXPECT_TRUE(error_details.find(error_substr) != string::npos) |
| 299 << error_substr << " not in " << error_details; | 296 << error_substr << " not in " << error_details; |
| 300 } | 297 } |
| 301 } | 298 } |
| 302 | 299 |
| 303 string GenerateNonce() { | 300 string GenerateNonce() { |
| 304 string nonce; | 301 string nonce; |
| 305 CryptoUtils::GenerateNonce( | 302 CryptoUtils::GenerateNonce( |
| 306 clock_.WallNow(), rand_, | 303 clock_.WallNow(), rand_, |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); | 1241 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); |
| 1245 } else { | 1242 } else { |
| 1246 // version 33. | 1243 // version 33. |
| 1247 ASSERT_EQ(kSHLO, out_.tag()); | 1244 ASSERT_EQ(kSHLO, out_.tag()); |
| 1248 CheckServerHello(out_); | 1245 CheckServerHello(out_); |
| 1249 } | 1246 } |
| 1250 } | 1247 } |
| 1251 | 1248 |
| 1252 } // namespace test | 1249 } // namespace test |
| 1253 } // namespace net | 1250 } // namespace net |
| OLD | NEW |