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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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_crypto_client_stream.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('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 12 matching lines...) Expand all
23 namespace net { 23 namespace net {
24 namespace test { 24 namespace test {
25 namespace { 25 namespace {
26 26
27 const char kServerHostname[] = "example.com"; 27 const char kServerHostname[] = "example.com";
28 const uint16 kServerPort = 80; 28 const uint16 kServerPort = 80;
29 29
30 class QuicCryptoClientStreamTest : public ::testing::Test { 30 class QuicCryptoClientStreamTest : public ::testing::Test {
31 public: 31 public:
32 QuicCryptoClientStreamTest() 32 QuicCryptoClientStreamTest()
33 : connection_(new PacketSavingConnection(false)), 33 : connection_(new PacketSavingConnection(/*is_server=*/false)),
34 session_(new TestClientSession(connection_, DefaultQuicConfig())), 34 session_(new TestClientSession(connection_, DefaultQuicConfig())),
35 server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED), 35 server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED),
36 stream_(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, 36 stream_(new QuicCryptoClientStream(server_id_,
37 session_.get(),
38 nullptr,
37 &crypto_config_)) { 39 &crypto_config_)) {
38 session_->SetCryptoStream(stream_.get()); 40 session_->SetCryptoStream(stream_.get());
39 // Advance the time, because timers do not like uninitialized times. 41 // Advance the time, because timers do not like uninitialized times.
40 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 42 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
41 } 43 }
42 44
43 void CompleteCryptoHandshake() { 45 void CompleteCryptoHandshake() {
44 stream_->CryptoConnect(); 46 stream_->CryptoConnect();
45 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); 47 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get());
46 } 48 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 116
115 CompleteCryptoHandshake(); 117 CompleteCryptoHandshake();
116 EXPECT_TRUE(stream_->encryption_established()); 118 EXPECT_TRUE(stream_->encryption_established());
117 EXPECT_TRUE(stream_->handshake_confirmed()); 119 EXPECT_TRUE(stream_->handshake_confirmed());
118 } 120 }
119 121
120 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { 122 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) {
121 // Seed the config with a cached server config. 123 // Seed the config with a cached server config.
122 CompleteCryptoHandshake(); 124 CompleteCryptoHandshake();
123 125
124 connection_ = new PacketSavingConnection(true); 126 connection_ = new PacketSavingConnection(/*is_server=*/false);
125 session_.reset(new TestClientSession(connection_, DefaultQuicConfig())); 127 session_.reset(new TestClientSession(connection_, DefaultQuicConfig()));
126 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, 128 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr,
127 &crypto_config_)); 129 &crypto_config_));
128 130
129 session_->SetCryptoStream(stream_.get()); 131 session_->SetCryptoStream(stream_.get());
130 132
131 // Advance time 5 years to ensure that we pass the expiry time of the cached 133 // Advance time 5 years to ensure that we pass the expiry time of the cached
132 // server config. 134 // server config.
133 connection_->AdvanceTime( 135 connection_->AdvanceTime(
134 QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5)); 136 QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5));
135 137
136 stream_->CryptoConnect(); 138 stream_->CryptoConnect();
137 // Check that a client hello was sent. 139 // Check that a client hello was sent.
138 ASSERT_EQ(1u, connection_->packets_.size()); 140 ASSERT_EQ(1u, connection_->encrypted_packets_.size());
139 } 141 }
140 142
141 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdate) { 143 TEST_F(QuicCryptoClientStreamTest, ServerConfigUpdate) {
142 // Test that the crypto client stream can receive server config updates after 144 // Test that the crypto client stream can receive server config updates after
143 // the connection has been established. 145 // the connection has been established.
144 CompleteCryptoHandshake(); 146 CompleteCryptoHandshake();
145 147
146 QuicCryptoClientConfig::CachedState* state = 148 QuicCryptoClientConfig::CachedState* state =
147 crypto_config_.LookupOrCreate(server_id_); 149 crypto_config_.LookupOrCreate(server_id_);
148 150
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 CryptoHandshakeMessage server_config_update; 196 CryptoHandshakeMessage server_config_update;
195 server_config_update.set_tag(kSCUP); 197 server_config_update.set_tag(kSCUP);
196 scoped_ptr<QuicData> data( 198 scoped_ptr<QuicData> data(
197 CryptoFramer::ConstructHandshakeMessage(server_config_update)); 199 CryptoFramer::ConstructHandshakeMessage(server_config_update));
198 stream_->ProcessRawData(data->data(), data->length()); 200 stream_->ProcessRawData(data->data(), data->length());
199 } 201 }
200 202
201 } // namespace 203 } // namespace
202 } // namespace test 204 } // namespace test
203 } // namespace net 205 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698