| 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 "net/quic/crypto/crypto_server_config.h" | 5 #include "net/quic/crypto/crypto_server_config.h" |
| 6 #include "net/quic/crypto/quic_random.h" | 6 #include "net/quic/crypto/quic_random.h" |
| 7 #include "net/quic/test_tools/crypto_test_utils.h" | 7 #include "net/quic/test_tools/crypto_test_utils.h" |
| 8 #include "net/quic/test_tools/mock_clock.h" | 8 #include "net/quic/test_tools/mock_clock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 using std::string; | 11 using std::string; |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 namespace test { | 14 namespace test { |
| 15 | 15 |
| 16 class CryptoServerTest : public ::testing::Test { | 16 class CryptoServerTest : public ::testing::Test { |
| 17 public: | 17 public: |
| 18 CryptoServerTest() | 18 CryptoServerTest() |
| 19 : rand_(QuicRandom::GetInstance()), | 19 : rand_(QuicRandom::GetInstance()), |
| 20 config_(QuicCryptoServerConfig::TESTING), | 20 config_(QuicCryptoServerConfig::TESTING, rand_), |
| 21 addr_(ParseIPLiteralToNumber("192.0.2.33", &ip_) ? | 21 addr_(ParseIPLiteralToNumber("192.0.2.33", &ip_) ? |
| 22 ip_ : IPAddressNumber(), 1) { | 22 ip_ : IPAddressNumber(), 1) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 virtual void SetUp() { | 25 virtual void SetUp() { |
| 26 scoped_ptr<CryptoHandshakeMessage> msg( | 26 scoped_ptr<CryptoHandshakeMessage> msg( |
| 27 config_.AddDefaultConfig(rand_, &clock_, 0)); | 27 config_.AddDefaultConfig(rand_, &clock_, |
| 28 QuicCryptoServerConfig::ConfigOptions())); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void ShouldSucceed(const CryptoHandshakeMessage& message) { | 31 void ShouldSucceed(const CryptoHandshakeMessage& message) { |
| 31 string error_details; | 32 string error_details; |
| 32 QuicErrorCode error = config_.ProcessClientHello( | 33 QuicErrorCode error = config_.ProcessClientHello( |
| 33 message, 1 /* GUID */, addr_, &clock_, | 34 message, 1 /* GUID */, addr_, &clock_, |
| 34 rand_, ¶ms_, &out_, &error_details); | 35 rand_, ¶ms_, &out_, &error_details); |
| 35 | 36 |
| 36 ASSERT_EQ(error, QUIC_NO_ERROR) | 37 ASSERT_EQ(error, QUIC_NO_ERROR) |
| 37 << "Message failed with error " << error_details << ": " | 38 << "Message failed with error " << error_details << ": " |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 }; | 140 }; |
| 140 | 141 |
| 141 TEST_F(CryptoServerTestNoConfig, DontCrash) { | 142 TEST_F(CryptoServerTestNoConfig, DontCrash) { |
| 142 ShouldFailMentioning("No config", InchoateClientHello( | 143 ShouldFailMentioning("No config", InchoateClientHello( |
| 143 "CHLO", | 144 "CHLO", |
| 144 NULL)); | 145 NULL)); |
| 145 } | 146 } |
| 146 | 147 |
| 147 } // namespace test | 148 } // namespace test |
| 148 } // namespace net | 149 } // namespace net |
| OLD | NEW |