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

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

Issue 18524: Merge r7710... (Closed) Base URL: svn://chrome-svn/chrome/branches/release_154.next/src/
Patch Set: Created 11 years, 11 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/protocol_parser_unittest.cc
===================================================================
--- chrome/browser/safe_browsing/protocol_parser_unittest.cc (revision 8470)
+++ chrome/browser/safe_browsing/protocol_parser_unittest.cc (working copy)
@@ -491,6 +491,47 @@
EXPECT_EQ(memcmp(hash_result, &full_hashes[0].hash, sizeof(SBFullHash)), 0);
}
+TEST(SafeBrowsingProtocolParsingTest, TestGetHashWithUnknownList) {
+ std::string hash_response = "goog-phish-shavar:1:32\n"
+ "12345678901234567890123456789012"
+ "googpub-phish-shavar:19:32\n"
+ "09876543210987654321098765432109";
+ bool re_key = false;
+ std::string key = "";
+ std::vector<SBFullHashResult> full_hashes;
+ SafeBrowsingProtocolParser parser;
+ EXPECT_TRUE(parser.ParseGetHash(hash_response.data(),
+ hash_response.size(),
+ key,
+ &re_key,
+ &full_hashes));
+
+ EXPECT_EQ(full_hashes.size(), 1);
+ EXPECT_EQ(memcmp("12345678901234567890123456789012",
+ &full_hashes[0].hash, sizeof(SBFullHash)), 0);
+ EXPECT_EQ(full_hashes[0].list_name, "goog-phish-shavar");
+ EXPECT_EQ(full_hashes[0].add_chunk_id, 1);
+
+ hash_response += "goog-malware-shavar:7:32\n"
+ "abcdefghijklmnopqrstuvwxyz123457";
+ full_hashes.clear();
+ EXPECT_TRUE(parser.ParseGetHash(hash_response.data(),
+ hash_response.size(),
+ key,
+ &re_key,
+ &full_hashes));
+
+ EXPECT_EQ(full_hashes.size(), 2);
+ EXPECT_EQ(memcmp("12345678901234567890123456789012",
+ &full_hashes[0].hash, sizeof(SBFullHash)), 0);
+ EXPECT_EQ(full_hashes[0].list_name, "goog-phish-shavar");
+ EXPECT_EQ(full_hashes[0].add_chunk_id, 1);
+ EXPECT_EQ(memcmp("abcdefghijklmnopqrstuvwxyz123457",
+ &full_hashes[1].hash, sizeof(SBFullHash)), 0);
+ EXPECT_EQ(full_hashes[1].list_name, "goog-malware-shavar");
+ EXPECT_EQ(full_hashes[1].add_chunk_id, 7);
+}
+
TEST(SafeBrowsingProtocolParsingTest, TestFormatHash) {
SafeBrowsingProtocolParser parser;
std::vector<SBPrefix> prefixes;
« no previous file with comments | « chrome/browser/safe_browsing/protocol_parser.cc ('k') | chrome/browser/safe_browsing/safe_browsing_database_bloom.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698