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

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

Issue 110373004: Remove redundant |is_server| argument from TestSession and call the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_crypto_client_stream_test.cc ('k') | net/quic/test_tools/crypto_test_utils.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_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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 kOrbitSize); 46 kOrbitSize);
47 } 47 }
48 }; 48 };
49 49
50 namespace { 50 namespace {
51 51
52 class QuicCryptoServerStreamTest : public testing::TestWithParam<bool> { 52 class QuicCryptoServerStreamTest : public testing::TestWithParam<bool> {
53 public: 53 public:
54 QuicCryptoServerStreamTest() 54 QuicCryptoServerStreamTest()
55 : connection_(new PacketSavingConnection(true)), 55 : connection_(new PacketSavingConnection(true)),
56 session_(connection_, DefaultQuicConfig(), true), 56 session_(connection_, DefaultQuicConfig()),
57 crypto_config_(QuicCryptoServerConfig::TESTING, 57 crypto_config_(QuicCryptoServerConfig::TESTING,
58 QuicRandom::GetInstance()), 58 QuicRandom::GetInstance()),
59 stream_(crypto_config_, &session_), 59 stream_(crypto_config_, &session_),
60 strike_register_client_(NULL) { 60 strike_register_client_(NULL) {
61 config_.SetDefaults(); 61 config_.SetDefaults();
62 session_.config()->SetDefaults(); 62 session_.config()->SetDefaults();
63 session_.SetCryptoStream(&stream_); 63 session_.SetCryptoStream(&stream_);
64 // We advance the clock initially because the default time is zero and the 64 // We advance the clock initially because the default time is zero and the
65 // strike register worries that we've just overflowed a uint32 time. 65 // strike register worries that we've just overflowed a uint32 time.
66 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 66 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 TEST_P(QuicCryptoServerStreamTest, ZeroRTT) { 132 TEST_P(QuicCryptoServerStreamTest, ZeroRTT) {
133 PacketSavingConnection* client_conn = new PacketSavingConnection(false); 133 PacketSavingConnection* client_conn = new PacketSavingConnection(false);
134 PacketSavingConnection* server_conn = new PacketSavingConnection(false); 134 PacketSavingConnection* server_conn = new PacketSavingConnection(false);
135 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 135 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
136 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 136 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
137 137
138 QuicConfig client_config; 138 QuicConfig client_config;
139 client_config.SetDefaults(); 139 client_config.SetDefaults();
140 scoped_ptr<TestSession> client_session( 140 scoped_ptr<TestSession> client_session(
141 new TestSession(client_conn, client_config, false)); 141 new TestSession(client_conn, client_config));
142 QuicCryptoClientConfig client_crypto_config; 142 QuicCryptoClientConfig client_crypto_config;
143 client_crypto_config.SetDefaults(); 143 client_crypto_config.SetDefaults();
144 144
145 scoped_ptr<QuicCryptoClientStream> client(new QuicCryptoClientStream( 145 scoped_ptr<QuicCryptoClientStream> client(new QuicCryptoClientStream(
146 "test.example.com", client_session.get(), &client_crypto_config)); 146 "test.example.com", client_session.get(), &client_crypto_config));
147 client_session->SetCryptoStream(client.get()); 147 client_session->SetCryptoStream(client.get());
148 148
149 // Do a first handshake in order to prime the client config with the server's 149 // Do a first handshake in order to prime the client config with the server's
150 // information. 150 // information.
151 CHECK(client->CryptoConnect()); 151 CHECK(client->CryptoConnect());
152 CHECK_EQ(1u, client_conn->packets_.size()); 152 CHECK_EQ(1u, client_conn->packets_.size());
153 153
154 scoped_ptr<TestSession> server_session( 154 scoped_ptr<TestSession> server_session(new TestSession(server_conn, config_));
155 new TestSession(server_conn, config_, true));
156 scoped_ptr<QuicCryptoServerStream> server( 155 scoped_ptr<QuicCryptoServerStream> server(
157 new QuicCryptoServerStream(crypto_config_, server_session.get())); 156 new QuicCryptoServerStream(crypto_config_, server_session.get()));
158 server_session->SetCryptoStream(server.get()); 157 server_session->SetCryptoStream(server.get());
159 158
160 CryptoTestUtils::CommunicateHandshakeMessages( 159 CryptoTestUtils::CommunicateHandshakeMessages(
161 client_conn, client.get(), server_conn, server.get()); 160 client_conn, client.get(), server_conn, server.get());
162 EXPECT_EQ(2, client->num_sent_client_hellos()); 161 EXPECT_EQ(2, client->num_sent_client_hellos());
163 162
164 // Now do another handshake, hopefully in 0-RTT. 163 // Now do another handshake, hopefully in 0-RTT.
165 LOG(INFO) << "Resetting for 0-RTT handshake attempt"; 164 LOG(INFO) << "Resetting for 0-RTT handshake attempt";
166 165
167 client_conn = new PacketSavingConnection(false); 166 client_conn = new PacketSavingConnection(false);
168 server_conn = new PacketSavingConnection(false); 167 server_conn = new PacketSavingConnection(false);
169 // We need to advance time past the strike-server window so that it's 168 // We need to advance time past the strike-server window so that it's
170 // authoritative in this time span. 169 // authoritative in this time span.
171 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000)); 170 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000));
172 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000)); 171 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000));
173 172
174 // This causes the client's nonce to be different and thus stops the 173 // This causes the client's nonce to be different and thus stops the
175 // strike-register from rejecting the repeated nonce. 174 // strike-register from rejecting the repeated nonce.
176 reinterpret_cast<MockRandom*>(client_conn->random_generator())->ChangeValue(); 175 reinterpret_cast<MockRandom*>(client_conn->random_generator())->ChangeValue();
177 client_session.reset(new TestSession(client_conn, client_config, false)); 176 client_session.reset(new TestSession(client_conn, client_config));
178 server_session.reset(new TestSession(server_conn, config_, true)); 177 server_session.reset(new TestSession(server_conn, config_));
179 client.reset(new QuicCryptoClientStream( 178 client.reset(new QuicCryptoClientStream(
180 "test.example.com", client_session.get(), &client_crypto_config)); 179 "test.example.com", client_session.get(), &client_crypto_config));
181 client_session->SetCryptoStream(client.get()); 180 client_session->SetCryptoStream(client.get());
182 181
183 server.reset(new QuicCryptoServerStream(crypto_config_, 182 server.reset(new QuicCryptoServerStream(crypto_config_,
184 server_session.get())); 183 server_session.get()));
185 server_session->SetCryptoStream(server.get()); 184 server_session->SetCryptoStream(server.get());
186 185
187 CHECK(client->CryptoConnect()); 186 CHECK(client->CryptoConnect());
188 187
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // CompleteCryptoHandshake verifies 253 // CompleteCryptoHandshake verifies
255 // stream_.crypto_negotiated_params().channel_id is correct. 254 // stream_.crypto_negotiated_params().channel_id is correct.
256 EXPECT_EQ(2, CompleteCryptoHandshake()); 255 EXPECT_EQ(2, CompleteCryptoHandshake());
257 EXPECT_TRUE(stream_.encryption_established()); 256 EXPECT_TRUE(stream_.encryption_established());
258 EXPECT_TRUE(stream_.handshake_confirmed()); 257 EXPECT_TRUE(stream_.handshake_confirmed());
259 } 258 }
260 259
261 } // namespace 260 } // namespace
262 } // namespace test 261 } // namespace test
263 } // namespace net 262 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream_test.cc ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698