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_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 8 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
9 #include "net/quic/crypto/quic_decrypter.h" | 9 #include "net/quic/crypto/quic_decrypter.h" |
10 #include "net/quic/crypto/quic_encrypter.h" | 10 #include "net/quic/crypto/quic_encrypter.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 class QuicCryptoClientStreamTest : public ::testing::Test { | 28 class QuicCryptoClientStreamTest : public ::testing::Test { |
29 public: | 29 public: |
30 QuicCryptoClientStreamTest() | 30 QuicCryptoClientStreamTest() |
31 : connection_(new PacketSavingConnection(false)), | 31 : connection_(new PacketSavingConnection(false)), |
32 session_(new TestClientSession(connection_, DefaultQuicConfig())), | 32 session_(new TestClientSession(connection_, DefaultQuicConfig())), |
33 server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED), | 33 server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED), |
34 stream_(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, | 34 stream_(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, |
35 &crypto_config_)) { | 35 &crypto_config_)) { |
36 session_->SetCryptoStream(stream_.get()); | 36 session_->SetCryptoStream(stream_.get()); |
| 37 // Advance the time, because timers do not like uninitialized times. |
| 38 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
37 } | 39 } |
38 | 40 |
39 void CompleteCryptoHandshake() { | 41 void CompleteCryptoHandshake() { |
40 EXPECT_TRUE(stream_->CryptoConnect()); | 42 EXPECT_TRUE(stream_->CryptoConnect()); |
41 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); | 43 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); |
42 } | 44 } |
43 | 45 |
44 void ConstructHandshakeMessage() { | 46 void ConstructHandshakeMessage() { |
45 CryptoFramer framer; | 47 CryptoFramer framer; |
46 message_data_.reset(framer.ConstructHandshakeMessage(message_)); | 48 message_data_.reset(framer.ConstructHandshakeMessage(message_)); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 123 |
122 connection_ = new PacketSavingConnection(true); | 124 connection_ = new PacketSavingConnection(true); |
123 session_.reset(new TestClientSession(connection_, DefaultQuicConfig())); | 125 session_.reset(new TestClientSession(connection_, DefaultQuicConfig())); |
124 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, | 126 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, |
125 &crypto_config_)); | 127 &crypto_config_)); |
126 | 128 |
127 session_->SetCryptoStream(stream_.get()); | 129 session_->SetCryptoStream(stream_.get()); |
128 | 130 |
129 // Advance time 5 years to ensure that we pass the expiry time of the cached | 131 // Advance time 5 years to ensure that we pass the expiry time of the cached |
130 // server config. | 132 // server config. |
131 reinterpret_cast<MockClock*>(const_cast<QuicClock*>(connection_->clock())) | 133 connection_->AdvanceTime( |
132 ->AdvanceTime(QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5)); | 134 QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5)); |
133 | 135 |
134 // Check that a client hello was sent and that CryptoConnect doesn't fail | 136 // Check that a client hello was sent and that CryptoConnect doesn't fail |
135 // with an error. | 137 // with an error. |
136 EXPECT_TRUE(stream_->CryptoConnect()); | 138 EXPECT_TRUE(stream_->CryptoConnect()); |
137 ASSERT_EQ(1u, connection_->packets_.size()); | 139 ASSERT_EQ(1u, connection_->packets_.size()); |
138 } | 140 } |
139 | 141 |
140 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdate) { | 142 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdate) { |
141 // Test that the crypto client stream can receive server config updates after | 143 // Test that the crypto client stream can receive server config updates after |
142 // the connection has been established. | 144 // the connection has been established. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 CryptoHandshakeMessage server_config_update; | 195 CryptoHandshakeMessage server_config_update; |
194 server_config_update.set_tag(kSCUP); | 196 server_config_update.set_tag(kSCUP); |
195 scoped_ptr<QuicData> data( | 197 scoped_ptr<QuicData> data( |
196 CryptoFramer::ConstructHandshakeMessage(server_config_update)); | 198 CryptoFramer::ConstructHandshakeMessage(server_config_update)); |
197 stream_->ProcessRawData(data->data(), data->length()); | 199 stream_->ProcessRawData(data->data(), data->length()); |
198 } | 200 } |
199 | 201 |
200 } // namespace | 202 } // namespace |
201 } // namespace test | 203 } // namespace test |
202 } // namespace net | 204 } // namespace net |
OLD | NEW |