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 session_->config()->SetDefaults(); | |
38 crypto_config_.SetDefaults(); | |
39 } | 37 } |
40 | 38 |
41 void CompleteCryptoHandshake() { | 39 void CompleteCryptoHandshake() { |
42 EXPECT_TRUE(stream_->CryptoConnect()); | 40 EXPECT_TRUE(stream_->CryptoConnect()); |
43 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); | 41 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); |
44 } | 42 } |
45 | 43 |
46 void ConstructHandshakeMessage() { | 44 void ConstructHandshakeMessage() { |
47 CryptoFramer framer; | 45 CryptoFramer framer; |
48 message_data_.reset(framer.ConstructHandshakeMessage(message_)); | 46 message_data_.reset(framer.ConstructHandshakeMessage(message_)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { | 118 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { |
121 // Seed the config with a cached server config. | 119 // Seed the config with a cached server config. |
122 CompleteCryptoHandshake(); | 120 CompleteCryptoHandshake(); |
123 | 121 |
124 connection_ = new PacketSavingConnection(true); | 122 connection_ = new PacketSavingConnection(true); |
125 session_.reset(new TestClientSession(connection_, DefaultQuicConfig())); | 123 session_.reset(new TestClientSession(connection_, DefaultQuicConfig())); |
126 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, | 124 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, |
127 &crypto_config_)); | 125 &crypto_config_)); |
128 | 126 |
129 session_->SetCryptoStream(stream_.get()); | 127 session_->SetCryptoStream(stream_.get()); |
130 session_->config()->SetDefaults(); | |
131 | 128 |
132 // Advance time 5 years to ensure that we pass the expiry time of the cached | 129 // Advance time 5 years to ensure that we pass the expiry time of the cached |
133 // server config. | 130 // server config. |
134 reinterpret_cast<MockClock*>(const_cast<QuicClock*>(connection_->clock())) | 131 reinterpret_cast<MockClock*>(const_cast<QuicClock*>(connection_->clock())) |
135 ->AdvanceTime(QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5)); | 132 ->AdvanceTime(QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5)); |
136 | 133 |
137 // Check that a client hello was sent and that CryptoConnect doesn't fail | 134 // Check that a client hello was sent and that CryptoConnect doesn't fail |
138 // with an error. | 135 // with an error. |
139 EXPECT_TRUE(stream_->CryptoConnect()); | 136 EXPECT_TRUE(stream_->CryptoConnect()); |
140 ASSERT_EQ(1u, connection_->packets_.size()); | 137 ASSERT_EQ(1u, connection_->packets_.size()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 CryptoHandshakeMessage server_config_update; | 193 CryptoHandshakeMessage server_config_update; |
197 server_config_update.set_tag(kSCUP); | 194 server_config_update.set_tag(kSCUP); |
198 scoped_ptr<QuicData> data( | 195 scoped_ptr<QuicData> data( |
199 CryptoFramer::ConstructHandshakeMessage(server_config_update)); | 196 CryptoFramer::ConstructHandshakeMessage(server_config_update)); |
200 stream_->ProcessRawData(data->data(), data->length()); | 197 stream_->ProcessRawData(data->data(), data->length()); |
201 } | 198 } |
202 | 199 |
203 } // namespace | 200 } // namespace |
204 } // namespace test | 201 } // namespace test |
205 } // namespace net | 202 } // namespace net |
OLD | NEW |