Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: net/quic/quic_crypto_client_stream_test.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698