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

Side by Side Diff: net/socket/ssl_client_socket_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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_client_socket_pool_unittest.cc ('k') | net/socket/ssl_server_socket_unittest.cc » ('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/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "net/base/address_list.h" 9 #include "net/base/address_list.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
13 #include "net/base/net_log_unittest.h" 13 #include "net/base/net_log_unittest.h"
14 #include "net/base/test_completion_callback.h" 14 #include "net/base/test_completion_callback.h"
15 #include "net/base/test_data_directory.h" 15 #include "net/base/test_data_directory.h"
16 #include "net/cert/mock_cert_verifier.h" 16 #include "net/cert/mock_cert_verifier.h"
17 #include "net/cert/test_root_certs.h" 17 #include "net/cert/test_root_certs.h"
18 #include "net/dns/host_resolver.h" 18 #include "net/dns/host_resolver.h"
19 #include "net/http/transport_security_state.h"
19 #include "net/socket/client_socket_factory.h" 20 #include "net/socket/client_socket_factory.h"
20 #include "net/socket/client_socket_handle.h" 21 #include "net/socket/client_socket_handle.h"
21 #include "net/socket/socket_test_util.h" 22 #include "net/socket/socket_test_util.h"
22 #include "net/socket/tcp_client_socket.h" 23 #include "net/socket/tcp_client_socket.h"
23 #include "net/ssl/ssl_cert_request_info.h" 24 #include "net/ssl/ssl_cert_request_info.h"
24 #include "net/ssl/ssl_config_service.h" 25 #include "net/ssl/ssl_config_service.h"
25 #include "net/test/cert_test_util.h" 26 #include "net/test/cert_test_util.h"
26 #include "net/test/spawned_test_server/spawned_test_server.h" 27 #include "net/test/spawned_test_server/spawned_test_server.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "testing/platform_test.h" 29 #include "testing/platform_test.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 499
499 DISALLOW_COPY_AND_ASSIGN(DeleteSocketCallback); 500 DISALLOW_COPY_AND_ASSIGN(DeleteSocketCallback);
500 }; 501 };
501 502
502 } // namespace 503 } // namespace
503 504
504 class SSLClientSocketTest : public PlatformTest { 505 class SSLClientSocketTest : public PlatformTest {
505 public: 506 public:
506 SSLClientSocketTest() 507 SSLClientSocketTest()
507 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()), 508 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()),
508 cert_verifier_(new net::MockCertVerifier) { 509 cert_verifier_(new net::MockCertVerifier),
510 transport_security_state_(new net::TransportSecurityState) {
509 cert_verifier_->set_default_result(net::OK); 511 cert_verifier_->set_default_result(net::OK);
510 context_.cert_verifier = cert_verifier_.get(); 512 context_.cert_verifier = cert_verifier_.get();
513 context_.transport_security_state = transport_security_state_.get();
511 } 514 }
512 515
513 protected: 516 protected:
514 net::SSLClientSocket* CreateSSLClientSocket( 517 net::SSLClientSocket* CreateSSLClientSocket(
515 net::StreamSocket* transport_socket, 518 net::StreamSocket* transport_socket,
516 const net::HostPortPair& host_and_port, 519 const net::HostPortPair& host_and_port,
517 const net::SSLConfig& ssl_config) { 520 const net::SSLConfig& ssl_config) {
518 return socket_factory_->CreateSSLClientSocket(transport_socket, 521 return socket_factory_->CreateSSLClientSocket(transport_socket,
519 host_and_port, 522 host_and_port,
520 ssl_config, 523 ssl_config,
521 context_); 524 context_);
522 } 525 }
523 526
524 net::ClientSocketFactory* socket_factory_; 527 net::ClientSocketFactory* socket_factory_;
525 scoped_ptr<net::MockCertVerifier> cert_verifier_; 528 scoped_ptr<net::MockCertVerifier> cert_verifier_;
529 scoped_ptr<net::TransportSecurityState> transport_security_state_;
526 net::SSLClientSocketContext context_; 530 net::SSLClientSocketContext context_;
527 }; 531 };
528 532
529 //----------------------------------------------------------------------------- 533 //-----------------------------------------------------------------------------
530 534
531 // LogContainsSSLConnectEndEvent returns true if the given index in the given 535 // LogContainsSSLConnectEndEvent returns true if the given index in the given
532 // log is an SSL connect end event. The NSS sockets will cork in an attempt to 536 // log is an SSL connect end event. The NSS sockets will cork in an attempt to
533 // merge the first application data record with the Finished message when false 537 // merge the first application data record with the Finished message when false
534 // starting. However, in order to avoid the server timing out the handshake, 538 // starting. However, in order to avoid the server timing out the handshake,
535 // they'll give up waiting for application data and send the Finished after a 539 // they'll give up waiting for application data and send the Finished after a
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 scoped_refptr<net::SSLCertRequestInfo> request_info = 1740 scoped_refptr<net::SSLCertRequestInfo> request_info =
1737 GetCertRequest(ssl_options); 1741 GetCertRequest(ssl_options);
1738 ASSERT_TRUE(request_info.get()); 1742 ASSERT_TRUE(request_info.get());
1739 ASSERT_EQ(2u, request_info->cert_authorities.size()); 1743 ASSERT_EQ(2u, request_info->cert_authorities.size());
1740 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), 1744 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen),
1741 request_info->cert_authorities[0]); 1745 request_info->cert_authorities[0]);
1742 EXPECT_EQ( 1746 EXPECT_EQ(
1743 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), 1747 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen),
1744 request_info->cert_authorities[1]); 1748 request_info->cert_authorities[1]);
1745 } 1749 }
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_pool_unittest.cc ('k') | net/socket/ssl_server_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698