| 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 "base/strings/string_number_conversions.h" | 5 #include "base/strings/string_number_conversions.h" |
| 6 #include "net/quic/crypto/crypto_server_config.h" | 6 #include "net/quic/crypto/crypto_server_config.h" |
| 7 #include "net/quic/crypto/crypto_utils.h" | 7 #include "net/quic/crypto/crypto_utils.h" |
| 8 #include "net/quic/crypto/quic_random.h" | 8 #include "net/quic/crypto/quic_random.h" |
| 9 #include "net/quic/test_tools/crypto_test_utils.h" | 9 #include "net/quic/test_tools/crypto_test_utils.h" |
| 10 #include "net/quic/test_tools/mock_clock.h" | 10 #include "net/quic/test_tools/mock_clock.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 server_config_.reset(CryptoFramer::ParseMessage(scfg)); | 65 server_config_.reset(CryptoFramer::ParseMessage(scfg)); |
| 66 | 66 |
| 67 StringPiece scid; | 67 StringPiece scid; |
| 68 ASSERT_TRUE(server_config_->GetStringPiece(kSCID, &scid)); | 68 ASSERT_TRUE(server_config_->GetStringPiece(kSCID, &scid)); |
| 69 scid_hex_ = "#" + base::HexEncode(scid.data(), scid.size()); | 69 scid_hex_ = "#" + base::HexEncode(scid.data(), scid.size()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ShouldSucceed(const CryptoHandshakeMessage& message) { | 72 void ShouldSucceed(const CryptoHandshakeMessage& message) { |
| 73 string error_details; | 73 string error_details; |
| 74 QuicErrorCode error = config_.ProcessClientHello( | 74 QuicErrorCode error = config_.ProcessClientHello( |
| 75 message, 1 /* GUID */, addr_, &clock_, | 75 message, QuicVersionMax(), 1 /* GUID */, addr_, |
| 76 rand_, ¶ms_, &out_, &error_details); | 76 &clock_, rand_, ¶ms_, &out_, &error_details); |
| 77 | 77 |
| 78 ASSERT_EQ(error, QUIC_NO_ERROR) | 78 ASSERT_EQ(error, QUIC_NO_ERROR) |
| 79 << "Message failed with error " << error_details << ": " | 79 << "Message failed with error " << error_details << ": " |
| 80 << message.DebugString(); | 80 << message.DebugString(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ShouldFailMentioning(const char* error_substr, | 83 void ShouldFailMentioning(const char* error_substr, |
| 84 const CryptoHandshakeMessage& message) { | 84 const CryptoHandshakeMessage& message) { |
| 85 string error_details; | 85 string error_details; |
| 86 QuicErrorCode error = config_.ProcessClientHello( | 86 QuicErrorCode error = config_.ProcessClientHello( |
| 87 message, 1 /* GUID */, addr_, &clock_, | 87 message, QuicVersionMax(), 1 /* GUID */, addr_, |
| 88 rand_, ¶ms_, &out_, &error_details); | 88 &clock_, rand_, ¶ms_, &out_, &error_details); |
| 89 | 89 |
| 90 ASSERT_NE(error, QUIC_NO_ERROR) | 90 ASSERT_NE(error, QUIC_NO_ERROR) |
| 91 << "Message didn't fail: " << message.DebugString(); | 91 << "Message didn't fail: " << message.DebugString(); |
| 92 | 92 |
| 93 EXPECT_TRUE(error_details.find(error_substr) != string::npos) | 93 EXPECT_TRUE(error_details.find(error_substr) != string::npos) |
| 94 << error_substr << " not in " << error_details; | 94 << error_substr << " not in " << error_details; |
| 95 } | 95 } |
| 96 | 96 |
| 97 CryptoHandshakeMessage InchoateClientHello(const char* message_tag, ...) { | 97 CryptoHandshakeMessage InchoateClientHello(const char* message_tag, ...) { |
| 98 va_list ap; | 98 va_list ap; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 }; | 247 }; |
| 248 | 248 |
| 249 TEST_F(CryptoServerTestNoConfig, DontCrash) { | 249 TEST_F(CryptoServerTestNoConfig, DontCrash) { |
| 250 ShouldFailMentioning("No config", InchoateClientHello( | 250 ShouldFailMentioning("No config", InchoateClientHello( |
| 251 "CHLO", | 251 "CHLO", |
| 252 NULL)); | 252 NULL)); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace test | 255 } // namespace test |
| 256 } // namespace net | 256 } // namespace net |
| OLD | NEW |