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

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

Issue 425803014: Refactor pooling logic into a helper method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working Created 6 years, 4 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_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "net/base/capturing_net_log.h" 11 #include "net/base/capturing_net_log.h"
12 #include "net/base/test_completion_callback.h" 12 #include "net/base/test_completion_callback.h"
13 #include "net/base/test_data_directory.h" 13 #include "net/base/test_data_directory.h"
14 #include "net/cert/cert_verify_result.h" 14 #include "net/cert/cert_verify_result.h"
15 #include "net/http/transport_security_state.h"
15 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 16 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
16 #include "net/quic/crypto/crypto_protocol.h" 17 #include "net/quic/crypto/crypto_protocol.h"
17 #include "net/quic/crypto/proof_verifier_chromium.h" 18 #include "net/quic/crypto/proof_verifier_chromium.h"
18 #include "net/quic/crypto/quic_decrypter.h" 19 #include "net/quic/crypto/quic_decrypter.h"
19 #include "net/quic/crypto/quic_encrypter.h" 20 #include "net/quic/crypto/quic_encrypter.h"
20 #include "net/quic/crypto/quic_server_info.h" 21 #include "net/quic/crypto/quic_server_info.h"
21 #include "net/quic/quic_default_packet_writer.h" 22 #include "net/quic/quic_default_packet_writer.h"
22 #include "net/quic/test_tools/crypto_test_utils.h" 23 #include "net/quic/test_tools/crypto_test_utils.h"
23 #include "net/quic/test_tools/quic_client_session_peer.h" 24 #include "net/quic/test_tools/quic_client_session_peer.h"
24 #include "net/quic/test_tools/quic_test_utils.h" 25 #include "net/quic/test_tools/quic_test_utils.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 QuicPacketHeader header_; 67 QuicPacketHeader header_;
67 }; 68 };
68 69
69 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { 70 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> {
70 protected: 71 protected:
71 QuicClientSessionTest() 72 QuicClientSessionTest()
72 : writer_(new TestPacketWriter(GetParam())), 73 : writer_(new TestPacketWriter(GetParam())),
73 connection_( 74 connection_(
74 new PacketSavingConnection(false, SupportedVersions(GetParam()))), 75 new PacketSavingConnection(false, SupportedVersions(GetParam()))),
75 session_(connection_, GetSocket().Pass(), writer_.Pass(), NULL, NULL, 76 session_(connection_, GetSocket().Pass(), writer_.Pass(), NULL, NULL,
77 &transport_security_state_,
76 make_scoped_ptr((QuicServerInfo*)NULL), 78 make_scoped_ptr((QuicServerInfo*)NULL),
77 QuicServerId(kServerHostname, kServerPort, false, 79 QuicServerId(kServerHostname, kServerPort, false,
78 PRIVACY_MODE_DISABLED), 80 PRIVACY_MODE_DISABLED),
79 DefaultQuicConfig(), &crypto_config_, 81 DefaultQuicConfig(), &crypto_config_,
80 base::MessageLoop::current()->message_loop_proxy().get(), 82 base::MessageLoop::current()->message_loop_proxy().get(),
81 &net_log_) { 83 &net_log_) {
82 session_.InitializeSession(); 84 session_.InitializeSession();
83 session_.config()->SetDefaults(); 85 session_.config()->SetDefaults();
84 crypto_config_.SetDefaults(); 86 crypto_config_.SetDefaults();
85 } 87 }
(...skipping 15 matching lines...) Expand all
101 CryptoTestUtils::HandshakeWithFakeServer( 103 CryptoTestUtils::HandshakeWithFakeServer(
102 connection_, session_.GetCryptoStream()); 104 connection_, session_.GetCryptoStream());
103 ASSERT_EQ(OK, callback_.WaitForResult()); 105 ASSERT_EQ(OK, callback_.WaitForResult());
104 } 106 }
105 107
106 scoped_ptr<QuicDefaultPacketWriter> writer_; 108 scoped_ptr<QuicDefaultPacketWriter> writer_;
107 PacketSavingConnection* connection_; 109 PacketSavingConnection* connection_;
108 CapturingNetLog net_log_; 110 CapturingNetLog net_log_;
109 MockClientSocketFactory socket_factory_; 111 MockClientSocketFactory socket_factory_;
110 StaticSocketDataProvider socket_data_; 112 StaticSocketDataProvider socket_data_;
113 TransportSecurityState transport_security_state_;
111 QuicClientSession session_; 114 QuicClientSession session_;
112 MockClock clock_; 115 MockClock clock_;
113 MockRandom random_; 116 MockRandom random_;
114 QuicConnectionVisitorInterface* visitor_; 117 QuicConnectionVisitorInterface* visitor_;
115 TestCompletionCallback callback_; 118 TestCompletionCallback callback_;
116 QuicCryptoClientConfig crypto_config_; 119 QuicCryptoClientConfig crypto_config_;
117 }; 120 };
118 121
119 INSTANTIATE_TEST_CASE_P(Tests, QuicClientSessionTest, 122 INSTANTIATE_TEST_CASE_P(Tests, QuicClientSessionTest,
120 ::testing::ValuesIn(QuicSupportedVersions())); 123 ::testing::ValuesIn(QuicSupportedVersions()));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 168
166 TEST_P(QuicClientSessionTest, GoAwayReceived) { 169 TEST_P(QuicClientSessionTest, GoAwayReceived) {
167 CompleteCryptoHandshake(); 170 CompleteCryptoHandshake();
168 171
169 // After receiving a GoAway, I should no longer be able to create outgoing 172 // After receiving a GoAway, I should no longer be able to create outgoing
170 // streams. 173 // streams.
171 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); 174 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away."));
172 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream()); 175 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream());
173 } 176 }
174 177
175 // TODO(rch): re-enable this. 178 TEST_P(QuicClientSessionTest, CanPool) {
176 TEST_P(QuicClientSessionTest, DISABLED_CanPool) {
177 // Load a cert that is valid for: 179 // Load a cert that is valid for:
178 // www.example.org 180 // www.example.org
179 // mail.example.org 181 // mail.example.org
180 // www.example.com 182 // www.example.com
181 base::FilePath certs_dir = GetTestCertsDirectory(); 183 base::FilePath certs_dir = GetTestCertsDirectory();
182 184
183 CertVerifyResult result; 185 CertVerifyResult result;
184 ProofVerifyDetailsChromium details; 186 ProofVerifyDetailsChromium details;
185 details.cert_verify_result.verified_cert = 187 details.cert_verify_result.verified_cert =
186 ImportCertFromFile(certs_dir, "spdy_pooling.pem"); 188 ImportCertFromFile(certs_dir, "spdy_pooling.pem");
187 ASSERT_TRUE(details.cert_verify_result.verified_cert); 189 ASSERT_TRUE(details.cert_verify_result.verified_cert);
188 190
189 session_.OnProofVerifyDetailsAvailable(details); 191 session_.OnProofVerifyDetailsAvailable(details);
190 CompleteCryptoHandshake(); 192 CompleteCryptoHandshake();
191 193
192 194
193 EXPECT_TRUE(session_.CanPool("www.example.org")); 195 EXPECT_TRUE(session_.CanPool("www.example.org"));
194 EXPECT_TRUE(session_.CanPool("mail.example.org")); 196 EXPECT_TRUE(session_.CanPool("mail.example.org"));
195 EXPECT_TRUE(session_.CanPool("mail.example.com")); 197 EXPECT_TRUE(session_.CanPool("mail.example.com"));
196 EXPECT_FALSE(session_.CanPool("mail.google.com")); 198 EXPECT_FALSE(session_.CanPool("mail.google.com"));
197 } 199 }
198 200
199 // TODO(rch): re-enable this. 201 TEST_P(QuicClientSessionTest, ConnectionPooledWithTlsChannelId) {
Ryan Sleevi 2014/08/07 18:49:29 Pinning tests
Ryan Hamilton 2014/08/08 19:27:43 I would have thought that the new tests written as
200 TEST_P(QuicClientSessionTest, DISABLED_ConnectionPooledWithTlsChannelId) {
201 // Load a cert that is valid for: 202 // Load a cert that is valid for:
202 // www.example.org 203 // www.example.org
203 // mail.example.org 204 // mail.example.org
204 // www.example.com 205 // www.example.com
205 base::FilePath certs_dir = GetTestCertsDirectory(); 206 base::FilePath certs_dir = GetTestCertsDirectory();
206 207
207 CertVerifyResult result; 208 CertVerifyResult result;
208 ProofVerifyDetailsChromium details; 209 ProofVerifyDetailsChromium details;
209 details.cert_verify_result.verified_cert = 210 details.cert_verify_result.verified_cert =
210 ImportCertFromFile(certs_dir, "spdy_pooling.pem"); 211 ImportCertFromFile(certs_dir, "spdy_pooling.pem");
211 ASSERT_TRUE(details.cert_verify_result.verified_cert); 212 ASSERT_TRUE(details.cert_verify_result.verified_cert);
212 213
213 session_.OnProofVerifyDetailsAvailable(details); 214 session_.OnProofVerifyDetailsAvailable(details);
214 CompleteCryptoHandshake(); 215 CompleteCryptoHandshake();
215 QuicClientSessionPeer::SetChannelIDSent(&session_, true); 216 QuicClientSessionPeer::SetChannelIDSent(&session_, true);
216 217
217 EXPECT_TRUE(session_.CanPool("www.example.org")); 218 EXPECT_TRUE(session_.CanPool("www.example.org"));
218 EXPECT_TRUE(session_.CanPool("mail.example.org")); 219 EXPECT_TRUE(session_.CanPool("mail.example.org"));
219 EXPECT_FALSE(session_.CanPool("mail.example.com")); 220 EXPECT_FALSE(session_.CanPool("mail.example.com"));
220 EXPECT_FALSE(session_.CanPool("mail.google.com")); 221 EXPECT_FALSE(session_.CanPool("mail.google.com"));
221 } 222 }
222 223
223 } // namespace 224 } // namespace
224 } // namespace test 225 } // namespace test
225 } // namespace net 226 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698