Chromium Code Reviews| 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..d74a6a895172ce90a9b5ce0e0b411de53badb8bd |
| --- /dev/null |
| +++ b/chrome/browser/safe_browsing/incident_reporting/finch_config_signature_incident_handlers_unittest.cc |
| @@ -0,0 +1,65 @@ |
| +// 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+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + return incident.Pass(); |
| +} |
| + |
| +} // namespace |
| + |
| +// Tests that GetKey returns the dll path. |
|
grt (UTC plus 2)
2014/10/10 17:45:43
copy-n-paste? ;-)
Georges Khalil
2014/10/10 20:19:32
Oops! :)
Done.
|
| +TEST(GetFinchConfigSignatureIncidentKey, KeyIsPath) { |
|
grt (UTC plus 2)
2014/10/10 17:45:43
make this a KeyIsConstant test that verifies that
Georges Khalil
2014/10/10 20:19:32
Done.
|
| + safe_browsing::ClientIncidentReport_IncidentData incident; |
| + |
| + incident.mutable_finch_config_signature()->set_signature_hash( |
| + "MEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + 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+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + |
| + scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident2( |
| + MakeIncident()); |
| + incident2->mutable_finch_config_signature()->set_signature_hash( |
| + "AEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + |
| + ASSERT_NE(safe_browsing::GetFinchConfigSignatureIncidentDigest(*incident), |
| + safe_browsing::GetFinchConfigSignatureIncidentDigest(*incident2)); |
| +} |