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

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

Issue 444123002: Adding a new delayed analysis that verify binaries signature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@grt
Patch Set: Last minute nit fix Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/binary_integrity_incident_handlers_unittest.cc
diff --git a/chrome/browser/safe_browsing/binary_integrity_incident_handlers_unittest.cc b/chrome/browser/safe_browsing/binary_integrity_incident_handlers_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..91b4559bd9d524d1e099a31f578890107ff15995
--- /dev/null
+++ b/chrome/browser/safe_browsing/binary_integrity_incident_handlers_unittest.cc
@@ -0,0 +1,68 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/safe_browsing/binary_integrity_incident_handlers.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace safe_browsing {
+
+namespace {
+
+scoped_ptr<ClientIncidentReport_IncidentData> MakeIncident() {
+ scoped_ptr<ClientIncidentReport_IncidentData> incident(
+ new ClientIncidentReport_IncidentData);
+
+ incident->mutable_binary_integrity()->set_file_basename("foo");
+
+ // Set the signature.
+ incident->mutable_binary_integrity()->mutable_signature()->set_trusted(true);
+ ClientDownloadRequest_CertificateChain* certificate_chain =
+ incident->mutable_binary_integrity()->mutable_signature()
+ ->add_certificate_chain();
+
+ // Fill the certificate chain with 2 elements.
+ const unsigned char certificates[][5] = {
+ {42, 255, 100, 53, 2},
+ {64, 33, 51, 91, 210},
+ };
+ for (size_t i = 0; i < arraysize(certificates); ++i) {
+ ClientDownloadRequest_CertificateChain_Element* element =
+ certificate_chain->add_element();
+ element->set_certificate(certificates[i], arraysize(certificates[i]));
+ }
+
+ return incident.Pass();
+}
+
+} // namespace
+
+TEST(BinaryIntegrityIncidentHandlersTest, GetKeyIsFile) {
+ ClientIncidentReport_IncidentData incident;
+
+ incident.mutable_binary_integrity()->set_file_basename("foo");
+ ASSERT_EQ(std::string("foo"), GetBinaryIntegrityIncidentKey(incident));
+}
+
+TEST(BinaryIntegrityIncidentHandlersTest, SameIncidentSameDigest) {
+ scoped_ptr<ClientIncidentReport_IncidentData> incident(MakeIncident());
+
+ uint32_t digest = GetBinaryIntegrityIncidentDigest(*incident);
+ ASSERT_EQ(digest, GetBinaryIntegrityIncidentDigest(*MakeIncident()));
+}
+
+TEST(BinaryIntegrityIncidentHandlersTest, DifferentIncidentDifferentDigest) {
+ scoped_ptr<ClientIncidentReport_IncidentData> incident(MakeIncident());
+
+ uint32_t digest = GetBinaryIntegrityIncidentDigest(*incident);
+
+ scoped_ptr<ClientIncidentReport_IncidentData> incident2(MakeIncident());
+ incident2->mutable_binary_integrity()->set_file_basename("bar");
+
+ ASSERT_NE(digest, GetBinaryIntegrityIncidentDigest(*incident2));
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698