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

Side by Side Diff: net/socket/ssl_client_socket_unittest.cc

Issue 257513008: Populate cert_key_types on OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Line length (try jobs on #8) Created 6 years, 7 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
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 "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "net/base/address_list.h" 10 #include "net/base/address_list.h"
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); 697 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig));
698 EXPECT_FALSE(sock->IsConnected()); 698 EXPECT_FALSE(sock->IsConnected());
699 699
700 rv = sock->Connect(callback.callback()); 700 rv = sock->Connect(callback.callback());
701 if (rv == ERR_IO_PENDING) 701 if (rv == ERR_IO_PENDING)
702 rv = callback.WaitForResult(); 702 rv = callback.WaitForResult();
703 scoped_refptr<SSLCertRequestInfo> request_info = new SSLCertRequestInfo(); 703 scoped_refptr<SSLCertRequestInfo> request_info = new SSLCertRequestInfo();
704 sock->GetSSLCertRequestInfo(request_info.get()); 704 sock->GetSSLCertRequestInfo(request_info.get());
705 sock->Disconnect(); 705 sock->Disconnect();
706 EXPECT_FALSE(sock->IsConnected()); 706 EXPECT_FALSE(sock->IsConnected());
707 EXPECT_TRUE(
708 test_server.host_port_pair().Equals(request_info->host_and_port));
707 709
708 return request_info; 710 return request_info;
709 } 711 }
710 }; 712 };
711 713
712 class SSLClientSocketFalseStartTest : public SSLClientSocketTest { 714 class SSLClientSocketFalseStartTest : public SSLClientSocketTest {
713 protected: 715 protected:
714 void TestFalseStart(const SpawnedTestServer::SSLOptions& server_options, 716 void TestFalseStart(const SpawnedTestServer::SSLOptions& server_options,
715 const SSLConfig& client_config, 717 const SSLConfig& client_config,
716 bool expect_false_start) { 718 bool expect_false_start) {
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options); 2214 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options);
2213 ASSERT_TRUE(request_info.get()); 2215 ASSERT_TRUE(request_info.get());
2214 ASSERT_EQ(2u, request_info->cert_authorities.size()); 2216 ASSERT_EQ(2u, request_info->cert_authorities.size());
2215 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), 2217 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen),
2216 request_info->cert_authorities[0]); 2218 request_info->cert_authorities[0]);
2217 EXPECT_EQ( 2219 EXPECT_EQ(
2218 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), 2220 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen),
2219 request_info->cert_authorities[1]); 2221 request_info->cert_authorities[1]);
2220 } 2222 }
2221 2223
2224 // cert_key_types is currently only populated on OpenSSL.
2225 #if defined(USE_OPENSSL)
2226 TEST_F(SSLClientSocketCertRequestInfoTest, CertKeyTypes) {
2227 SpawnedTestServer::SSLOptions ssl_options;
2228 ssl_options.request_client_certificate = true;
2229 ssl_options.client_cert_types.push_back(CLIENT_CERT_RSA_SIGN);
2230 ssl_options.client_cert_types.push_back(CLIENT_CERT_ECDSA_SIGN);
2231 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options);
2232 ASSERT_TRUE(request_info.get());
2233 ASSERT_EQ(2u, request_info->cert_key_types.size());
2234 EXPECT_EQ(CLIENT_CERT_RSA_SIGN, request_info->cert_key_types[0]);
2235 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, request_info->cert_key_types[1]);
2236 }
2237 #endif // defined(USE_OPENSSL)
2238
2222 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledTLSExtension) { 2239 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledTLSExtension) {
2223 SpawnedTestServer::SSLOptions ssl_options; 2240 SpawnedTestServer::SSLOptions ssl_options;
2224 ssl_options.signed_cert_timestamps_tls_ext = "test"; 2241 ssl_options.signed_cert_timestamps_tls_ext = "test";
2225 2242
2226 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, 2243 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS,
2227 ssl_options, 2244 ssl_options,
2228 base::FilePath()); 2245 base::FilePath());
2229 ASSERT_TRUE(test_server.Start()); 2246 ASSERT_TRUE(test_server.Start());
2230 2247
2231 AddressList addr; 2248 AddressList addr;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 2519
2503 // TODO(haavardm@opera.com): Due to differences in threading, Linux returns 2520 // TODO(haavardm@opera.com): Due to differences in threading, Linux returns
2504 // ERR_UNEXPECTED while Mac and Windows return ERR_PROTOCOL_ERROR. Accept all 2521 // ERR_UNEXPECTED while Mac and Windows return ERR_PROTOCOL_ERROR. Accept all
2505 // error codes for now. 2522 // error codes for now.
2506 // http://crbug.com/373670 2523 // http://crbug.com/373670
2507 EXPECT_NE(OK, rv); 2524 EXPECT_NE(OK, rv);
2508 EXPECT_FALSE(sock_->IsConnected()); 2525 EXPECT_FALSE(sock_->IsConnected());
2509 } 2526 }
2510 2527
2511 } // namespace net 2528 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_openssl.cc ('k') | net/test/spawned_test_server/base_test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698