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

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

Issue 1673733002: Support new Safe Browsing list "goog-badresource-shavar" in SafeBrowsingDatabase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/local_database_manager_unittest.cc
diff --git a/chrome/browser/safe_browsing/local_database_manager_unittest.cc b/chrome/browser/safe_browsing/local_database_manager_unittest.cc
index 5ea449d2140c04639caeaa9787fcca294b5d2aae..c41bb9452b05d3f837346961cc268d3b49f06c40 100644
--- a/chrome/browser/safe_browsing/local_database_manager_unittest.cc
+++ b/chrome/browser/safe_browsing/local_database_manager_unittest.cc
@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "chrome/browser/safe_browsing/local_database_manager.h"
+
rkaplow 2016/02/05 21:21:29 unneeded?
veranika 2016/02/17 15:37:53 Done.
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
@@ -149,6 +150,9 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
const GURL kUnwantedUrl("http://www.unwanted.com/page.html");
const GURL kUnwantedAndMalwareUrl(
"http://www.unwantedandmalware.com/page.html");
+ const GURL kBlacklistedResourceUrl("http://www.blacklisted.com/script.js");
+ const GURL kUnwantedResourceUrl("http://www.unwantedresource.com/script.js");
+ const GURL kMalwareResourceUrl("http://www.malwareresource.com/script.js");
const GURL kSafeUrl("http://www.safe.com/page.html");
const SBFullHash kMalwareHostHash = SBFullHashForString("malware.com/");
@@ -156,6 +160,12 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
const SBFullHash kUnwantedHostHash = SBFullHashForString("unwanted.com/");
const SBFullHash kUnwantedAndMalwareHostHash =
SBFullHashForString("unwantedandmalware.com/");
+ const SBFullHash kBlacklistedResourceHostHash =
+ SBFullHashForString("blacklisted.com/");
+ const SBFullHash kUnwantedResourceHostHash =
+ SBFullHashForString("unwantedresource.com/");
+ const SBFullHash kMalwareResourceHostHash =
+ SBFullHashForString("malwareresource.com/");
const SBFullHash kSafeHostHash = SBFullHashForString("www.safe.com/");
{
@@ -180,6 +190,13 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
}
{
+ SBFullHashResult full_hash;
+ full_hash.hash = kBlacklistedResourceHostHash;
+ full_hash.list_id = static_cast<int>(RESOURCEBLACKLIST);
+ full_hashes.push_back(full_hash);
+ }
+
+ {
// Add both MALWARE and UNWANTEDURL list IDs for
// kUnwantedAndMalwareHostHash.
SBFullHashResult full_hash_malware;
@@ -193,6 +210,26 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
full_hashes.push_back(full_hash_unwanted);
}
+ {
+ SBFullHashResult full_hash_unwanted =
+ {kUnwantedResourceHostHash, static_cast<int>(UNWANTEDURL)};
+ full_hashes.push_back(full_hash_unwanted);
+
+ SBFullHashResult full_hash_resource =
+ {kUnwantedResourceHostHash, static_cast<int>(RESOURCEBLACKLIST)};
+ full_hashes.push_back(full_hash_resource);
+ }
+
+ {
+ SBFullHashResult full_hash_malware =
+ {kMalwareResourceHostHash, static_cast<int>(MALWARE)};
+ full_hashes.push_back(full_hash_malware);
+
+ SBFullHashResult full_hash_resource =
+ {kMalwareResourceHostHash, static_cast<int>(RESOURCEBLACKLIST)};
+ full_hashes.push_back(full_hash_resource);
+ }
+
EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
kMalwareHostHash, full_hashes));
@@ -209,6 +246,18 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
kUnwantedAndMalwareHostHash, full_hashes));
+ EXPECT_EQ(SB_THREAT_TYPE_BLACKLISTED_RESOURCE,
+ LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
+ kBlacklistedResourceHostHash, full_hashes));
+
+ EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED,
+ LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
+ kUnwantedResourceHostHash, full_hashes));
+
+ EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
+ LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
+ kMalwareResourceHostHash, full_hashes));
+
EXPECT_EQ(SB_THREAT_TYPE_SAFE,
LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType(
kSafeHostHash, full_hashes));
@@ -230,10 +279,25 @@ TEST_F(SafeBrowsingDatabaseManagerTest, GetUrlSeverestThreatType) {
kUnwantedUrl, full_hashes, &index));
EXPECT_EQ(2U, index);
+ EXPECT_EQ(SB_THREAT_TYPE_BLACKLISTED_RESOURCE,
+ LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
+ kBlacklistedResourceUrl, full_hashes, &index));
+ EXPECT_EQ(3U, index);
+
EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
kUnwantedAndMalwareUrl, full_hashes, &index));
- EXPECT_EQ(3U, index);
+ EXPECT_EQ(4U, index);
+
+ EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED,
+ LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
+ kUnwantedResourceUrl, full_hashes, &index));
+ EXPECT_EQ(6U, index);
+
+ EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE,
+ LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType(
+ kMalwareResourceUrl, full_hashes, &index));
+ EXPECT_EQ(8U, index);
index = kArbitraryValue;
EXPECT_EQ(SB_THREAT_TYPE_SAFE,
« no previous file with comments | « chrome/browser/safe_browsing/local_database_manager.cc ('k') | chrome/browser/safe_browsing/safe_browsing_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698