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

Side by Side Diff: net/spdy/spdy_test_util_common.cc

Issue 2067843003: Require a CTVerifier and CTPolicyEnforcer for TLS/QUIC sockets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/spdy/spdy_test_util_common.h ('k') | net/url_request/url_request_context.h » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/spdy/spdy_test_util_common.h" 5 #include "net/spdy/spdy_test_util_common.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "net/base/host_port_pair.h" 18 #include "net/base/host_port_pair.h"
19 #include "net/cert/ct_policy_enforcer.h"
19 #include "net/cert/mock_cert_verifier.h" 20 #include "net/cert/mock_cert_verifier.h"
21 #include "net/cert/multi_log_ct_verifier.h"
20 #include "net/http/http_cache.h" 22 #include "net/http/http_cache.h"
21 #include "net/http/http_network_session.h" 23 #include "net/http/http_network_session.h"
22 #include "net/http/http_network_transaction.h" 24 #include "net/http/http_network_transaction.h"
23 #include "net/http/http_server_properties_impl.h" 25 #include "net/http/http_server_properties_impl.h"
24 #include "net/socket/socket_test_util.h" 26 #include "net/socket/socket_test_util.h"
25 #include "net/socket/ssl_client_socket.h" 27 #include "net/socket/ssl_client_socket.h"
26 #include "net/socket/transport_client_socket_pool.h" 28 #include "net/socket/transport_client_socket_pool.h"
27 #include "net/spdy/buffered_spdy_framer.h" 29 #include "net/spdy/buffered_spdy_framer.h"
28 #include "net/spdy/spdy_alt_svc_wire_format.h" 30 #include "net/spdy/spdy_alt_svc_wire_format.h"
29 #include "net/spdy/spdy_framer.h" 31 #include "net/spdy/spdy_framer.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 MockECSignatureCreatorFactory::~MockECSignatureCreatorFactory() { 326 MockECSignatureCreatorFactory::~MockECSignatureCreatorFactory() {
325 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); 327 crypto::ECSignatureCreator::SetFactoryForTesting(NULL);
326 } 328 }
327 329
328 crypto::ECSignatureCreator* MockECSignatureCreatorFactory::Create( 330 crypto::ECSignatureCreator* MockECSignatureCreatorFactory::Create(
329 crypto::ECPrivateKey* key) { 331 crypto::ECPrivateKey* key) {
330 return new MockECSignatureCreator(key); 332 return new MockECSignatureCreator(key);
331 } 333 }
332 334
333 SpdySessionDependencies::SpdySessionDependencies(NextProto protocol) 335 SpdySessionDependencies::SpdySessionDependencies(NextProto protocol)
336 : SpdySessionDependencies(protocol, ProxyService::CreateDirect()) {}
337
338 SpdySessionDependencies::SpdySessionDependencies(
339 NextProto protocol,
340 std::unique_ptr<ProxyService> proxy_service)
334 : host_resolver(new MockCachingHostResolver), 341 : host_resolver(new MockCachingHostResolver),
335 cert_verifier(new MockCertVerifier), 342 cert_verifier(new MockCertVerifier),
336 channel_id_service(nullptr), 343 channel_id_service(nullptr),
337 transport_security_state(new TransportSecurityState), 344 transport_security_state(new TransportSecurityState),
338 proxy_service(ProxyService::CreateDirect()), 345 cert_transparency_verifier(new MultiLogCTVerifier),
346 ct_policy_enforcer(new CTPolicyEnforcer),
347 proxy_service(std::move(proxy_service)),
339 ssl_config_service(new SSLConfigServiceDefaults), 348 ssl_config_service(new SSLConfigServiceDefaults),
340 socket_factory(new MockClientSocketFactory), 349 socket_factory(new MockClientSocketFactory),
341 http_auth_handler_factory( 350 http_auth_handler_factory(
342 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), 351 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())),
343 enable_ip_pooling(true), 352 enable_ip_pooling(true),
344 enable_ping(false), 353 enable_ping(false),
345 enable_user_alternate_protocol_ports(false), 354 enable_user_alternate_protocol_ports(false),
346 enable_npn(false), 355 enable_npn(false),
347 enable_priority_dependencies(true), 356 enable_priority_dependencies(true),
348 enable_spdy31(true), 357 enable_spdy31(true),
349 enable_quic(false), 358 enable_quic(false),
350 enable_alternative_service_for_insecure_origins(true), 359 enable_alternative_service_for_insecure_origins(true),
351 protocol(protocol), 360 protocol(protocol),
352 session_max_recv_window_size( 361 session_max_recv_window_size(
353 SpdySession::GetDefaultInitialWindowSize(protocol)), 362 SpdySession::GetDefaultInitialWindowSize(protocol)),
354 stream_max_recv_window_size( 363 stream_max_recv_window_size(
355 SpdySession::GetDefaultInitialWindowSize(protocol)), 364 SpdySession::GetDefaultInitialWindowSize(protocol)),
356 time_func(&base::TimeTicks::Now), 365 time_func(&base::TimeTicks::Now),
357 enable_alternative_service_with_different_host(true), 366 enable_alternative_service_with_different_host(true),
358 net_log(NULL) { 367 net_log(NULL) {
359 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol; 368 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol;
360 369
361 // Note: The CancelledTransaction test does cleanup by running all 370 // Note: The CancelledTransaction test does cleanup by running all
362 // tasks in the message loop (RunAllPending). Unfortunately, that 371 // tasks in the message loop (RunAllPending). Unfortunately, that
363 // doesn't clean up tasks on the host resolver thread; and 372 // doesn't clean up tasks on the host resolver thread; and
364 // TCPConnectJob is currently not cancellable. Using synchronous 373 // TCPConnectJob is currently not cancellable. Using synchronous
365 // lookups allows the test to shutdown cleanly. Until we have 374 // lookups allows the test to shutdown cleanly. Until we have
366 // cancellable TCPConnectJobs, use synchronous lookups. 375 // cancellable TCPConnectJobs, use synchronous lookups.
367 host_resolver->set_synchronous_mode(true); 376 host_resolver->set_synchronous_mode(true);
Ryan Sleevi 2016/06/15 01:25:05 Interestingly, this *wasn't* set if you supplied a
368 } 377 }
369 378
370 SpdySessionDependencies::SpdySessionDependencies(
371 NextProto protocol,
372 std::unique_ptr<ProxyService> proxy_service)
373 : host_resolver(new MockHostResolver),
374 cert_verifier(new MockCertVerifier),
375 channel_id_service(nullptr),
376 transport_security_state(new TransportSecurityState),
377 proxy_service(std::move(proxy_service)),
378 ssl_config_service(new SSLConfigServiceDefaults),
379 socket_factory(new MockClientSocketFactory),
380 http_auth_handler_factory(
381 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())),
382 enable_ip_pooling(true),
383 enable_ping(false),
384 enable_user_alternate_protocol_ports(false),
385 enable_npn(false),
386 enable_priority_dependencies(true),
387 enable_spdy31(true),
388 enable_quic(false),
389 enable_alternative_service_for_insecure_origins(true),
390 protocol(protocol),
391 session_max_recv_window_size(
392 SpdySession::GetDefaultInitialWindowSize(protocol)),
393 stream_max_recv_window_size(
394 SpdySession::GetDefaultInitialWindowSize(protocol)),
395 time_func(&base::TimeTicks::Now),
396 enable_alternative_service_with_different_host(true),
397 net_log(NULL) {
398 DCHECK(next_proto_is_spdy(protocol)) << "Invalid protocol: " << protocol;
399 }
400
401 SpdySessionDependencies::~SpdySessionDependencies() {} 379 SpdySessionDependencies::~SpdySessionDependencies() {}
402 380
403 // static 381 // static
404 std::unique_ptr<HttpNetworkSession> SpdySessionDependencies::SpdyCreateSession( 382 std::unique_ptr<HttpNetworkSession> SpdySessionDependencies::SpdyCreateSession(
405 SpdySessionDependencies* session_deps) { 383 SpdySessionDependencies* session_deps) {
406 HttpNetworkSession::Params params = CreateSessionParams(session_deps); 384 HttpNetworkSession::Params params = CreateSessionParams(session_deps);
407 params.client_socket_factory = session_deps->socket_factory.get(); 385 params.client_socket_factory = session_deps->socket_factory.get();
408 std::unique_ptr<HttpNetworkSession> http_session( 386 std::unique_ptr<HttpNetworkSession> http_session(
409 new HttpNetworkSession(params)); 387 new HttpNetworkSession(params));
410 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool()); 388 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool());
411 pool_peer.SetEnableSendingInitialData(false); 389 pool_peer.SetEnableSendingInitialData(false);
412 return http_session; 390 return http_session;
413 } 391 }
414 392
415 // static 393 // static
416 HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams( 394 HttpNetworkSession::Params SpdySessionDependencies::CreateSessionParams(
417 SpdySessionDependencies* session_deps) { 395 SpdySessionDependencies* session_deps) {
418 DCHECK(next_proto_is_spdy(session_deps->protocol)) << 396 DCHECK(next_proto_is_spdy(session_deps->protocol)) <<
419 "Invalid protocol: " << session_deps->protocol; 397 "Invalid protocol: " << session_deps->protocol;
420 398
421 HttpNetworkSession::Params params; 399 HttpNetworkSession::Params params;
422 params.host_resolver = session_deps->host_resolver.get(); 400 params.host_resolver = session_deps->host_resolver.get();
423 params.cert_verifier = session_deps->cert_verifier.get(); 401 params.cert_verifier = session_deps->cert_verifier.get();
424 params.channel_id_service = session_deps->channel_id_service.get(); 402 params.channel_id_service = session_deps->channel_id_service.get();
425 params.transport_security_state = 403 params.transport_security_state =
426 session_deps->transport_security_state.get(); 404 session_deps->transport_security_state.get();
405 params.cert_transparency_verifier =
406 session_deps->cert_transparency_verifier.get();
407 params.ct_policy_enforcer = session_deps->ct_policy_enforcer.get();
427 params.proxy_service = session_deps->proxy_service.get(); 408 params.proxy_service = session_deps->proxy_service.get();
428 params.ssl_config_service = session_deps->ssl_config_service.get(); 409 params.ssl_config_service = session_deps->ssl_config_service.get();
429 params.http_auth_handler_factory = 410 params.http_auth_handler_factory =
430 session_deps->http_auth_handler_factory.get(); 411 session_deps->http_auth_handler_factory.get();
431 params.http_server_properties = 412 params.http_server_properties =
432 session_deps->http_server_properties.GetWeakPtr(); 413 session_deps->http_server_properties.GetWeakPtr();
433 params.enable_spdy_ping_based_connection_checking = session_deps->enable_ping; 414 params.enable_spdy_ping_based_connection_checking = session_deps->enable_ping;
434 params.enable_user_alternate_protocol_ports = 415 params.enable_user_alternate_protocol_ports =
435 session_deps->enable_user_alternate_protocol_ports; 416 session_deps->enable_user_alternate_protocol_ports;
436 params.enable_npn = session_deps->enable_npn; 417 params.enable_npn = session_deps->enable_npn;
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 } 1299 }
1319 } 1300 }
1320 1301
1321 void SpdyTestUtil::SetPriority(RequestPriority priority, 1302 void SpdyTestUtil::SetPriority(RequestPriority priority,
1322 SpdySynStreamIR* ir) const { 1303 SpdySynStreamIR* ir) const {
1323 ir->set_priority(ConvertRequestPriorityToSpdyPriority( 1304 ir->set_priority(ConvertRequestPriorityToSpdyPriority(
1324 priority, spdy_version())); 1305 priority, spdy_version()));
1325 } 1306 }
1326 1307
1327 } // namespace net 1308 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | net/url_request/url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698