| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This test creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
| 6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
| 7 // service. | 7 // service. |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // otherwise it returns false. | 127 // otherwise it returns false. |
| 128 bool ContainsBrowseUrl(const GURL& url, | 128 bool ContainsBrowseUrl(const GURL& url, |
| 129 std::vector<SBPrefix>* prefix_hits, | 129 std::vector<SBPrefix>* prefix_hits, |
| 130 std::vector<SBFullHashResult>* cache_hits) override { | 130 std::vector<SBFullHashResult>* cache_hits) override { |
| 131 cache_hits->clear(); | 131 cache_hits->clear(); |
| 132 return ContainsUrl(safe_browsing_util::MALWARE, | 132 return ContainsUrl(safe_browsing_util::MALWARE, |
| 133 safe_browsing_util::PHISH, | 133 safe_browsing_util::PHISH, |
| 134 std::vector<GURL>(1, url), | 134 std::vector<GURL>(1, url), |
| 135 prefix_hits); | 135 prefix_hits); |
| 136 } | 136 } |
| 137 bool ContainsUnwantedSoftwareUrl( |
| 138 const GURL& url, |
| 139 std::vector<SBPrefix>* prefix_hits, |
| 140 std::vector<SBFullHashResult>* cache_hits) override { |
| 141 cache_hits->clear(); |
| 142 return ContainsUrl(safe_browsing_util::UNWANTEDURL, |
| 143 safe_browsing_util::UNWANTEDURL, |
| 144 std::vector<GURL>(1, url), |
| 145 prefix_hits); |
| 146 } |
| 137 bool ContainsDownloadUrl(const std::vector<GURL>& urls, | 147 bool ContainsDownloadUrl(const std::vector<GURL>& urls, |
| 138 std::vector<SBPrefix>* prefix_hits) override { | 148 std::vector<SBPrefix>* prefix_hits) override { |
| 139 bool found = ContainsUrl(safe_browsing_util::BINURL, | 149 bool found = ContainsUrl(safe_browsing_util::BINURL, |
| 140 safe_browsing_util::BINURL, | 150 safe_browsing_util::BINURL, |
| 141 urls, | 151 urls, |
| 142 prefix_hits); | 152 prefix_hits); |
| 143 if (!found) | 153 if (!found) |
| 144 return false; | 154 return false; |
| 145 DCHECK_LE(1U, prefix_hits->size()); | 155 DCHECK_LE(1U, prefix_hits->size()); |
| 146 return true; | 156 return true; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const base::TimeDelta& cache_lifetime) override { | 189 const base::TimeDelta& cache_lifetime) override { |
| 180 // Do nothing for the cache. | 190 // Do nothing for the cache. |
| 181 } | 191 } |
| 182 bool IsMalwareIPMatchKillSwitchOn() override { return false; } | 192 bool IsMalwareIPMatchKillSwitchOn() override { return false; } |
| 183 bool IsCsdWhitelistKillSwitchOn() override { return false; } | 193 bool IsCsdWhitelistKillSwitchOn() override { return false; } |
| 184 | 194 |
| 185 // Fill up the database with test URL. | 195 // Fill up the database with test URL. |
| 186 void AddUrl(const GURL& url, | 196 void AddUrl(const GURL& url, |
| 187 int list_id, | 197 int list_id, |
| 188 const std::vector<SBPrefix>& prefix_hits) { | 198 const std::vector<SBPrefix>& prefix_hits) { |
| 189 badurls_[url.spec()].list_id = list_id; | 199 Hits* hits_for_url = &badurls_[url.spec()]; |
| 190 badurls_[url.spec()].prefix_hits = prefix_hits; | 200 hits_for_url->list_ids.push_back(list_id); |
| 201 hits_for_url->prefix_hits.insert(hits_for_url->prefix_hits.end(), |
| 202 prefix_hits.begin(), |
| 203 prefix_hits.end()); |
| 191 } | 204 } |
| 192 | 205 |
| 193 // Fill up the database with test hash digest. | 206 // Fill up the database with test hash digest. |
| 194 void AddDownloadPrefix(SBPrefix prefix) { | 207 void AddDownloadPrefix(SBPrefix prefix) { |
| 195 download_digest_prefix_.insert(prefix); | 208 download_digest_prefix_.insert(prefix); |
| 196 } | 209 } |
| 197 | 210 |
| 198 private: | 211 private: |
| 212 // Stores |list_ids| of safe browsing lists that match some |prefix_hits|. |
| 199 struct Hits { | 213 struct Hits { |
| 200 int list_id; | 214 std::vector<int> list_ids; |
| 201 std::vector<SBPrefix> prefix_hits; | 215 std::vector<SBPrefix> prefix_hits; |
| 202 }; | 216 }; |
| 203 | 217 |
| 204 bool ContainsUrl(int list_id0, | 218 bool ContainsUrl(int list_id0, |
| 205 int list_id1, | 219 int list_id1, |
| 206 const std::vector<GURL>& urls, | 220 const std::vector<GURL>& urls, |
| 207 std::vector<SBPrefix>* prefix_hits) { | 221 std::vector<SBPrefix>* prefix_hits) { |
| 208 bool hit = false; | 222 bool hit = false; |
| 209 for (size_t i = 0; i < urls.size(); ++i) { | 223 for (size_t i = 0; i < urls.size(); ++i) { |
| 210 const GURL& url = urls[i]; | 224 const GURL& url = urls[i]; |
| 211 base::hash_map<std::string, Hits>::const_iterator | 225 base::hash_map<std::string, Hits>::const_iterator |
| 212 badurls_it = badurls_.find(url.spec()); | 226 badurls_it = badurls_.find(url.spec()); |
| 213 | 227 |
| 214 if (badurls_it == badurls_.end()) | 228 if (badurls_it == badurls_.end()) |
| 215 continue; | 229 continue; |
| 216 | 230 |
| 217 if (badurls_it->second.list_id == list_id0 || | 231 std::vector<int> list_ids_for_url = badurls_it->second.list_ids; |
| 218 badurls_it->second.list_id == list_id1) { | 232 if (std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id0) |
| 233 != list_ids_for_url.end() || |
| 234 std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id1) |
| 235 != list_ids_for_url.end()) { |
| 219 prefix_hits->insert(prefix_hits->end(), | 236 prefix_hits->insert(prefix_hits->end(), |
| 220 badurls_it->second.prefix_hits.begin(), | 237 badurls_it->second.prefix_hits.begin(), |
| 221 badurls_it->second.prefix_hits.end()); | 238 badurls_it->second.prefix_hits.end()); |
| 222 hit = true; | 239 hit = true; |
| 223 } | 240 } |
| 224 } | 241 } |
| 225 return hit; | 242 return hit; |
| 226 } | 243 } |
| 227 | 244 |
| 228 base::hash_map<std::string, Hits> badurls_; | 245 base::hash_map<std::string, Hits> badurls_; |
| 229 base::hash_set<SBPrefix> download_digest_prefix_; | 246 base::hash_set<SBPrefix> download_digest_prefix_; |
| 230 }; | 247 }; |
| 231 | 248 |
| 232 // Factory that creates TestSafeBrowsingDatabase instances. | 249 // Factory that creates TestSafeBrowsingDatabase instances. |
| 233 class TestSafeBrowsingDatabaseFactory : public SafeBrowsingDatabaseFactory { | 250 class TestSafeBrowsingDatabaseFactory : public SafeBrowsingDatabaseFactory { |
| 234 public: | 251 public: |
| 235 TestSafeBrowsingDatabaseFactory() : db_(NULL) {} | 252 TestSafeBrowsingDatabaseFactory() : db_(NULL) {} |
| 236 ~TestSafeBrowsingDatabaseFactory() override {} | 253 ~TestSafeBrowsingDatabaseFactory() override {} |
| 237 | 254 |
| 238 SafeBrowsingDatabase* CreateSafeBrowsingDatabase( | 255 SafeBrowsingDatabase* CreateSafeBrowsingDatabase( |
| 239 bool enable_download_protection, | 256 bool enable_download_protection, |
| 240 bool enable_client_side_whitelist, | 257 bool enable_client_side_whitelist, |
| 241 bool enable_download_whitelist, | 258 bool enable_download_whitelist, |
| 242 bool enable_extension_blacklist, | 259 bool enable_extension_blacklist, |
| 243 bool enable_side_effect_free_whitelist, | 260 bool enable_side_effect_free_whitelist, |
| 244 bool enable_ip_blacklist) override { | 261 bool enable_ip_blacklist, |
| 262 bool enabled_unwanted_software_list) override { |
| 245 db_ = new TestSafeBrowsingDatabase(); | 263 db_ = new TestSafeBrowsingDatabase(); |
| 246 return db_; | 264 return db_; |
| 247 } | 265 } |
| 248 TestSafeBrowsingDatabase* GetDb() { | 266 TestSafeBrowsingDatabase* GetDb() { |
| 249 return db_; | 267 return db_; |
| 250 } | 268 } |
| 251 private: | 269 private: |
| 252 // Owned by the SafebrowsingService. | 270 // Owned by the SafebrowsingService. |
| 253 TestSafeBrowsingDatabase* db_; | 271 TestSafeBrowsingDatabase* db_; |
| 254 }; | 272 }; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 274 void GetFullHash(const std::vector<SBPrefix>& prefixes, | 292 void GetFullHash(const std::vector<SBPrefix>& prefixes, |
| 275 SafeBrowsingProtocolManager::FullHashCallback callback, | 293 SafeBrowsingProtocolManager::FullHashCallback callback, |
| 276 bool is_download) override { | 294 bool is_download) override { |
| 277 BrowserThread::PostDelayedTask( | 295 BrowserThread::PostDelayedTask( |
| 278 BrowserThread::IO, FROM_HERE, | 296 BrowserThread::IO, FROM_HERE, |
| 279 base::Bind(InvokeFullHashCallback, callback, full_hashes_), | 297 base::Bind(InvokeFullHashCallback, callback, full_hashes_), |
| 280 delay_); | 298 delay_); |
| 281 } | 299 } |
| 282 | 300 |
| 283 // Prepare the GetFullHash results for the next request. | 301 // Prepare the GetFullHash results for the next request. |
| 284 void SetGetFullHashResponse(const SBFullHashResult& full_hash_result) { | 302 void AddGetFullHashResponse(const SBFullHashResult& full_hash_result) { |
| 285 full_hashes_.clear(); | |
| 286 full_hashes_.push_back(full_hash_result); | 303 full_hashes_.push_back(full_hash_result); |
| 287 } | 304 } |
| 288 | 305 |
| 289 void IntroduceDelay(const base::TimeDelta& delay) { | 306 void IntroduceDelay(const base::TimeDelta& delay) { |
| 290 delay_ = delay; | 307 delay_ = delay; |
| 291 } | 308 } |
| 292 | 309 |
| 293 static int create_count() { | 310 static int create_count() { |
| 294 return create_count_; | 311 return create_count_; |
| 295 } | 312 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 command_line->AppendSwitch( | 413 command_line->AppendSwitch( |
| 397 chromeos::switches::kIgnoreUserProfileMappingForTests); | 414 chromeos::switches::kIgnoreUserProfileMappingForTests); |
| 398 #endif | 415 #endif |
| 399 } | 416 } |
| 400 | 417 |
| 401 virtual void SetUpInProcessBrowserTestFixture() { | 418 virtual void SetUpInProcessBrowserTestFixture() { |
| 402 ASSERT_TRUE(test_server()->Start()); | 419 ASSERT_TRUE(test_server()->Start()); |
| 403 } | 420 } |
| 404 | 421 |
| 405 // This will setup the "url" prefix in database and prepare protocol manager | 422 // This will setup the "url" prefix in database and prepare protocol manager |
| 406 // to response with |full_hash| for get full hash request. | 423 // to respond with |full_hash|, as well as other |full_hash|es previously set |
| 424 // via this call, on GetFullHash requests. |
| 407 void SetupResponseForUrl(const GURL& url, const SBFullHashResult& full_hash) { | 425 void SetupResponseForUrl(const GURL& url, const SBFullHashResult& full_hash) { |
| 408 std::vector<SBPrefix> prefix_hits; | 426 std::vector<SBPrefix> prefix_hits; |
| 409 prefix_hits.push_back(full_hash.hash.prefix); | 427 prefix_hits.push_back(full_hash.hash.prefix); |
| 410 | 428 |
| 411 // Make sure the full hits is empty unless we need to test the | 429 // Make sure the full hits is empty unless we need to test the |
| 412 // full hash is hit in database's local cache. | 430 // full hash is hit in database's local cache. |
| 413 TestSafeBrowsingDatabase* db = db_factory_.GetDb(); | 431 TestSafeBrowsingDatabase* db = db_factory_.GetDb(); |
| 414 db->AddUrl(url, full_hash.list_id, prefix_hits); | 432 db->AddUrl(url, full_hash.list_id, prefix_hits); |
| 415 | 433 |
| 416 TestProtocolManager* pm = pm_factory_.GetProtocolManager(); | 434 TestProtocolManager* pm = pm_factory_.GetProtocolManager(); |
| 417 pm->SetGetFullHashResponse(full_hash); | 435 pm->AddGetFullHashResponse(full_hash); |
| 418 } | 436 } |
| 419 | 437 |
| 420 bool ShowingInterstitialPage() { | 438 bool ShowingInterstitialPage() { |
| 421 WebContents* contents = | 439 WebContents* contents = |
| 422 browser()->tab_strip_model()->GetActiveWebContents(); | 440 browser()->tab_strip_model()->GetActiveWebContents(); |
| 423 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); | 441 InterstitialPage* interstitial_page = contents->GetInterstitialPage(); |
| 424 return interstitial_page != NULL; | 442 return interstitial_page != NULL; |
| 425 } | 443 } |
| 426 | 444 |
| 427 void IntroduceGetHashDelay(const base::TimeDelta& delay) { | 445 void IntroduceGetHashDelay(const base::TimeDelta& delay) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 } | 735 } |
| 718 | 736 |
| 719 void CheckDownloadUrl(const std::vector<GURL>& url_chain) { | 737 void CheckDownloadUrl(const std::vector<GURL>& url_chain) { |
| 720 BrowserThread::PostTask( | 738 BrowserThread::PostTask( |
| 721 BrowserThread::IO, FROM_HERE, | 739 BrowserThread::IO, FROM_HERE, |
| 722 base::Bind(&TestSBClient::CheckDownloadUrlOnIOThread, | 740 base::Bind(&TestSBClient::CheckDownloadUrlOnIOThread, |
| 723 this, url_chain)); | 741 this, url_chain)); |
| 724 content::RunMessageLoop(); // Will stop in OnCheckDownloadUrlResult. | 742 content::RunMessageLoop(); // Will stop in OnCheckDownloadUrlResult. |
| 725 } | 743 } |
| 726 | 744 |
| 745 void CheckBrowseUrl(const GURL& url) { |
| 746 BrowserThread::PostTask( |
| 747 BrowserThread::IO, FROM_HERE, |
| 748 base::Bind(&TestSBClient::CheckBrowseUrlOnIOThread, |
| 749 this, url)); |
| 750 content::RunMessageLoop(); // Will stop in OnCheckBrowseUrlResult. |
| 751 } |
| 752 |
| 727 private: | 753 private: |
| 728 friend class base::RefCountedThreadSafe<TestSBClient>; | 754 friend class base::RefCountedThreadSafe<TestSBClient>; |
| 729 ~TestSBClient() override {} | 755 ~TestSBClient() override {} |
| 730 | 756 |
| 731 void CheckDownloadUrlOnIOThread(const std::vector<GURL>& url_chain) { | 757 void CheckDownloadUrlOnIOThread(const std::vector<GURL>& url_chain) { |
| 732 safe_browsing_service_->database_manager()-> | 758 bool synchronous_safe_signal = safe_browsing_service_->database_manager()-> |
| 733 CheckDownloadUrl(url_chain, this); | 759 CheckDownloadUrl(url_chain, this); |
| 760 if (synchronous_safe_signal) { |
| 761 threat_type_ = SB_THREAT_TYPE_SAFE; |
| 762 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 763 base::Bind(&TestSBClient::CheckDone, this)); |
| 764 } |
| 765 } |
| 766 |
| 767 void CheckBrowseUrlOnIOThread(const GURL& url) { |
| 768 // The async CheckDone() hook will not be called when we have a synchronous |
| 769 // safe signal, handle it right away. |
| 770 bool synchronous_safe_signal = safe_browsing_service_->database_manager()-> |
| 771 CheckBrowseUrl(url, this); |
| 772 if (synchronous_safe_signal) { |
| 773 threat_type_ = SB_THREAT_TYPE_SAFE; |
| 774 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 775 base::Bind(&TestSBClient::CheckDone, this)); |
| 776 } |
| 734 } | 777 } |
| 735 | 778 |
| 736 // Called when the result of checking a download URL is known. | 779 // Called when the result of checking a download URL is known. |
| 737 void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, | 780 void OnCheckDownloadUrlResult(const std::vector<GURL>& /* url_chain */, |
| 738 SBThreatType threat_type) override { | 781 SBThreatType threat_type) override { |
| 739 threat_type_ = threat_type; | 782 threat_type_ = threat_type; |
| 740 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 783 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 741 base::Bind(&TestSBClient::DownloadCheckDone, this)); | 784 base::Bind(&TestSBClient::CheckDone, this)); |
| 742 } | 785 } |
| 743 | 786 |
| 744 void DownloadCheckDone() { | 787 // Called when the result of checking a browse URL is known. |
| 788 void OnCheckBrowseUrlResult(const GURL& /* url */, |
| 789 SBThreatType threat_type, |
| 790 const std::string& /* metadata */ ) override { |
| 791 threat_type_ = threat_type; |
| 792 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 793 base::Bind(&TestSBClient::CheckDone, this)); |
| 794 } |
| 795 |
| 796 void CheckDone() { |
| 745 base::MessageLoopForUI::current()->Quit(); | 797 base::MessageLoopForUI::current()->Quit(); |
| 746 } | 798 } |
| 747 | 799 |
| 748 SBThreatType threat_type_; | 800 SBThreatType threat_type_; |
| 749 SafeBrowsingService* safe_browsing_service_; | 801 SafeBrowsingService* safe_browsing_service_; |
| 750 | 802 |
| 751 DISALLOW_COPY_AND_ASSIGN(TestSBClient); | 803 DISALLOW_COPY_AND_ASSIGN(TestSBClient); |
| 752 }; | 804 }; |
| 753 | 805 |
| 754 // These tests use SafeBrowsingService::Client to directly interact with | 806 // These tests use SafeBrowsingService::Client to directly interact with |
| (...skipping 14 matching lines...) Expand all Loading... |
| 769 GenUrlFullhashResult(badbin_url, safe_browsing_util::BINURL, | 821 GenUrlFullhashResult(badbin_url, safe_browsing_util::BINURL, |
| 770 &full_hash_result); | 822 &full_hash_result); |
| 771 SetupResponseForUrl(badbin_url, full_hash_result); | 823 SetupResponseForUrl(badbin_url, full_hash_result); |
| 772 | 824 |
| 773 client->CheckDownloadUrl(badbin_urls); | 825 client->CheckDownloadUrl(badbin_urls); |
| 774 | 826 |
| 775 // Now, the badbin_url is not safe since it is added to download database. | 827 // Now, the badbin_url is not safe since it is added to download database. |
| 776 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); | 828 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); |
| 777 } | 829 } |
| 778 | 830 |
| 831 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckUnwantedSoftwareUrl) { |
| 832 const GURL bad_url = test_server()->GetURL(kMalwareFile); |
| 833 { |
| 834 scoped_refptr<TestSBClient> client(new TestSBClient); |
| 835 |
| 836 // Since bad_url is not in database, it is considered to be |
| 837 // safe. |
| 838 client->CheckBrowseUrl(bad_url); |
| 839 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); |
| 840 |
| 841 SBFullHashResult full_hash_result; |
| 842 GenUrlFullhashResult(bad_url, safe_browsing_util::UNWANTEDURL, |
| 843 &full_hash_result); |
| 844 SetupResponseForUrl(bad_url, full_hash_result); |
| 845 |
| 846 // Now, the bad_url is not safe since it is added to download |
| 847 // database. |
| 848 client->CheckBrowseUrl(bad_url); |
| 849 EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, client->GetThreatType()); |
| 850 } |
| 851 |
| 852 // The unwantedness should survive across multiple clients. |
| 853 { |
| 854 scoped_refptr<TestSBClient> client(new TestSBClient); |
| 855 client->CheckBrowseUrl(bad_url); |
| 856 EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, client->GetThreatType()); |
| 857 } |
| 858 |
| 859 // An unwanted URL also marked as malware should be flagged as malware. |
| 860 { |
| 861 scoped_refptr<TestSBClient> client(new TestSBClient); |
| 862 |
| 863 SBFullHashResult full_hash_result; |
| 864 GenUrlFullhashResult(bad_url, safe_browsing_util::MALWARE, |
| 865 &full_hash_result); |
| 866 SetupResponseForUrl(bad_url, full_hash_result); |
| 867 |
| 868 client->CheckBrowseUrl(bad_url); |
| 869 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); |
| 870 } |
| 871 } |
| 872 |
| 873 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckBrowseUrl) { |
| 874 const GURL bad_url = test_server()->GetURL(kMalwareFile); |
| 875 { |
| 876 scoped_refptr<TestSBClient> client(new TestSBClient); |
| 877 |
| 878 // Since bad_url is not in database, it is considered to be |
| 879 // safe. |
| 880 client->CheckBrowseUrl(bad_url); |
| 881 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); |
| 882 |
| 883 SBFullHashResult full_hash_result; |
| 884 GenUrlFullhashResult(bad_url, safe_browsing_util::MALWARE, |
| 885 &full_hash_result); |
| 886 SetupResponseForUrl(bad_url, full_hash_result); |
| 887 |
| 888 // Now, the bad_url is not safe since it is added to download |
| 889 // database. |
| 890 client->CheckBrowseUrl(bad_url); |
| 891 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); |
| 892 } |
| 893 |
| 894 // The unwantedness should survive across multiple clients. |
| 895 { |
| 896 scoped_refptr<TestSBClient> client(new TestSBClient); |
| 897 client->CheckBrowseUrl(bad_url); |
| 898 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); |
| 899 } |
| 900 |
| 901 // Adding the unwanted state to an existing malware URL should have no impact |
| 902 // (i.e. a malware hit should still prevail). |
| 903 { |
| 904 scoped_refptr<TestSBClient> client(new TestSBClient); |
| 905 |
| 906 SBFullHashResult full_hash_result; |
| 907 GenUrlFullhashResult(bad_url, safe_browsing_util::UNWANTEDURL, |
| 908 &full_hash_result); |
| 909 SetupResponseForUrl(bad_url, full_hash_result); |
| 910 |
| 911 client->CheckBrowseUrl(bad_url); |
| 912 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); |
| 913 } |
| 914 } |
| 915 |
| 779 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckDownloadUrlRedirects) { | 916 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckDownloadUrlRedirects) { |
| 780 GURL original_url = test_server()->GetURL(kEmptyPage); | 917 GURL original_url = test_server()->GetURL(kEmptyPage); |
| 781 GURL badbin_url = test_server()->GetURL(kMalwareFile); | 918 GURL badbin_url = test_server()->GetURL(kMalwareFile); |
| 782 GURL final_url = test_server()->GetURL(kEmptyPage); | 919 GURL final_url = test_server()->GetURL(kEmptyPage); |
| 783 std::vector<GURL> badbin_urls; | 920 std::vector<GURL> badbin_urls; |
| 784 badbin_urls.push_back(original_url); | 921 badbin_urls.push_back(original_url); |
| 785 badbin_urls.push_back(badbin_url); | 922 badbin_urls.push_back(badbin_url); |
| 786 badbin_urls.push_back(final_url); | 923 badbin_urls.push_back(final_url); |
| 787 | 924 |
| 788 scoped_refptr<TestSBClient> client(new TestSBClient); | 925 scoped_refptr<TestSBClient> client(new TestSBClient); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 content::WindowedNotificationObserver observer( | 1226 content::WindowedNotificationObserver observer( |
| 1090 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1227 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
| 1091 content::Source<SafeBrowsingDatabaseManager>( | 1228 content::Source<SafeBrowsingDatabaseManager>( |
| 1092 sb_service_->database_manager().get())); | 1229 sb_service_->database_manager().get())); |
| 1093 BrowserThread::PostTask( | 1230 BrowserThread::PostTask( |
| 1094 BrowserThread::IO, | 1231 BrowserThread::IO, |
| 1095 FROM_HERE, | 1232 FROM_HERE, |
| 1096 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1233 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
| 1097 observer.Wait(); | 1234 observer.Wait(); |
| 1098 } | 1235 } |
| OLD | NEW |