OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic_crypto_server_stream.h" | 5 #include "net/quic/quic_crypto_server_stream.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 }; | 64 }; |
65 | 65 |
66 class QuicCryptoServerStreamTest : public ::testing::Test { | 66 class QuicCryptoServerStreamTest : public ::testing::Test { |
67 public: | 67 public: |
68 QuicCryptoServerStreamTest() | 68 QuicCryptoServerStreamTest() |
69 : guid_(1), | 69 : guid_(1), |
70 addr_(ParseIPLiteralToNumber("192.0.2.33", &ip_) ? | 70 addr_(ParseIPLiteralToNumber("192.0.2.33", &ip_) ? |
71 ip_ : IPAddressNumber(), 1), | 71 ip_ : IPAddressNumber(), 1), |
72 connection_(new PacketSavingConnection(guid_, addr_, true)), | 72 connection_(new PacketSavingConnection(guid_, addr_, true)), |
73 session_(connection_, true), | 73 session_(connection_, true), |
74 stream_(&session_) { | 74 crypto_config_(QuicCryptoServerConfig::TESTING), |
| 75 stream_(config_, crypto_config_, &session_) { |
| 76 CryptoTestUtils::SetupCryptoServerConfigForTest( |
| 77 connection_->clock(), connection_->random_generator(), &config_, |
| 78 &crypto_config_); |
75 } | 79 } |
76 | 80 |
77 void ConstructHandshakeMessage() { | 81 void ConstructHandshakeMessage() { |
78 CryptoFramer framer; | 82 CryptoFramer framer; |
79 message_data_.reset(framer.ConstructHandshakeMessage(message_)); | 83 message_data_.reset(framer.ConstructHandshakeMessage(message_)); |
80 } | 84 } |
81 | 85 |
82 void CompleteCryptoHandshake() { | 86 void CompleteCryptoHandshake() { |
83 CryptoTestUtils::HandshakeWithFakeClient(connection_, &stream_); | 87 CryptoTestUtils::HandshakeWithFakeClient(connection_, &stream_); |
84 } | 88 } |
85 | 89 |
86 protected: | 90 protected: |
87 IPAddressNumber ip_; | 91 IPAddressNumber ip_; |
88 QuicGuid guid_; | 92 QuicGuid guid_; |
89 IPEndPoint addr_; | 93 IPEndPoint addr_; |
90 PacketSavingConnection* connection_; | 94 PacketSavingConnection* connection_; |
91 TestSession session_; | 95 TestSession session_; |
| 96 QuicConfig config_; |
| 97 QuicCryptoServerConfig crypto_config_; |
92 QuicCryptoServerStream stream_; | 98 QuicCryptoServerStream stream_; |
93 CryptoHandshakeMessage message_; | 99 CryptoHandshakeMessage message_; |
94 scoped_ptr<QuicData> message_data_; | 100 scoped_ptr<QuicData> message_data_; |
95 }; | 101 }; |
96 | 102 |
97 TEST_F(QuicCryptoServerStreamTest, NotInitiallyConected) { | 103 TEST_F(QuicCryptoServerStreamTest, NotInitiallyConected) { |
98 if (!Aes128GcmEncrypter::IsSupported()) { | 104 if (!Aes128GcmEncrypter::IsSupported()) { |
99 LOG(INFO) << "AES GCM not supported. Test skipped."; | 105 LOG(INFO) << "AES GCM not supported. Test skipped."; |
100 return; | 106 return; |
101 } | 107 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 message_.set_tag(kSHLO); | 142 message_.set_tag(kSHLO); |
137 ConstructHandshakeMessage(); | 143 ConstructHandshakeMessage(); |
138 EXPECT_CALL(*connection_, SendConnectionClose( | 144 EXPECT_CALL(*connection_, SendConnectionClose( |
139 QUIC_INVALID_CRYPTO_MESSAGE_TYPE)); | 145 QUIC_INVALID_CRYPTO_MESSAGE_TYPE)); |
140 stream_.ProcessData(message_data_->data(), message_data_->length()); | 146 stream_.ProcessData(message_data_->data(), message_data_->length()); |
141 } | 147 } |
142 | 148 |
143 } // namespace | 149 } // namespace |
144 } // namespace test | 150 } // namespace test |
145 } // namespace net | 151 } // namespace net |
OLD | NEW |