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

Unified Diff: chrome/browser/safe_browsing/signature_util_win_unittest.cc

Issue 8459001: Extract the certificate to use in the download protection pingback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Address Noe and Matt's comments Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/signature_util_win.cc ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/signature_util_win_unittest.cc
===================================================================
--- chrome/browser/safe_browsing/signature_util_win_unittest.cc (revision 108613)
+++ chrome/browser/safe_browsing/signature_util_win_unittest.cc (working copy)
@@ -4,14 +4,19 @@
#include "chrome/browser/safe_browsing/signature_util.h"
+#include <string>
#include "base/base_paths.h"
#include "base/file_path.h"
#include "base/path_service.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
+#include "net/base/x509_cert_types.h"
+#include "net/base/x509_certificate.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
-TEST(SignatureUtilWinTest, IsSigned) {
+TEST(SignatureUtilWinTest, CheckSignature) {
FilePath source_path;
ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &source_path));
@@ -22,11 +27,27 @@
.AppendASCII("safe_browsing")
.AppendASCII("download_protection");
- EXPECT_TRUE(signature_util::IsSigned(testdata_path.Append(L"signed.exe")));
- EXPECT_FALSE(signature_util::IsSigned(
- testdata_path.Append(L"unsigned.exe")));
- EXPECT_FALSE(signature_util::IsSigned(
- testdata_path.Append(L"doesnotexist.exe")));
+ scoped_refptr<SignatureUtil> signature_util(new SignatureUtil());
+ ClientDownloadRequest_SignatureInfo signature_info;
+ signature_util->CheckSignature(testdata_path.Append(L"signed.exe"),
+ &signature_info);
+ EXPECT_FALSE(signature_info.certificate_contents().empty());
+ scoped_refptr<net::X509Certificate> cert(
+ net::X509Certificate::CreateFromBytes(
+ signature_info.certificate_contents().data(),
+ signature_info.certificate_contents().size()));
+ ASSERT_TRUE(cert.get());
+ EXPECT_EQ("Joe's-Software-Emporium", cert->subject().common_name);
+
+ signature_info.Clear();
+ signature_util->CheckSignature(testdata_path.Append(L"unsigned.exe"),
+ &signature_info);
+ EXPECT_FALSE(signature_info.has_certificate_contents());
+
+ signature_info.Clear();
+ signature_util->CheckSignature(testdata_path.Append(L"doesnotexist.exe"),
+ &signature_info);
+ EXPECT_FALSE(signature_info.has_certificate_contents());
}
} // namespace safe_browsing
« no previous file with comments | « chrome/browser/safe_browsing/signature_util_win.cc ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698