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

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service_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: Created 4 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
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 "chrome/browser/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/base_paths.h" 14 #include "base/base_paths.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
19 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
20 #include "base/files/scoped_temp_dir.h" 20 #include "base/files/scoped_temp_dir.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/ref_counted.h" 22 #include "base/memory/ref_counted.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/path_service.h" 24 #include "base/path_service.h"
25 #include "base/run_loop.h" 25 #include "base/run_loop.h"
26 #include "base/sha1.h"
26 #include "base/strings/string_number_conversions.h" 27 #include "base/strings/string_number_conversions.h"
27 #include "base/threading/sequenced_worker_pool.h" 28 #include "base/threading/sequenced_worker_pool.h"
28 #include "chrome/browser/history/history_service_factory.h" 29 #include "chrome/browser/history/history_service_factory.h"
29 #include "chrome/browser/safe_browsing/download_feedback_service.h" 30 #include "chrome/browser/safe_browsing/download_feedback_service.h"
30 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" 31 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h"
31 #include "chrome/browser/safe_browsing/local_database_manager.h" 32 #include "chrome/browser/safe_browsing/local_database_manager.h"
32 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 33 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
33 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
35 #include "chrome/common/safe_browsing/binary_feature_extractor.h" 36 #include "chrome/common/safe_browsing/binary_feature_extractor.h"
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 EXPECT_FALSE(HasClientDownloadRequest()); 1725 EXPECT_FALSE(HasClientDownloadRequest());
1725 } 1726 }
1726 1727
1727 TEST_F(DownloadProtectionServiceTest, GetCertificateWhitelistStrings) { 1728 TEST_F(DownloadProtectionServiceTest, GetCertificateWhitelistStrings) {
1728 // We'll pass this cert in as the "issuer", even though it isn't really 1729 // We'll pass this cert in as the "issuer", even though it isn't really
1729 // used to sign the certs below. GetCertificateWhitelistStirngs doesn't care 1730 // used to sign the certs below. GetCertificateWhitelistStirngs doesn't care
1730 // about this. 1731 // about this.
1731 scoped_refptr<net::X509Certificate> issuer_cert( 1732 scoped_refptr<net::X509Certificate> issuer_cert(
1732 ReadTestCertificate("issuer.pem")); 1733 ReadTestCertificate("issuer.pem"));
1733 ASSERT_TRUE(issuer_cert.get()); 1734 ASSERT_TRUE(issuer_cert.get());
1734 std::string cert_base = "cert/" + base::HexEncode( 1735 std::string issuer_der;
1735 issuer_cert->fingerprint().data, 1736 net::X509Certificate::GetDEREncoded(issuer_cert->os_cert_handle(),
1736 sizeof(issuer_cert->fingerprint().data)); 1737 &issuer_der);
1738 std::string hashed = base::SHA1HashString(issuer_der);
1739 std::string cert_base =
1740 "cert/" + base::HexEncode(hashed.data(), hashed.size());
1737 1741
1738 scoped_refptr<net::X509Certificate> cert(ReadTestCertificate("test_cn.pem")); 1742 scoped_refptr<net::X509Certificate> cert(ReadTestCertificate("test_cn.pem"));
1739 ASSERT_TRUE(cert.get()); 1743 ASSERT_TRUE(cert.get());
1740 std::vector<std::string> whitelist_strings; 1744 std::vector<std::string> whitelist_strings;
1741 GetCertificateWhitelistStrings( 1745 GetCertificateWhitelistStrings(
1742 *cert.get(), *issuer_cert.get(), &whitelist_strings); 1746 *cert.get(), *issuer_cert.get(), &whitelist_strings);
1743 // This also tests escaping of characters in the certificate attributes. 1747 // This also tests escaping of characters in the certificate attributes.
1744 EXPECT_THAT(whitelist_strings, ElementsAre( 1748 EXPECT_THAT(whitelist_strings, ElementsAre(
1745 cert_base + "/CN=subject%2F%251")); 1749 cert_base + "/CN=subject%2F%251"));
1746 1750
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1922 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1919 base::Unretained(this))); 1923 base::Unretained(this)));
1920 MessageLoop::current()->Run(); 1924 MessageLoop::current()->Run();
1921 1925
1922 EXPECT_FALSE(HasClientDownloadRequest()); 1926 EXPECT_FALSE(HasClientDownloadRequest());
1923 // Overriden by flag: 1927 // Overriden by flag:
1924 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 1928 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
1925 } 1929 }
1926 1930
1927 } // namespace safe_browsing 1931 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698