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

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

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with TOT Created 6 years, 9 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 | Annotate | Revision Log
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 static string GetPrimaryOrbit(const QuicCryptoServerConfig& config) { 42 static string GetPrimaryOrbit(const QuicCryptoServerConfig& config) {
43 base::AutoLock lock(config.configs_lock_); 43 base::AutoLock lock(config.configs_lock_);
44 CHECK(config.primary_config_ != NULL); 44 CHECK(config.primary_config_ != NULL);
45 return string(reinterpret_cast<const char*>(config.primary_config_->orbit), 45 return string(reinterpret_cast<const char*>(config.primary_config_->orbit),
46 kOrbitSize); 46 kOrbitSize);
47 } 47 }
48 }; 48 };
49 49
50 namespace { 50 namespace {
51 51
52 const char kServerHostname[] = "test.example.com";
53 const uint16 kServerPort = 80;
54
52 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> { 55 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> {
53 public: 56 public:
54 QuicCryptoServerStreamTest() 57 QuicCryptoServerStreamTest()
55 : connection_(new PacketSavingConnection(true)), 58 : connection_(new PacketSavingConnection(true)),
56 session_(connection_, DefaultQuicConfig()), 59 session_(connection_, DefaultQuicConfig()),
57 crypto_config_(QuicCryptoServerConfig::TESTING, 60 crypto_config_(QuicCryptoServerConfig::TESTING,
58 QuicRandom::GetInstance()), 61 QuicRandom::GetInstance()),
59 stream_(crypto_config_, &session_), 62 stream_(crypto_config_, &session_),
60 strike_register_client_(NULL) { 63 strike_register_client_(NULL) {
61 config_.SetDefaults(); 64 config_.SetDefaults();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 138 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
136 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 139 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
137 140
138 QuicConfig client_config; 141 QuicConfig client_config;
139 client_config.SetDefaults(); 142 client_config.SetDefaults();
140 scoped_ptr<TestSession> client_session( 143 scoped_ptr<TestSession> client_session(
141 new TestSession(client_conn, client_config)); 144 new TestSession(client_conn, client_config));
142 QuicCryptoClientConfig client_crypto_config; 145 QuicCryptoClientConfig client_crypto_config;
143 client_crypto_config.SetDefaults(); 146 client_crypto_config.SetDefaults();
144 147
148 QuicSessionKey server_key(kServerHostname, kServerPort, false);
145 scoped_ptr<QuicCryptoClientStream> client(new QuicCryptoClientStream( 149 scoped_ptr<QuicCryptoClientStream> client(new QuicCryptoClientStream(
146 "test.example.com", client_session.get(), &client_crypto_config)); 150 server_key, client_session.get(), &client_crypto_config));
147 client_session->SetCryptoStream(client.get()); 151 client_session->SetCryptoStream(client.get());
148 152
149 // Do a first handshake in order to prime the client config with the server's 153 // Do a first handshake in order to prime the client config with the server's
150 // information. 154 // information.
151 CHECK(client->CryptoConnect()); 155 CHECK(client->CryptoConnect());
152 CHECK_EQ(1u, client_conn->packets_.size()); 156 CHECK_EQ(1u, client_conn->packets_.size());
153 157
154 scoped_ptr<TestSession> server_session(new TestSession(server_conn, config_)); 158 scoped_ptr<TestSession> server_session(new TestSession(server_conn, config_));
155 scoped_ptr<QuicCryptoServerStream> server( 159 scoped_ptr<QuicCryptoServerStream> server(
156 new QuicCryptoServerStream(crypto_config_, server_session.get())); 160 new QuicCryptoServerStream(crypto_config_, server_session.get()));
(...skipping 12 matching lines...) Expand all
169 // authoritative in this time span. 173 // authoritative in this time span.
170 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000)); 174 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000));
171 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000)); 175 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000));
172 176
173 // This causes the client's nonce to be different and thus stops the 177 // This causes the client's nonce to be different and thus stops the
174 // strike-register from rejecting the repeated nonce. 178 // strike-register from rejecting the repeated nonce.
175 reinterpret_cast<MockRandom*>(client_conn->random_generator())->ChangeValue(); 179 reinterpret_cast<MockRandom*>(client_conn->random_generator())->ChangeValue();
176 client_session.reset(new TestSession(client_conn, client_config)); 180 client_session.reset(new TestSession(client_conn, client_config));
177 server_session.reset(new TestSession(server_conn, config_)); 181 server_session.reset(new TestSession(server_conn, config_));
178 client.reset(new QuicCryptoClientStream( 182 client.reset(new QuicCryptoClientStream(
179 "test.example.com", client_session.get(), &client_crypto_config)); 183 server_key, client_session.get(), &client_crypto_config));
180 client_session->SetCryptoStream(client.get()); 184 client_session->SetCryptoStream(client.get());
181 185
182 server.reset(new QuicCryptoServerStream(crypto_config_, 186 server.reset(new QuicCryptoServerStream(crypto_config_,
183 server_session.get())); 187 server_session.get()));
184 server_session->SetCryptoStream(server.get()); 188 server_session->SetCryptoStream(server.get());
185 189
186 CHECK(client->CryptoConnect()); 190 CHECK(client->CryptoConnect());
187 191
188 if (AsyncStrikeRegisterVerification()) { 192 if (AsyncStrikeRegisterVerification()) {
189 EXPECT_FALSE(client->handshake_confirmed()); 193 EXPECT_FALSE(client->handshake_confirmed());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // CompleteCryptoHandshake verifies 257 // CompleteCryptoHandshake verifies
254 // stream_.crypto_negotiated_params().channel_id is correct. 258 // stream_.crypto_negotiated_params().channel_id is correct.
255 EXPECT_EQ(2, CompleteCryptoHandshake()); 259 EXPECT_EQ(2, CompleteCryptoHandshake());
256 EXPECT_TRUE(stream_.encryption_established()); 260 EXPECT_TRUE(stream_.encryption_established());
257 EXPECT_TRUE(stream_.handshake_confirmed()); 261 EXPECT_TRUE(stream_.handshake_confirmed());
258 } 262 }
259 263
260 } // namespace 264 } // namespace
261 } // namespace test 265 } // namespace test
262 } // namespace net 266 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698