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

Unified Diff: chrome/browser/safe_browsing/incident_reporting/finch_config_signature_incident_handlers_unittest.cc

Issue 646733002: Added incident report for variations seed signature mismatch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Output of git cl format. Created 6 years, 2 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/incident_reporting/finch_config_signature_incident_handlers_unittest.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/finch_config_signature_incident_handlers_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/finch_config_signature_incident_handlers_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d6ea51261eed190fd686977f84dafe8c36c9f2e2
--- /dev/null
+++ b/chrome/browser/safe_browsing/incident_reporting/finch_config_signature_incident_handlers_unittest.cc
@@ -0,0 +1,69 @@
+// 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/incident_reporting/finch_config_signature_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 {
+
+scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> MakeIncident() {
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident(
+ new safe_browsing::ClientIncidentReport_IncidentData);
+ incident->mutable_finch_config_signature()->set_signature_hash(
+ "MEUCID+QmAfaj"
+ "h/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL7tXVLhURxUQcpi"
+ "Mg9eMLWO0U=");
+ return incident.Pass();
+}
+
+} // namespace
+
+// Tests that GetKey returns the dll path.
+TEST(GetFinchConfigSignatureIncidentKey, KeyIsPath) {
+ safe_browsing::ClientIncidentReport_IncidentData incident;
+
+ incident.mutable_finch_config_signature()->set_signature_hash(
+ "MEUCID+QmAfajh"
+ "/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL7tXVLhURxUQcpiM"
+ "g9eMLWO0U=");
+ ASSERT_EQ(std::string(
+ "MEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtV"
+ "UHhFA/4M6Bff2GazL7tXVLhURxUQcpiMg9eMLWO0U="),
+ safe_browsing::GetFinchConfigSignatureIncidentKey(incident));
+}
+
+// Tests that GetDigest returns the same value for the same incident.
+TEST(GetFinchConfigSignatureIncidentDigest, SameIncidentSameDigest) {
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident(
+ MakeIncident());
+
+ uint32_t digest =
+ safe_browsing::GetFinchConfigSignatureIncidentDigest(*incident);
+ ASSERT_EQ(
+ digest,
+ safe_browsing::GetFinchConfigSignatureIncidentDigest(*MakeIncident()));
+}
+
+// Tests that GetDigest returns different values for different incidents.
+TEST(GetFinchConfigSignatureIncidentDigest, DifferentIncidentDifferentDigest) {
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident(
+ MakeIncident());
+ incident->mutable_finch_config_signature()->set_signature_hash(
+ "MEUCID+QmAfaj"
+ "h/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL7tXVLhURxUQcpi"
+ "Mg9eMLWO0U=");
+
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident2(
+ MakeIncident());
+ incident2->mutable_finch_config_signature()->set_signature_hash(
+ "AEUCID+QmAfa"
+ "jh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL7tXVLhURxUQcp"
+ "iMg9eMLWO0U=");
+
+ ASSERT_NE(safe_browsing::GetFinchConfigSignatureIncidentDigest(*incident),
+ safe_browsing::GetFinchConfigSignatureIncidentDigest(*incident2));
+}

Powered by Google App Engine
This is Rietveld 408576698