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

Side by Side Diff: net/http/http_network_layer_unittest.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: Fixup 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/cert_net/cert_net_fetcher_impl_unittest.cc ('k') | net/http/http_network_session.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) 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/http/http_network_layer.h" 5 #include "net/http/http_network_layer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/cert/ct_policy_enforcer.h"
10 #include "net/cert/mock_cert_verifier.h" 11 #include "net/cert/mock_cert_verifier.h"
12 #include "net/cert/multi_log_ct_verifier.h"
11 #include "net/dns/mock_host_resolver.h" 13 #include "net/dns/mock_host_resolver.h"
12 #include "net/http/http_network_session.h" 14 #include "net/http/http_network_session.h"
13 #include "net/http/http_server_properties_impl.h" 15 #include "net/http/http_server_properties_impl.h"
14 #include "net/http/http_transaction_test_util.h" 16 #include "net/http/http_transaction_test_util.h"
15 #include "net/http/transport_security_state.h" 17 #include "net/http/transport_security_state.h"
16 #include "net/log/net_log.h" 18 #include "net/log/net_log.h"
17 #include "net/proxy/proxy_service.h" 19 #include "net/proxy/proxy_service.h"
18 #include "net/socket/socket_test_util.h" 20 #include "net/socket/socket_test_util.h"
19 #include "net/spdy/spdy_session_pool.h" 21 #include "net/spdy/spdy_session_pool.h"
20 #include "net/ssl/ssl_config_service_defaults.h" 22 #include "net/ssl/ssl_config_service_defaults.h"
(...skipping 14 matching lines...) Expand all
35 37
36 void ConfigureTestDependencies(std::unique_ptr<ProxyService> proxy_service) { 38 void ConfigureTestDependencies(std::unique_ptr<ProxyService> proxy_service) {
37 cert_verifier_.reset(new MockCertVerifier); 39 cert_verifier_.reset(new MockCertVerifier);
38 transport_security_state_.reset(new TransportSecurityState); 40 transport_security_state_.reset(new TransportSecurityState);
39 proxy_service_ = std::move(proxy_service); 41 proxy_service_ = std::move(proxy_service);
40 HttpNetworkSession::Params session_params; 42 HttpNetworkSession::Params session_params;
41 session_params.client_socket_factory = &mock_socket_factory_; 43 session_params.client_socket_factory = &mock_socket_factory_;
42 session_params.host_resolver = &host_resolver_; 44 session_params.host_resolver = &host_resolver_;
43 session_params.cert_verifier = cert_verifier_.get(); 45 session_params.cert_verifier = cert_verifier_.get();
44 session_params.transport_security_state = transport_security_state_.get(); 46 session_params.transport_security_state = transport_security_state_.get();
47 session_params.cert_transparency_verifier = &ct_verifier_;
48 session_params.ct_policy_enforcer = &ct_policy_enforcer_;
45 session_params.proxy_service = proxy_service_.get(); 49 session_params.proxy_service = proxy_service_.get();
46 session_params.ssl_config_service = ssl_config_service_.get(); 50 session_params.ssl_config_service = ssl_config_service_.get();
47 session_params.http_server_properties = &http_server_properties_; 51 session_params.http_server_properties = &http_server_properties_;
48 network_session_.reset(new HttpNetworkSession(session_params)); 52 network_session_.reset(new HttpNetworkSession(session_params));
49 factory_.reset(new HttpNetworkLayer(network_session_.get())); 53 factory_.reset(new HttpNetworkLayer(network_session_.get()));
50 } 54 }
51 55
52 void ExecuteRequestExpectingContentAndHeader(const std::string& method, 56 void ExecuteRequestExpectingContentAndHeader(const std::string& method,
53 const std::string& content, 57 const std::string& content,
54 const std::string& header, 58 const std::string& header,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 ExecuteRequestExpectingContentAndHeader("GET", "Bypass message", "", ""); 254 ExecuteRequestExpectingContentAndHeader("GET", "Bypass message", "", "");
251 255
252 // We should also observe the bad proxy or proxies in the retry list. 256 // We should also observe the bad proxy or proxies in the retry list.
253 TestBadProxies(proxy_count, bad_proxy, bad_proxy2); 257 TestBadProxies(proxy_count, bad_proxy, bad_proxy2);
254 } 258 }
255 259
256 MockClientSocketFactory mock_socket_factory_; 260 MockClientSocketFactory mock_socket_factory_;
257 MockHostResolver host_resolver_; 261 MockHostResolver host_resolver_;
258 std::unique_ptr<CertVerifier> cert_verifier_; 262 std::unique_ptr<CertVerifier> cert_verifier_;
259 std::unique_ptr<TransportSecurityState> transport_security_state_; 263 std::unique_ptr<TransportSecurityState> transport_security_state_;
264 MultiLogCTVerifier ct_verifier_;
265 CTPolicyEnforcer ct_policy_enforcer_;
260 std::unique_ptr<ProxyService> proxy_service_; 266 std::unique_ptr<ProxyService> proxy_service_;
261 const scoped_refptr<SSLConfigService> ssl_config_service_; 267 const scoped_refptr<SSLConfigService> ssl_config_service_;
262 std::unique_ptr<HttpNetworkSession> network_session_; 268 std::unique_ptr<HttpNetworkSession> network_session_;
263 std::unique_ptr<HttpNetworkLayer> factory_; 269 std::unique_ptr<HttpNetworkLayer> factory_;
264 HttpServerPropertiesImpl http_server_properties_; 270 HttpServerPropertiesImpl http_server_properties_;
265 }; 271 };
266 272
267 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { 273 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
268 std::unique_ptr<HttpTransaction> trans; 274 std::unique_ptr<HttpTransaction> trans;
269 int rv = factory_->CreateTransaction(DEFAULT_PRIORITY, &trans); 275 int rv = factory_->CreateTransaction(DEFAULT_PRIORITY, &trans);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 rv = trans->Start(&request_info, callback.callback(), BoundNetLog()); 401 rv = trans->Start(&request_info, callback.callback(), BoundNetLog());
396 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv)); 402 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv));
397 403
398 // network_accessed is true; the HTTP stack did try to make a connection. 404 // network_accessed is true; the HTTP stack did try to make a connection.
399 EXPECT_TRUE(trans->GetResponseInfo()->network_accessed); 405 EXPECT_TRUE(trans->GetResponseInfo()->network_accessed);
400 } 406 }
401 407
402 } // namespace 408 } // namespace
403 409
404 } // namespace net 410 } // namespace net
OLDNEW
« no previous file with comments | « net/cert_net/cert_net_fetcher_impl_unittest.cc ('k') | net/http/http_network_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698