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

Side by Side Diff: net/cert/nss_cert_database_unittest.cc

Issue 2000503002: Remove the fingerprint and ca_fingerprint from X509Certificate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_cache
Patch Set: Fix IDN test 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/cert_verify_proc_win.cc ('k') | net/cert/nss_profile_filter_chromeos_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/cert/nss_cert_database.h" 5 #include "net/cert/nss_cert_database.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <pk11pub.h> 9 #include <pk11pub.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
23 #include "crypto/scoped_nss_types.h" 23 #include "crypto/scoped_nss_types.h"
24 #include "crypto/scoped_test_nss_db.h" 24 #include "crypto/scoped_test_nss_db.h"
25 #include "net/base/crypto_module.h" 25 #include "net/base/crypto_module.h"
26 #include "net/base/hash_value.h"
26 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
27 #include "net/base/test_data_directory.h" 28 #include "net/base/test_data_directory.h"
28 #include "net/cert/cert_status_flags.h" 29 #include "net/cert/cert_status_flags.h"
29 #include "net/cert/cert_verify_proc_nss.h" 30 #include "net/cert/cert_verify_proc_nss.h"
30 #include "net/cert/cert_verify_result.h" 31 #include "net/cert/cert_verify_result.h"
31 #include "net/cert/x509_certificate.h" 32 #include "net/cert/x509_certificate.h"
32 #include "net/test/cert_test_util.h" 33 #include "net/test/cert_test_util.h"
33 #include "net/third_party/mozilla_security_manager/nsNSSCertificateDB.h" 34 #include "net/third_party/mozilla_security_manager/nsNSSCertificateDB.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 36
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 CERTCertList* cert_list = PK11_ListCertsInSlot(test_nssdb_.slot()); 102 CERTCertList* cert_list = PK11_ListCertsInSlot(test_nssdb_.slot());
102 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); 103 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list);
103 !CERT_LIST_END(node, cert_list); 104 !CERT_LIST_END(node, cert_list);
104 node = CERT_LIST_NEXT(node)) { 105 node = CERT_LIST_NEXT(node)) {
105 result.push_back(X509Certificate::CreateFromHandle( 106 result.push_back(X509Certificate::CreateFromHandle(
106 node->cert, X509Certificate::OSCertHandles())); 107 node->cert, X509Certificate::OSCertHandles()));
107 } 108 }
108 CERT_DestroyCertList(cert_list); 109 CERT_DestroyCertList(cert_list);
109 110
110 // Sort the result so that test comparisons can be deterministic. 111 // Sort the result so that test comparisons can be deterministic.
111 std::sort(result.begin(), result.end(), X509Certificate::LessThan()); 112 std::sort(
113 result.begin(), result.end(),
114 [](const scoped_refptr<X509Certificate>& lhs,
115 const scoped_refptr<X509Certificate>& rhs) {
116 return SHA256HashValueLessThan()(
117 X509Certificate::CalculateFingerprint256(lhs->os_cert_handle()),
118 X509Certificate::CalculateFingerprint256(rhs->os_cert_handle()));
119 });
112 return result; 120 return result;
113 } 121 }
114 122
115 std::unique_ptr<NSSCertDatabase> cert_db_; 123 std::unique_ptr<NSSCertDatabase> cert_db_;
116 const CertificateList empty_cert_list_; 124 const CertificateList empty_cert_list_;
117 crypto::ScopedTestNSSDB test_nssdb_; 125 crypto::ScopedTestNSSDB test_nssdb_;
118 scoped_refptr<CryptoModule> public_module_; 126 scoped_refptr<CryptoModule> public_module_;
119 }; 127 };
120 128
121 TEST_F(CertDatabaseNSSTest, ListCertsSync) { 129 TEST_F(CertDatabaseNSSTest, ListCertsSync) {
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 EXPECT_EQ(NSSCertDatabase::TRUST_DEFAULT, 981 EXPECT_EQ(NSSCertDatabase::TRUST_DEFAULT,
974 cert_db_->GetCertTrust(certs2[0].get(), SERVER_CERT)); 982 cert_db_->GetCertTrust(certs2[0].get(), SERVER_CERT));
975 983
976 new_certs = ListCerts(); 984 new_certs = ListCerts();
977 ASSERT_EQ(2U, new_certs.size()); 985 ASSERT_EQ(2U, new_certs.size());
978 EXPECT_STRNE(new_certs[0]->os_cert_handle()->nickname, 986 EXPECT_STRNE(new_certs[0]->os_cert_handle()->nickname,
979 new_certs[1]->os_cert_handle()->nickname); 987 new_certs[1]->os_cert_handle()->nickname);
980 } 988 }
981 989
982 } // namespace net 990 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/cert_verify_proc_win.cc ('k') | net/cert/nss_profile_filter_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698