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

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

Issue 2109303002: Add QuicStreamFactory as an observer of an SSLConfigService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "net/ssl/default_channel_id_store.h" 43 #include "net/ssl/default_channel_id_store.h"
44 #include "net/test/cert_test_util.h" 44 #include "net/test/cert_test_util.h"
45 #include "net/test/test_data_directory.h" 45 #include "net/test/test_data_directory.h"
46 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
47 47
48 using std::string; 48 using std::string;
49 using std::vector; 49 using std::vector;
50 50
51 namespace net { 51 namespace net {
52 52
53 namespace {
54
55 class MockSSLConfigService : public SSLConfigService {
56 public:
57 MockSSLConfigService() {}
58
59 void GetSSLConfig(SSLConfig* config) override { *config = config_; }
60
61 private:
62 ~MockSSLConfigService() override {}
63
64 SSLConfig config_;
65 };
66
67 } // namespace
68
53 namespace test { 69 namespace test {
54 70
55 namespace { 71 namespace {
56 72
57 enum DestinationType { 73 enum DestinationType {
58 // In pooling tests with two requests for different origins to the same 74 // In pooling tests with two requests for different origins to the same
59 // destination, the destination should be 75 // destination, the destination should be
60 SAME_AS_FIRST, // the same as the first origin, 76 SAME_AS_FIRST, // the same as the first origin,
61 SAME_AS_SECOND, // the same as the second origin, or 77 SAME_AS_SECOND, // the same as the second origin, or
62 DIFFERENT, // different from both. 78 DIFFERENT, // different from both.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 261
246 private: 262 private:
247 std::unique_ptr<NetworkChangeNotifier::DisableForTest> 263 std::unique_ptr<NetworkChangeNotifier::DisableForTest>
248 disable_network_change_notifier_for_tests_; 264 disable_network_change_notifier_for_tests_;
249 std::unique_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_; 265 std::unique_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_;
250 }; 266 };
251 267
252 class QuicStreamFactoryTestBase { 268 class QuicStreamFactoryTestBase {
253 protected: 269 protected:
254 QuicStreamFactoryTestBase(QuicVersion version, bool enable_connection_racing) 270 QuicStreamFactoryTestBase(QuicVersion version, bool enable_connection_racing)
255 : random_generator_(0), 271 : ssl_config_service_(new MockSSLConfigService),
272 random_generator_(0),
256 clock_(new MockClock()), 273 clock_(new MockClock()),
257 runner_(new TestTaskRunner(clock_)), 274 runner_(new TestTaskRunner(clock_)),
258 version_(version), 275 version_(version),
259 client_maker_(version_, 276 client_maker_(version_,
260 0, 277 0,
261 clock_, 278 clock_,
262 kDefaultServerHostName, 279 kDefaultServerHostName,
263 Perspective::IS_CLIENT), 280 Perspective::IS_CLIENT),
264 server_maker_(version_, 281 server_maker_(version_,
265 0, 282 0,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // If |factory_| was initialized, then it took over ownership of |clock_|. 323 // If |factory_| was initialized, then it took over ownership of |clock_|.
307 // If |factory_| was not initialized, then |clock_| needs to be destroyed. 324 // If |factory_| was not initialized, then |clock_| needs to be destroyed.
308 if (!factory_) { 325 if (!factory_) {
309 delete clock_; 326 delete clock_;
310 } 327 }
311 } 328 }
312 329
313 void Initialize() { 330 void Initialize() {
314 DCHECK(!factory_); 331 DCHECK(!factory_);
315 factory_.reset(new QuicStreamFactory( 332 factory_.reset(new QuicStreamFactory(
316 net_log_.net_log(), &host_resolver_, &socket_factory_, 333 net_log_.net_log(), &host_resolver_, ssl_config_service_.get(),
317 &http_server_properties_, cert_verifier_.get(), &ct_policy_enforcer_, 334 &socket_factory_, &http_server_properties_, cert_verifier_.get(),
318 channel_id_service_.get(), &transport_security_state_, 335 &ct_policy_enforcer_, channel_id_service_.get(),
319 cert_transparency_verifier_.get(), 336 &transport_security_state_, cert_transparency_verifier_.get(),
320 /*SocketPerformanceWatcherFactory*/ nullptr, 337 /*SocketPerformanceWatcherFactory*/ nullptr,
321 &crypto_client_stream_factory_, &random_generator_, clock_, 338 &crypto_client_stream_factory_, &random_generator_, clock_,
322 kDefaultMaxPacketSize, string(), SupportedVersions(version_), 339 kDefaultMaxPacketSize, string(), SupportedVersions(version_),
323 enable_port_selection_, always_require_handshake_confirmation_, 340 enable_port_selection_, always_require_handshake_confirmation_,
324 disable_connection_pooling_, load_server_info_timeout_srtt_multiplier_, 341 disable_connection_pooling_, load_server_info_timeout_srtt_multiplier_,
325 enable_connection_racing_, enable_non_blocking_io_, disable_disk_cache_, 342 enable_connection_racing_, enable_non_blocking_io_, disable_disk_cache_,
326 prefer_aes_, max_number_of_lossy_connections_, packet_loss_threshold_, 343 prefer_aes_, max_number_of_lossy_connections_, packet_loss_threshold_,
327 max_disabled_reasons_, threshold_timeouts_with_open_streams_, 344 max_disabled_reasons_, threshold_timeouts_with_open_streams_,
328 threshold_public_resets_post_handshake_, receive_buffer_size_, 345 threshold_public_resets_post_handshake_, receive_buffer_size_,
329 delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0, 346 delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 bool should_include_version, 484 bool should_include_version,
468 bool fin) { 485 bool fin) {
469 SpdyHeaderBlock headers = server_maker_.GetResponseHeaders("200 OK"); 486 SpdyHeaderBlock headers = server_maker_.GetResponseHeaders("200 OK");
470 size_t spdy_headers_frame_len; 487 size_t spdy_headers_frame_len;
471 return server_maker_.MakeResponseHeadersPacket( 488 return server_maker_.MakeResponseHeadersPacket(
472 packet_number, stream_id, should_include_version, fin, 489 packet_number, stream_id, should_include_version, fin,
473 std::move(headers), &spdy_headers_frame_len); 490 std::move(headers), &spdy_headers_frame_len);
474 } 491 }
475 492
476 MockHostResolver host_resolver_; 493 MockHostResolver host_resolver_;
494 scoped_refptr<SSLConfigService> ssl_config_service_;
477 MockClientSocketFactory socket_factory_; 495 MockClientSocketFactory socket_factory_;
478 MockCryptoClientStreamFactory crypto_client_stream_factory_; 496 MockCryptoClientStreamFactory crypto_client_stream_factory_;
479 MockRandom random_generator_; 497 MockRandom random_generator_;
480 MockClock* clock_; // Owned by |factory_| once created. 498 MockClock* clock_; // Owned by |factory_| once created.
481 scoped_refptr<TestTaskRunner> runner_; 499 scoped_refptr<TestTaskRunner> runner_;
482 QuicVersion version_; 500 QuicVersion version_;
483 QuicTestPacketMaker client_maker_; 501 QuicTestPacketMaker client_maker_;
484 QuicTestPacketMaker server_maker_; 502 QuicTestPacketMaker server_maker_;
485 HttpServerPropertiesImpl http_server_properties_; 503 HttpServerPropertiesImpl http_server_properties_;
486 std::unique_ptr<CertVerifier> cert_verifier_; 504 std::unique_ptr<CertVerifier> cert_verifier_;
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 request.Request(host_port_pair_, privacy_mode_, 2413 request.Request(host_port_pair_, privacy_mode_,
2396 /*cert_verify_flags=*/0, url_, "GET", net_log_, 2414 /*cert_verify_flags=*/0, url_, "GET", net_log_,
2397 callback_.callback())); 2415 callback_.callback()));
2398 2416
2399 EXPECT_EQ(OK, callback_.WaitForResult()); 2417 EXPECT_EQ(OK, callback_.WaitForResult());
2400 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); 2418 std::unique_ptr<QuicHttpStream> stream = request.CreateStream();
2401 HttpRequestInfo request_info; 2419 HttpRequestInfo request_info;
2402 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, 2420 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY,
2403 net_log_, CompletionCallback())); 2421 net_log_, CompletionCallback()));
2404 2422
2405 factory_->OnSSLConfigChanged(); 2423 ssl_config_service_->NotifySSLConfigChange();
Ryan Hamilton 2016/06/29 23:16:15 Well, that was easy!
2406 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, 2424 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED,
2407 stream->ReadResponseHeaders(callback_.callback())); 2425 stream->ReadResponseHeaders(callback_.callback()));
2408 EXPECT_FALSE(factory_->require_confirmation()); 2426 EXPECT_FALSE(factory_->require_confirmation());
2409 2427
2410 // Now attempting to request a stream to the same origin should create 2428 // Now attempting to request a stream to the same origin should create
2411 // a new session. 2429 // a new session.
2412 2430
2413 QuicStreamRequest request2(factory_.get()); 2431 QuicStreamRequest request2(factory_.get());
2414 EXPECT_EQ(ERR_IO_PENDING, 2432 EXPECT_EQ(ERR_IO_PENDING,
2415 request2.Request(host_port_pair_, privacy_mode_, 2433 request2.Request(host_port_pair_, privacy_mode_,
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
4331 EXPECT_NE(session1, session2); 4349 EXPECT_NE(session1, session2);
4332 4350
4333 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id()); 4351 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id());
4334 EXPECT_EQ(QuicServerId(origin2_, privacy_mode_), session2->server_id()); 4352 EXPECT_EQ(QuicServerId(origin2_, privacy_mode_), session2->server_id());
4335 4353
4336 EXPECT_TRUE(AllDataConsumed()); 4354 EXPECT_TRUE(AllDataConsumed());
4337 } 4355 }
4338 4356
4339 } // namespace test 4357 } // namespace test
4340 } // namespace net 4358 } // namespace net
OLDNEW
« net/quic/quic_stream_factory.cc ('K') | « net/quic/quic_stream_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698