Chromium Code Reviews

Side by Side Diff: net/http/http_network_layer_unittest.cc

Issue 16501002: Give more request types a TransportSecurityState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Enforce CalledOnValidThread in all non-static methods. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | 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/http/http_network_layer.h" 5 #include "net/http/http_network_layer.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "net/base/net_log.h" 8 #include "net/base/net_log.h"
9 #include "net/cert/mock_cert_verifier.h" 9 #include "net/cert/mock_cert_verifier.h"
10 #include "net/dns/mock_host_resolver.h" 10 #include "net/dns/mock_host_resolver.h"
11 #include "net/http/http_network_session.h" 11 #include "net/http/http_network_session.h"
12 #include "net/http/http_server_properties_impl.h" 12 #include "net/http/http_server_properties_impl.h"
13 #include "net/http/http_transaction_unittest.h" 13 #include "net/http/http_transaction_unittest.h"
14 #include "net/http/transport_security_state.h"
14 #include "net/proxy/proxy_service.h" 15 #include "net/proxy/proxy_service.h"
15 #include "net/socket/socket_test_util.h" 16 #include "net/socket/socket_test_util.h"
16 #include "net/spdy/spdy_session_pool.h" 17 #include "net/spdy/spdy_session_pool.h"
17 #include "net/ssl/ssl_config_service_defaults.h" 18 #include "net/ssl/ssl_config_service_defaults.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 namespace { 24 namespace {
24 25
25 class HttpNetworkLayerTest : public PlatformTest { 26 class HttpNetworkLayerTest : public PlatformTest {
26 protected: 27 protected:
27 HttpNetworkLayerTest() : ssl_config_service_(new SSLConfigServiceDefaults) {} 28 HttpNetworkLayerTest() : ssl_config_service_(new SSLConfigServiceDefaults) {}
28 29
29 virtual void SetUp() { 30 virtual void SetUp() {
30 ConfigureTestDependencies(ProxyService::CreateDirect()); 31 ConfigureTestDependencies(ProxyService::CreateDirect());
31 } 32 }
32 33
33 void ConfigureTestDependencies(ProxyService* proxy_service) { 34 void ConfigureTestDependencies(ProxyService* proxy_service) {
34 cert_verifier_.reset(new MockCertVerifier); 35 cert_verifier_.reset(new MockCertVerifier);
36 transport_security_state_.reset(new TransportSecurityState);
35 proxy_service_.reset(proxy_service); 37 proxy_service_.reset(proxy_service);
36 HttpNetworkSession::Params session_params; 38 HttpNetworkSession::Params session_params;
37 session_params.client_socket_factory = &mock_socket_factory_; 39 session_params.client_socket_factory = &mock_socket_factory_;
38 session_params.host_resolver = &host_resolver_; 40 session_params.host_resolver = &host_resolver_;
39 session_params.cert_verifier = cert_verifier_.get(); 41 session_params.cert_verifier = cert_verifier_.get();
42 session_params.transport_security_state = transport_security_state_.get();
40 session_params.proxy_service = proxy_service_.get(); 43 session_params.proxy_service = proxy_service_.get();
41 session_params.ssl_config_service = ssl_config_service_.get(); 44 session_params.ssl_config_service = ssl_config_service_.get();
42 session_params.http_server_properties = &http_server_properties_; 45 session_params.http_server_properties = &http_server_properties_;
43 network_session_ = new HttpNetworkSession(session_params); 46 network_session_ = new HttpNetworkSession(session_params);
44 factory_.reset(new HttpNetworkLayer(network_session_.get())); 47 factory_.reset(new HttpNetworkLayer(network_session_.get()));
45 } 48 }
46 49
47 MockClientSocketFactory mock_socket_factory_; 50 MockClientSocketFactory mock_socket_factory_;
48 MockHostResolver host_resolver_; 51 MockHostResolver host_resolver_;
49 scoped_ptr<CertVerifier> cert_verifier_; 52 scoped_ptr<CertVerifier> cert_verifier_;
53 scoped_ptr<TransportSecurityState> transport_security_state_;
50 scoped_ptr<ProxyService> proxy_service_; 54 scoped_ptr<ProxyService> proxy_service_;
51 const scoped_refptr<SSLConfigService> ssl_config_service_; 55 const scoped_refptr<SSLConfigService> ssl_config_service_;
52 scoped_refptr<HttpNetworkSession> network_session_; 56 scoped_refptr<HttpNetworkSession> network_session_;
53 scoped_ptr<HttpNetworkLayer> factory_; 57 scoped_ptr<HttpNetworkLayer> factory_;
54 HttpServerPropertiesImpl http_server_properties_; 58 HttpServerPropertiesImpl http_server_properties_;
55 }; 59 };
56 60
57 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { 61 TEST_F(HttpNetworkLayerTest, CreateAndDestroy) {
58 scoped_ptr<HttpTransaction> trans; 62 scoped_ptr<HttpTransaction> trans;
59 int rv = factory_->CreateTransaction(DEFAULT_PRIORITY, &trans, NULL); 63 int rv = factory_->CreateTransaction(DEFAULT_PRIORITY, &trans, NULL);
(...skipping 373 matching lines...)
433 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv)); 437 ASSERT_EQ(ERR_CONNECTION_RESET, callback.GetResult(rv));
434 438
435 // If the response info is null, that means that any consumer won't 439 // If the response info is null, that means that any consumer won't
436 // see the network accessed bit set. 440 // see the network accessed bit set.
437 EXPECT_EQ(NULL, trans->GetResponseInfo()); 441 EXPECT_EQ(NULL, trans->GetResponseInfo());
438 } 442 }
439 443
440 } // namespace 444 } // namespace
441 445
442 } // namespace net 446 } // namespace net
OLDNEW
« no previous file with comments | « jingle/glue/proxy_resolving_client_socket.cc ('k') | net/http/http_network_transaction_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine