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

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

Issue 1415933006: QUIC - delete #ifdef USE_OPENSSL in unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 5 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/quic/crypto/proof_test.cc ('k') | net/quic/quic_chromium_client_session_test.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "net/quic/crypto/quic_crypto_server_config.h" 5 #include "net/quic/crypto/quic_crypto_server_config.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 bool is_known_orbit_called() { return is_known_orbit_called_; } 213 bool is_known_orbit_called() { return is_known_orbit_called_; }
214 214
215 private: 215 private:
216 QuicCryptoServerConfig* config_; 216 QuicCryptoServerConfig* config_;
217 mutable bool is_known_orbit_called_; 217 mutable bool is_known_orbit_called_;
218 }; 218 };
219 219
220 TEST(QuicCryptoServerConfigTest, ServerConfig) { 220 TEST(QuicCryptoServerConfigTest, ServerConfig) {
221 QuicRandom* rand = QuicRandom::GetInstance(); 221 QuicRandom* rand = QuicRandom::GetInstance();
222 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, 222 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
223 #if defined(USE_OPENSSL)
224 CryptoTestUtils::ProofSourceForTesting()); 223 CryptoTestUtils::ProofSourceForTesting());
225 #else
226 CryptoTestUtils::FakeProofSourceForTesting());
227 #endif
228 MockClock clock; 224 MockClock clock;
229 225
230 scoped_ptr<CryptoHandshakeMessage>( 226 scoped_ptr<CryptoHandshakeMessage>(
231 server.AddDefaultConfig(rand, &clock, 227 server.AddDefaultConfig(rand, &clock,
232 QuicCryptoServerConfig::ConfigOptions())); 228 QuicCryptoServerConfig::ConfigOptions()));
233 } 229 }
234 230
235 TEST(QuicCryptoServerConfigTest, GetOrbitIsCalledWithoutTheStrikeRegisterLock) { 231 TEST(QuicCryptoServerConfigTest, GetOrbitIsCalledWithoutTheStrikeRegisterLock) {
236 QuicRandom* rand = QuicRandom::GetInstance(); 232 QuicRandom* rand = QuicRandom::GetInstance();
237 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, 233 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
238 #if defined(USE_OPENSSL)
239 CryptoTestUtils::ProofSourceForTesting()); 234 CryptoTestUtils::ProofSourceForTesting());
240 #else
241 CryptoTestUtils::FakeProofSourceForTesting());
242 #endif
243 MockClock clock; 235 MockClock clock;
244 236
245 TestStrikeRegisterClient* strike_register = 237 TestStrikeRegisterClient* strike_register =
246 new TestStrikeRegisterClient(&server); 238 new TestStrikeRegisterClient(&server);
247 server.SetStrikeRegisterClient(strike_register); 239 server.SetStrikeRegisterClient(strike_register);
248 240
249 QuicCryptoServerConfig::ConfigOptions options; 241 QuicCryptoServerConfig::ConfigOptions options;
250 scoped_ptr<CryptoHandshakeMessage> message( 242 scoped_ptr<CryptoHandshakeMessage> message(
251 server.AddDefaultConfig(rand, &clock, options)); 243 server.AddDefaultConfig(rand, &clock, options));
252 EXPECT_TRUE(strike_register->is_known_orbit_called()); 244 EXPECT_TRUE(strike_register->is_known_orbit_called());
253 } 245 }
254 246
255 class SourceAddressTokenTest : public ::testing::Test { 247 class SourceAddressTokenTest : public ::testing::Test {
256 public: 248 public:
257 SourceAddressTokenTest() 249 SourceAddressTokenTest()
258 : ip4_(Loopback4()), 250 : ip4_(Loopback4()),
259 ip4_dual_(ConvertIPv4NumberToIPv6Number(ip4_)), 251 ip4_dual_(ConvertIPv4NumberToIPv6Number(ip4_)),
260 ip6_(Loopback6()), 252 ip6_(Loopback6()),
261 original_time_(QuicWallTime::Zero()), 253 original_time_(QuicWallTime::Zero()),
262 rand_(QuicRandom::GetInstance()), 254 rand_(QuicRandom::GetInstance()),
263 server_(QuicCryptoServerConfig::TESTING, 255 server_(QuicCryptoServerConfig::TESTING,
264 rand_, 256 rand_,
265 #if defined(USE_OPENSSL)
266 CryptoTestUtils::ProofSourceForTesting()), 257 CryptoTestUtils::ProofSourceForTesting()),
267 #else
268 CryptoTestUtils::FakeProofSourceForTesting()),
269 #endif
270 peer_(&server_) { 258 peer_(&server_) {
271 // Advance the clock to some non-zero time. 259 // Advance the clock to some non-zero time.
272 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000000)); 260 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000000));
273 original_time_ = clock_.WallNow(); 261 original_time_ = clock_.WallNow();
274 262
275 primary_config_.reset(server_.AddDefaultConfig( 263 primary_config_.reset(server_.AddDefaultConfig(
276 rand_, &clock_, QuicCryptoServerConfig::ConfigOptions())); 264 rand_, &clock_, QuicCryptoServerConfig::ConfigOptions()));
277 265
278 // Add a config that overrides the default boxer. 266 // Add a config that overrides the default boxer.
279 QuicCryptoServerConfig::ConfigOptions options; 267 QuicCryptoServerConfig::ConfigOptions options;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 421
434 EXPECT_EQ(HANDSHAKE_OK, 422 EXPECT_EQ(HANDSHAKE_OK,
435 ValidateSourceAddressTokens(kPrimary, token4or6, ip4_)); 423 ValidateSourceAddressTokens(kPrimary, token4or6, ip4_));
436 ASSERT_EQ(HANDSHAKE_OK, 424 ASSERT_EQ(HANDSHAKE_OK,
437 ValidateSourceAddressTokens(kPrimary, token4or6, ip6_)); 425 ValidateSourceAddressTokens(kPrimary, token4or6, ip6_));
438 } 426 }
439 427
440 TEST(QuicCryptoServerConfigTest, ValidateServerNonce) { 428 TEST(QuicCryptoServerConfigTest, ValidateServerNonce) {
441 QuicRandom* rand = QuicRandom::GetInstance(); 429 QuicRandom* rand = QuicRandom::GetInstance();
442 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand, 430 QuicCryptoServerConfig server(QuicCryptoServerConfig::TESTING, rand,
443 #if defined(USE_OPENSSL)
444 CryptoTestUtils::ProofSourceForTesting()); 431 CryptoTestUtils::ProofSourceForTesting());
445 #else
446 CryptoTestUtils::FakeProofSourceForTesting());
447 #endif
448 QuicCryptoServerConfigPeer peer(&server); 432 QuicCryptoServerConfigPeer peer(&server);
449 433
450 StringPiece message("hello world"); 434 StringPiece message("hello world");
451 const size_t key_size = CryptoSecretBoxer::GetKeySize(); 435 const size_t key_size = CryptoSecretBoxer::GetKeySize();
452 scoped_ptr<uint8[]> key(new uint8[key_size]); 436 scoped_ptr<uint8[]> key(new uint8[key_size]);
453 memset(key.get(), 0x11, key_size); 437 memset(key.get(), 0x11, key_size);
454 438
455 CryptoSecretBoxer boxer; 439 CryptoSecretBoxer boxer;
456 boxer.SetKey(StringPiece(reinterpret_cast<char*>(key.get()), key_size)); 440 boxer.SetKey(StringPiece(reinterpret_cast<char*>(key.get()), key_size));
457 const string box = boxer.Box(rand, message); 441 const string box = boxer.Box(rand, message);
(...skipping 12 matching lines...) Expand all
470 server_nonce = peer.NewServerNonce(rand, now); 454 server_nonce = peer.NewServerNonce(rand, now);
471 EXPECT_EQ(HANDSHAKE_OK, peer.ValidateServerNonce(server_nonce, now)); 455 EXPECT_EQ(HANDSHAKE_OK, peer.ValidateServerNonce(server_nonce, now));
472 } 456 }
473 457
474 class CryptoServerConfigsTest : public ::testing::Test { 458 class CryptoServerConfigsTest : public ::testing::Test {
475 public: 459 public:
476 CryptoServerConfigsTest() 460 CryptoServerConfigsTest()
477 : rand_(QuicRandom::GetInstance()), 461 : rand_(QuicRandom::GetInstance()),
478 config_(QuicCryptoServerConfig::TESTING, 462 config_(QuicCryptoServerConfig::TESTING,
479 rand_, 463 rand_,
480 #if defined(USE_OPENSSL)
481 CryptoTestUtils::ProofSourceForTesting()), 464 CryptoTestUtils::ProofSourceForTesting()),
482 #else
483 CryptoTestUtils::FakeProofSourceForTesting()),
484 #endif
485 test_peer_(&config_) { 465 test_peer_(&config_) {
486 } 466 }
487 467
488 void SetUp() override { 468 void SetUp() override {
489 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000)); 469 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1000));
490 } 470 }
491 471
492 // SetConfigs constructs suitable config protobufs and calls SetConfigs on 472 // SetConfigs constructs suitable config protobufs and calls SetConfigs on
493 // |config_|. The arguments are given as nullptr-terminated pairs. The first 473 // |config_|. The arguments are given as nullptr-terminated pairs. The first
494 // of each pair is the server config ID of a Config. The second is the 474 // of each pair is the server config ID of a Config. The second is the
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 nullptr); 758 nullptr);
779 test_peer_.CheckConfigs( 759 test_peer_.CheckConfigs(
780 "a", false, 760 "a", false,
781 "b", true, 761 "b", true,
782 "c", false, 762 "c", false,
783 nullptr); 763 nullptr);
784 } 764 }
785 765
786 } // namespace test 766 } // namespace test
787 } // namespace net 767 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/proof_test.cc ('k') | net/quic/quic_chromium_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698