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

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: 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
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/location.h" 21 #include "base/location.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/ref_counted.h" 23 #include "base/memory/ref_counted.h"
24 #include "base/message_loop/message_loop.h" 24 #include "base/message_loop/message_loop.h"
25 #include "base/path_service.h" 25 #include "base/path_service.h"
26 #include "base/run_loop.h" 26 #include "base/run_loop.h"
27 #include "base/sha1.h"
27 #include "base/single_thread_task_runner.h" 28 #include "base/single_thread_task_runner.h"
28 #include "base/strings/string_number_conversions.h" 29 #include "base/strings/string_number_conversions.h"
29 #include "base/threading/sequenced_worker_pool.h" 30 #include "base/threading/sequenced_worker_pool.h"
30 #include "base/threading/thread_task_runner_handle.h" 31 #include "base/threading/thread_task_runner_handle.h"
31 #include "chrome/browser/history/history_service_factory.h" 32 #include "chrome/browser/history/history_service_factory.h"
32 #include "chrome/browser/safe_browsing/download_feedback_service.h" 33 #include "chrome/browser/safe_browsing/download_feedback_service.h"
33 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" 34 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h"
34 #include "chrome/browser/safe_browsing/local_database_manager.h" 35 #include "chrome/browser/safe_browsing/local_database_manager.h"
35 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 36 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
36 #include "chrome/common/chrome_switches.h" 37 #include "chrome/common/chrome_switches.h"
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 EXPECT_FALSE(HasClientDownloadRequest()); 1737 EXPECT_FALSE(HasClientDownloadRequest());
1737 } 1738 }
1738 1739
1739 TEST_F(DownloadProtectionServiceTest, GetCertificateWhitelistStrings) { 1740 TEST_F(DownloadProtectionServiceTest, GetCertificateWhitelistStrings) {
1740 // We'll pass this cert in as the "issuer", even though it isn't really 1741 // We'll pass this cert in as the "issuer", even though it isn't really
1741 // used to sign the certs below. GetCertificateWhitelistStirngs doesn't care 1742 // used to sign the certs below. GetCertificateWhitelistStirngs doesn't care
1742 // about this. 1743 // about this.
1743 scoped_refptr<net::X509Certificate> issuer_cert( 1744 scoped_refptr<net::X509Certificate> issuer_cert(
1744 ReadTestCertificate("issuer.pem")); 1745 ReadTestCertificate("issuer.pem"));
1745 ASSERT_TRUE(issuer_cert.get()); 1746 ASSERT_TRUE(issuer_cert.get());
1746 std::string cert_base = "cert/" + base::HexEncode( 1747 std::string issuer_der;
1747 issuer_cert->fingerprint().data, 1748 net::X509Certificate::GetDEREncoded(issuer_cert->os_cert_handle(),
1748 sizeof(issuer_cert->fingerprint().data)); 1749 &issuer_der);
1750 std::string hashed = base::SHA1HashString(issuer_der);
1751 std::string cert_base =
1752 "cert/" + base::HexEncode(hashed.data(), hashed.size());
1749 1753
1750 scoped_refptr<net::X509Certificate> cert(ReadTestCertificate("test_cn.pem")); 1754 scoped_refptr<net::X509Certificate> cert(ReadTestCertificate("test_cn.pem"));
1751 ASSERT_TRUE(cert.get()); 1755 ASSERT_TRUE(cert.get());
1752 std::vector<std::string> whitelist_strings; 1756 std::vector<std::string> whitelist_strings;
1753 GetCertificateWhitelistStrings( 1757 GetCertificateWhitelistStrings(
1754 *cert.get(), *issuer_cert.get(), &whitelist_strings); 1758 *cert.get(), *issuer_cert.get(), &whitelist_strings);
1755 // This also tests escaping of characters in the certificate attributes. 1759 // This also tests escaping of characters in the certificate attributes.
1756 EXPECT_THAT(whitelist_strings, ElementsAre( 1760 EXPECT_THAT(whitelist_strings, ElementsAre(
1757 cert_base + "/CN=subject%2F%251")); 1761 cert_base + "/CN=subject%2F%251"));
1758 1762
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2150 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2147 base::Unretained(this))); 2151 base::Unretained(this)));
2148 MessageLoop::current()->Run(); 2152 MessageLoop::current()->Run();
2149 2153
2150 EXPECT_FALSE(HasClientDownloadRequest()); 2154 EXPECT_FALSE(HasClientDownloadRequest());
2151 // Overriden by flag: 2155 // Overriden by flag:
2152 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2156 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2153 } 2157 }
2154 2158
2155 } // namespace safe_browsing 2159 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698