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

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

Issue 9960002: Make all the things use cert_test_util.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nitfix Created 8 years, 8 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/base/cert_database_nss_unittest.cc ('k') | remoting/protocol/authenticator_test_base.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 // This test suite uses SSLClientSocket to test the implementation of 5 // This test suite uses SSLClientSocket to test the implementation of
6 // SSLServerSocket. In order to establish connections between the sockets 6 // SSLServerSocket. In order to establish connections between the sockets
7 // we need two additional classes: 7 // we need two additional classes:
8 // 1. FakeSocket 8 // 1. FakeSocket
9 // Connects SSL socket to FakeDataChannel. This class is just a stub. 9 // Connects SSL socket to FakeDataChannel. This class is just a stub.
10 // 10 //
(...skipping 10 matching lines...) Expand all
21 21
22 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
23 #include "base/file_path.h" 23 #include "base/file_path.h"
24 #include "base/file_util.h" 24 #include "base/file_util.h"
25 #include "base/message_loop.h" 25 #include "base/message_loop.h"
26 #include "base/path_service.h" 26 #include "base/path_service.h"
27 #include "crypto/nss_util.h" 27 #include "crypto/nss_util.h"
28 #include "crypto/rsa_private_key.h" 28 #include "crypto/rsa_private_key.h"
29 #include "net/base/address_list.h" 29 #include "net/base/address_list.h"
30 #include "net/base/cert_status_flags.h" 30 #include "net/base/cert_status_flags.h"
31 #include "net/base/cert_test_util.h"
31 #include "net/base/cert_verifier.h" 32 #include "net/base/cert_verifier.h"
32 #include "net/base/completion_callback.h" 33 #include "net/base/completion_callback.h"
33 #include "net/base/host_port_pair.h" 34 #include "net/base/host_port_pair.h"
34 #include "net/base/io_buffer.h" 35 #include "net/base/io_buffer.h"
35 #include "net/base/ip_endpoint.h" 36 #include "net/base/ip_endpoint.h"
36 #include "net/base/net_errors.h" 37 #include "net/base/net_errors.h"
37 #include "net/base/net_log.h" 38 #include "net/base/net_log.h"
38 #include "net/base/ssl_config_service.h" 39 #include "net/base/ssl_config_service.h"
39 #include "net/base/ssl_info.h" 40 #include "net/base/ssl_info.h"
40 #include "net/base/x509_certificate.h" 41 #include "net/base/x509_certificate.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 SSLServerSocketTest() 248 SSLServerSocketTest()
248 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()), 249 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()),
249 cert_verifier_(net::CertVerifier::CreateDefault()) { 250 cert_verifier_(net::CertVerifier::CreateDefault()) {
250 } 251 }
251 252
252 protected: 253 protected:
253 void Initialize() { 254 void Initialize() {
254 FakeSocket* fake_client_socket = new FakeSocket(&channel_1_, &channel_2_); 255 FakeSocket* fake_client_socket = new FakeSocket(&channel_1_, &channel_2_);
255 FakeSocket* fake_server_socket = new FakeSocket(&channel_2_, &channel_1_); 256 FakeSocket* fake_server_socket = new FakeSocket(&channel_2_, &channel_1_);
256 257
257 FilePath certs_dir; 258 FilePath certs_dir(GetTestCertsDirectory());
258 PathService::Get(base::DIR_SOURCE_ROOT, &certs_dir);
259 certs_dir = certs_dir.AppendASCII("net");
260 certs_dir = certs_dir.AppendASCII("data");
261 certs_dir = certs_dir.AppendASCII("ssl");
262 certs_dir = certs_dir.AppendASCII("certificates");
263 259
264 FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); 260 FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der");
265 std::string cert_der; 261 std::string cert_der;
266 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &cert_der)); 262 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &cert_der));
267 263
268 scoped_refptr<net::X509Certificate> cert = 264 scoped_refptr<net::X509Certificate> cert =
269 X509Certificate::CreateFromBytes(cert_der.data(), cert_der.size()); 265 X509Certificate::CreateFromBytes(cert_der.data(), cert_der.size());
270 266
271 FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); 267 FilePath key_path = certs_dir.AppendASCII("unittest.key.bin");
272 std::string key_string; 268 std::string key_string;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 unsigned char client_bad[kKeyingMaterialSize]; 468 unsigned char client_bad[kKeyingMaterialSize];
473 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad, 469 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad,
474 false, kKeyingContext, 470 false, kKeyingContext,
475 client_bad, sizeof(client_bad)); 471 client_bad, sizeof(client_bad));
476 ASSERT_EQ(rv, net::OK); 472 ASSERT_EQ(rv, net::OK);
477 EXPECT_TRUE(memcmp(server_out, client_bad, sizeof(server_out)) != 0); 473 EXPECT_TRUE(memcmp(server_out, client_bad, sizeof(server_out)) != 0);
478 } 474 }
479 #endif 475 #endif
480 476
481 } // namespace net 477 } // namespace net
OLDNEW
« no previous file with comments | « net/base/cert_database_nss_unittest.cc ('k') | remoting/protocol/authenticator_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698