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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc

Issue 1410343012: Revert of Move more declarations from c/b/sb/sb_util.h to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_components
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return true; 131 return true;
132 } 132 }
133 133
134 // Called on the IO thread to check if the given URL is safe or not. If we 134 // Called on the IO thread to check if the given URL is safe or not. If we
135 // can synchronously determine that the URL is safe, CheckUrl returns true, 135 // can synchronously determine that the URL is safe, CheckUrl returns true,
136 // otherwise it returns false. 136 // otherwise it returns false.
137 bool ContainsBrowseUrl(const GURL& url, 137 bool ContainsBrowseUrl(const GURL& url,
138 std::vector<SBPrefix>* prefix_hits, 138 std::vector<SBPrefix>* prefix_hits,
139 std::vector<SBFullHashResult>* cache_hits) override { 139 std::vector<SBFullHashResult>* cache_hits) override {
140 cache_hits->clear(); 140 cache_hits->clear();
141 return ContainsUrl(safe_browsing::MALWARE, 141 return ContainsUrl(safe_browsing_util::MALWARE,
142 safe_browsing::PHISH, 142 safe_browsing_util::PHISH,
143 std::vector<GURL>(1, url), 143 std::vector<GURL>(1, url),
144 prefix_hits); 144 prefix_hits);
145 } 145 }
146 bool ContainsUnwantedSoftwareUrl( 146 bool ContainsUnwantedSoftwareUrl(
147 const GURL& url, 147 const GURL& url,
148 std::vector<SBPrefix>* prefix_hits, 148 std::vector<SBPrefix>* prefix_hits,
149 std::vector<SBFullHashResult>* cache_hits) override { 149 std::vector<SBFullHashResult>* cache_hits) override {
150 cache_hits->clear(); 150 cache_hits->clear();
151 return ContainsUrl(safe_browsing::UNWANTEDURL, 151 return ContainsUrl(safe_browsing_util::UNWANTEDURL,
152 safe_browsing::UNWANTEDURL, 152 safe_browsing_util::UNWANTEDURL,
153 std::vector<GURL>(1, url), 153 std::vector<GURL>(1, url),
154 prefix_hits); 154 prefix_hits);
155 } 155 }
156 bool ContainsDownloadUrlPrefixes( 156 bool ContainsDownloadUrlPrefixes(
157 const std::vector<SBPrefix>& prefixes, 157 const std::vector<SBPrefix>& prefixes,
158 std::vector<SBPrefix>* prefix_hits) override { 158 std::vector<SBPrefix>* prefix_hits) override {
159 bool found = 159 bool found =
160 ContainsUrlPrefixes(safe_browsing::BINURL, 160 ContainsUrlPrefixes(safe_browsing_util::BINURL,
161 safe_browsing::BINURL, prefixes, prefix_hits); 161 safe_browsing_util::BINURL, prefixes, prefix_hits);
162 if (!found) 162 if (!found)
163 return false; 163 return false;
164 DCHECK_LE(1U, prefix_hits->size()); 164 DCHECK_LE(1U, prefix_hits->size());
165 return true; 165 return true;
166 } 166 }
167 bool ContainsCsdWhitelistedUrl(const GURL& url) override { return true; } 167 bool ContainsCsdWhitelistedUrl(const GURL& url) override { return true; }
168 bool ContainsDownloadWhitelistedString(const std::string& str) override { 168 bool ContainsDownloadWhitelistedString(const std::string& str) override {
169 return true; 169 return true;
170 } 170 }
171 bool ContainsDownloadWhitelistedUrl(const GURL& url) override { return true; } 171 bool ContainsDownloadWhitelistedUrl(const GURL& url) override { return true; }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 class SafeBrowsingServiceTest : public InProcessBrowserTest { 417 class SafeBrowsingServiceTest : public InProcessBrowserTest {
418 public: 418 public:
419 SafeBrowsingServiceTest() { 419 SafeBrowsingServiceTest() {
420 } 420 }
421 421
422 static void GenUrlFullhashResult(const GURL& url, 422 static void GenUrlFullhashResult(const GURL& url,
423 int list_id, 423 int list_id,
424 SBFullHashResult* full_hash) { 424 SBFullHashResult* full_hash) {
425 std::string host; 425 std::string host;
426 std::string path; 426 std::string path;
427 safe_browsing::CanonicalizeUrl(url, &host, &path, NULL); 427 safe_browsing_util::CanonicalizeUrl(url, &host, &path, NULL);
428 full_hash->hash = safe_browsing::SBFullHashForString(host + path); 428 full_hash->hash = SBFullHashForString(host + path);
429 full_hash->list_id = list_id; 429 full_hash->list_id = list_id;
430 } 430 }
431 431
432 void SetUp() override { 432 void SetUp() override {
433 // InProcessBrowserTest::SetUp() instantiates SafebrowsingService and 433 // InProcessBrowserTest::SetUp() instantiates SafebrowsingService and
434 // RegisterFactory has to be called before SafeBrowsingService is created. 434 // RegisterFactory has to be called before SafeBrowsingService is created.
435 sb_factory_.reset(new TestSafeBrowsingServiceFactory( 435 sb_factory_.reset(new TestSafeBrowsingServiceFactory(
436 "https://definatelynotarealdomain/safebrowsing")); 436 "https://definatelynotarealdomain/safebrowsing"));
437 SafeBrowsingService::RegisterFactory(sb_factory_.get()); 437 SafeBrowsingService::RegisterFactory(sb_factory_.get());
438 SafeBrowsingDatabase::RegisterFactory(&db_factory_); 438 SafeBrowsingDatabase::RegisterFactory(&db_factory_);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 }; 594 };
595 595
596 class SafeBrowsingServiceMetadataTest 596 class SafeBrowsingServiceMetadataTest
597 : public SafeBrowsingServiceTest, 597 : public SafeBrowsingServiceTest,
598 public ::testing::WithParamInterface<MalwareMetadataTestType> { 598 public ::testing::WithParamInterface<MalwareMetadataTestType> {
599 public: 599 public:
600 SafeBrowsingServiceMetadataTest() {} 600 SafeBrowsingServiceMetadataTest() {}
601 601
602 void GenUrlFullhashResultWithMetadata(const GURL& url, 602 void GenUrlFullhashResultWithMetadata(const GURL& url,
603 SBFullHashResult* full_hash) { 603 SBFullHashResult* full_hash) {
604 GenUrlFullhashResult(url, safe_browsing::MALWARE, full_hash); 604 GenUrlFullhashResult(url, safe_browsing_util::MALWARE, full_hash);
605 605
606 safe_browsing::MalwarePatternType proto; 606 safe_browsing::MalwarePatternType proto;
607 switch (GetParam()) { 607 switch (GetParam()) {
608 case METADATA_NONE: 608 case METADATA_NONE:
609 full_hash->metadata = std::string(); 609 full_hash->metadata = std::string();
610 break; 610 break;
611 case METADATA_LANDING: 611 case METADATA_LANDING:
612 proto.set_pattern_type(safe_browsing::MalwarePatternType::LANDING); 612 proto.set_pattern_type(safe_browsing::MalwarePatternType::LANDING);
613 full_hash->metadata = proto.SerializeAsString(); 613 full_hash->metadata = proto.SerializeAsString();
614 break; 614 break;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 METADATA_LANDING, 705 METADATA_LANDING,
706 METADATA_DISTRIBUTION)); 706 METADATA_DISTRIBUTION));
707 707
708 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, UnwantedImgIgnored) { 708 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, UnwantedImgIgnored) {
709 GURL main_url = embedded_test_server()->GetURL(kMalwarePage); 709 GURL main_url = embedded_test_server()->GetURL(kMalwarePage);
710 GURL img_url = embedded_test_server()->GetURL(kMalwareImg); 710 GURL img_url = embedded_test_server()->GetURL(kMalwareImg);
711 711
712 // Add the img url as coming from a site serving UwS and then load the parent 712 // Add the img url as coming from a site serving UwS and then load the parent
713 // page. 713 // page.
714 SBFullHashResult uws_full_hash; 714 SBFullHashResult uws_full_hash;
715 GenUrlFullhashResult(img_url, safe_browsing::UNWANTEDURL, 715 GenUrlFullhashResult(img_url, safe_browsing_util::UNWANTEDURL,
716 &uws_full_hash); 716 &uws_full_hash);
717 SetupResponseForUrl(img_url, uws_full_hash); 717 SetupResponseForUrl(img_url, uws_full_hash);
718 718
719 ui_test_utils::NavigateToURL(browser(), main_url); 719 ui_test_utils::NavigateToURL(browser(), main_url);
720 720
721 EXPECT_FALSE(ShowingInterstitialPage()); 721 EXPECT_FALSE(ShowingInterstitialPage());
722 } 722 }
723 723
724 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, DISABLED_MalwareWithWhitelist) { 724 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, DISABLED_MalwareWithWhitelist) {
725 GURL url = embedded_test_server()->GetURL(kEmptyPage); 725 GURL url = embedded_test_server()->GetURL(kEmptyPage);
726 726
727 // After adding the url to safebrowsing database and getfullhash result, 727 // After adding the url to safebrowsing database and getfullhash result,
728 // we should see the interstitial page. 728 // we should see the interstitial page.
729 SBFullHashResult malware_full_hash; 729 SBFullHashResult malware_full_hash;
730 GenUrlFullhashResult(url, safe_browsing::MALWARE, &malware_full_hash); 730 GenUrlFullhashResult(url, safe_browsing_util::MALWARE, &malware_full_hash);
731 EXPECT_CALL(observer_, 731 EXPECT_CALL(observer_,
732 OnSafeBrowsingMatch(IsUnsafeResourceFor(url))).Times(1); 732 OnSafeBrowsingMatch(IsUnsafeResourceFor(url))).Times(1);
733 EXPECT_CALL(observer_, OnSafeBrowsingHit(IsUnsafeResourceFor(url))).Times(1) 733 EXPECT_CALL(observer_, OnSafeBrowsingHit(IsUnsafeResourceFor(url))).Times(1)
734 .WillOnce(testing::Invoke( 734 .WillOnce(testing::Invoke(
735 this, &SafeBrowsingServiceTest::ProceedAndWhitelist)); 735 this, &SafeBrowsingServiceTest::ProceedAndWhitelist));
736 SetupResponseForUrl(url, malware_full_hash); 736 SetupResponseForUrl(url, malware_full_hash);
737 737
738 ui_test_utils::NavigateToURL(browser(), url); 738 ui_test_utils::NavigateToURL(browser(), url);
739 // Mock calls OnBlockingPageDone set to proceed, so the interstitial 739 // Mock calls OnBlockingPageDone set to proceed, so the interstitial
740 // is removed. 740 // is removed.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 } 774 }
775 775
776 private: 776 private:
777 prerender::PrerenderManager::PrerenderManagerMode old_prerender_mode_; 777 prerender::PrerenderManager::PrerenderManagerMode old_prerender_mode_;
778 } set_prefetch_for_test(true); 778 } set_prefetch_for_test(true);
779 779
780 // Even though we have added this uri to the safebrowsing database and 780 // Even though we have added this uri to the safebrowsing database and
781 // getfullhash result, we should not see the interstitial page since the 781 // getfullhash result, we should not see the interstitial page since the
782 // only malware was a prefetch target. 782 // only malware was a prefetch target.
783 SBFullHashResult malware_full_hash; 783 SBFullHashResult malware_full_hash;
784 GenUrlFullhashResult(malware_url, safe_browsing::MALWARE, 784 GenUrlFullhashResult(malware_url, safe_browsing_util::MALWARE,
785 &malware_full_hash); 785 &malware_full_hash);
786 SetupResponseForUrl(malware_url, malware_full_hash); 786 SetupResponseForUrl(malware_url, malware_full_hash);
787 ui_test_utils::NavigateToURL(browser(), url); 787 ui_test_utils::NavigateToURL(browser(), url);
788 EXPECT_FALSE(ShowingInterstitialPage()); 788 EXPECT_FALSE(ShowingInterstitialPage());
789 Mock::VerifyAndClear(&observer_); 789 Mock::VerifyAndClear(&observer_);
790 790
791 // However, when we navigate to the malware page, we should still get 791 // However, when we navigate to the malware page, we should still get
792 // the interstitial. 792 // the interstitial.
793 EXPECT_CALL(observer_, OnSafeBrowsingMatch(IsUnsafeResourceFor(malware_url))) 793 EXPECT_CALL(observer_, OnSafeBrowsingMatch(IsUnsafeResourceFor(malware_url)))
794 .Times(1); 794 .Times(1);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile); 889 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile);
890 std::vector<GURL> badbin_urls(1, badbin_url); 890 std::vector<GURL> badbin_urls(1, badbin_url);
891 891
892 scoped_refptr<TestSBClient> client(new TestSBClient); 892 scoped_refptr<TestSBClient> client(new TestSBClient);
893 client->CheckDownloadUrl(badbin_urls); 893 client->CheckDownloadUrl(badbin_urls);
894 894
895 // Since badbin_url is not in database, it is considered to be safe. 895 // Since badbin_url is not in database, it is considered to be safe.
896 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); 896 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType());
897 897
898 SBFullHashResult full_hash_result; 898 SBFullHashResult full_hash_result;
899 GenUrlFullhashResult(badbin_url, safe_browsing::BINURL, 899 GenUrlFullhashResult(badbin_url, safe_browsing_util::BINURL,
900 &full_hash_result); 900 &full_hash_result);
901 SetupResponseForUrl(badbin_url, full_hash_result); 901 SetupResponseForUrl(badbin_url, full_hash_result);
902 902
903 client->CheckDownloadUrl(badbin_urls); 903 client->CheckDownloadUrl(badbin_urls);
904 904
905 // Now, the badbin_url is not safe since it is added to download database. 905 // Now, the badbin_url is not safe since it is added to download database.
906 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); 906 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType());
907 } 907 }
908 908
909 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckUnwantedSoftwareUrl) { 909 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckUnwantedSoftwareUrl) {
910 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile); 910 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile);
911 { 911 {
912 scoped_refptr<TestSBClient> client(new TestSBClient); 912 scoped_refptr<TestSBClient> client(new TestSBClient);
913 913
914 // Since bad_url is not in database, it is considered to be 914 // Since bad_url is not in database, it is considered to be
915 // safe. 915 // safe.
916 client->CheckBrowseUrl(bad_url); 916 client->CheckBrowseUrl(bad_url);
917 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); 917 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType());
918 918
919 SBFullHashResult full_hash_result; 919 SBFullHashResult full_hash_result;
920 GenUrlFullhashResult( 920 GenUrlFullhashResult(
921 bad_url, safe_browsing::UNWANTEDURL, &full_hash_result); 921 bad_url, safe_browsing_util::UNWANTEDURL, &full_hash_result);
922 SetupResponseForUrl(bad_url, full_hash_result); 922 SetupResponseForUrl(bad_url, full_hash_result);
923 923
924 // Now, the bad_url is not safe since it is added to download 924 // Now, the bad_url is not safe since it is added to download
925 // database. 925 // database.
926 client->CheckBrowseUrl(bad_url); 926 client->CheckBrowseUrl(bad_url);
927 EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, client->GetThreatType()); 927 EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, client->GetThreatType());
928 } 928 }
929 929
930 // The unwantedness should survive across multiple clients. 930 // The unwantedness should survive across multiple clients.
931 { 931 {
932 scoped_refptr<TestSBClient> client(new TestSBClient); 932 scoped_refptr<TestSBClient> client(new TestSBClient);
933 client->CheckBrowseUrl(bad_url); 933 client->CheckBrowseUrl(bad_url);
934 EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, client->GetThreatType()); 934 EXPECT_EQ(SB_THREAT_TYPE_URL_UNWANTED, client->GetThreatType());
935 } 935 }
936 936
937 // An unwanted URL also marked as malware should be flagged as malware. 937 // An unwanted URL also marked as malware should be flagged as malware.
938 { 938 {
939 scoped_refptr<TestSBClient> client(new TestSBClient); 939 scoped_refptr<TestSBClient> client(new TestSBClient);
940 940
941 SBFullHashResult full_hash_result; 941 SBFullHashResult full_hash_result;
942 GenUrlFullhashResult( 942 GenUrlFullhashResult(
943 bad_url, safe_browsing::MALWARE, &full_hash_result); 943 bad_url, safe_browsing_util::MALWARE, &full_hash_result);
944 SetupResponseForUrl(bad_url, full_hash_result); 944 SetupResponseForUrl(bad_url, full_hash_result);
945 945
946 client->CheckBrowseUrl(bad_url); 946 client->CheckBrowseUrl(bad_url);
947 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); 947 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType());
948 } 948 }
949 } 949 }
950 950
951 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckBrowseUrl) { 951 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckBrowseUrl) {
952 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile); 952 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile);
953 { 953 {
954 scoped_refptr<TestSBClient> client(new TestSBClient); 954 scoped_refptr<TestSBClient> client(new TestSBClient);
955 955
956 // Since bad_url is not in database, it is considered to be 956 // Since bad_url is not in database, it is considered to be
957 // safe. 957 // safe.
958 client->CheckBrowseUrl(bad_url); 958 client->CheckBrowseUrl(bad_url);
959 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); 959 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType());
960 960
961 SBFullHashResult full_hash_result; 961 SBFullHashResult full_hash_result;
962 GenUrlFullhashResult( 962 GenUrlFullhashResult(
963 bad_url, safe_browsing::MALWARE, &full_hash_result); 963 bad_url, safe_browsing_util::MALWARE, &full_hash_result);
964 SetupResponseForUrl(bad_url, full_hash_result); 964 SetupResponseForUrl(bad_url, full_hash_result);
965 965
966 // Now, the bad_url is not safe since it is added to download 966 // Now, the bad_url is not safe since it is added to download
967 // database. 967 // database.
968 client->CheckBrowseUrl(bad_url); 968 client->CheckBrowseUrl(bad_url);
969 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); 969 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType());
970 } 970 }
971 971
972 // The unwantedness should survive across multiple clients. 972 // The unwantedness should survive across multiple clients.
973 { 973 {
974 scoped_refptr<TestSBClient> client(new TestSBClient); 974 scoped_refptr<TestSBClient> client(new TestSBClient);
975 client->CheckBrowseUrl(bad_url); 975 client->CheckBrowseUrl(bad_url);
976 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); 976 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType());
977 } 977 }
978 978
979 // Adding the unwanted state to an existing malware URL should have no impact 979 // Adding the unwanted state to an existing malware URL should have no impact
980 // (i.e. a malware hit should still prevail). 980 // (i.e. a malware hit should still prevail).
981 { 981 {
982 scoped_refptr<TestSBClient> client(new TestSBClient); 982 scoped_refptr<TestSBClient> client(new TestSBClient);
983 983
984 SBFullHashResult full_hash_result; 984 SBFullHashResult full_hash_result;
985 GenUrlFullhashResult( 985 GenUrlFullhashResult(
986 bad_url, safe_browsing::UNWANTEDURL, &full_hash_result); 986 bad_url, safe_browsing_util::UNWANTEDURL, &full_hash_result);
987 SetupResponseForUrl(bad_url, full_hash_result); 987 SetupResponseForUrl(bad_url, full_hash_result);
988 988
989 client->CheckBrowseUrl(bad_url); 989 client->CheckBrowseUrl(bad_url);
990 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType()); 990 EXPECT_EQ(SB_THREAT_TYPE_URL_MALWARE, client->GetThreatType());
991 } 991 }
992 } 992 }
993 993
994 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckDownloadUrlRedirects) { 994 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckDownloadUrlRedirects) {
995 GURL original_url = embedded_test_server()->GetURL(kEmptyPage); 995 GURL original_url = embedded_test_server()->GetURL(kEmptyPage);
996 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile); 996 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile);
997 GURL final_url = embedded_test_server()->GetURL(kEmptyPage); 997 GURL final_url = embedded_test_server()->GetURL(kEmptyPage);
998 std::vector<GURL> badbin_urls; 998 std::vector<GURL> badbin_urls;
999 badbin_urls.push_back(original_url); 999 badbin_urls.push_back(original_url);
1000 badbin_urls.push_back(badbin_url); 1000 badbin_urls.push_back(badbin_url);
1001 badbin_urls.push_back(final_url); 1001 badbin_urls.push_back(final_url);
1002 1002
1003 scoped_refptr<TestSBClient> client(new TestSBClient); 1003 scoped_refptr<TestSBClient> client(new TestSBClient);
1004 client->CheckDownloadUrl(badbin_urls); 1004 client->CheckDownloadUrl(badbin_urls);
1005 1005
1006 // Since badbin_url is not in database, it is considered to be safe. 1006 // Since badbin_url is not in database, it is considered to be safe.
1007 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); 1007 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType());
1008 1008
1009 SBFullHashResult full_hash_result; 1009 SBFullHashResult full_hash_result;
1010 GenUrlFullhashResult(badbin_url, safe_browsing::BINURL, 1010 GenUrlFullhashResult(badbin_url, safe_browsing_util::BINURL,
1011 &full_hash_result); 1011 &full_hash_result);
1012 SetupResponseForUrl(badbin_url, full_hash_result); 1012 SetupResponseForUrl(badbin_url, full_hash_result);
1013 1013
1014 client->CheckDownloadUrl(badbin_urls); 1014 client->CheckDownloadUrl(badbin_urls);
1015 1015
1016 // Now, the badbin_url is not safe since it is added to download database. 1016 // Now, the badbin_url is not safe since it is added to download database.
1017 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); 1017 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType());
1018 } 1018 }
1019 1019
1020 #if defined(OS_WIN) 1020 #if defined(OS_WIN)
1021 // http://crbug.com/396409 1021 // http://crbug.com/396409
1022 #define MAYBE_CheckDownloadUrlTimedOut DISABLED_CheckDownloadUrlTimedOut 1022 #define MAYBE_CheckDownloadUrlTimedOut DISABLED_CheckDownloadUrlTimedOut
1023 #else 1023 #else
1024 #define MAYBE_CheckDownloadUrlTimedOut CheckDownloadUrlTimedOut 1024 #define MAYBE_CheckDownloadUrlTimedOut CheckDownloadUrlTimedOut
1025 #endif 1025 #endif
1026 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, 1026 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest,
1027 MAYBE_CheckDownloadUrlTimedOut) { 1027 MAYBE_CheckDownloadUrlTimedOut) {
1028 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile); 1028 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile);
1029 std::vector<GURL> badbin_urls(1, badbin_url); 1029 std::vector<GURL> badbin_urls(1, badbin_url);
1030 1030
1031 scoped_refptr<TestSBClient> client(new TestSBClient); 1031 scoped_refptr<TestSBClient> client(new TestSBClient);
1032 SBFullHashResult full_hash_result; 1032 SBFullHashResult full_hash_result;
1033 GenUrlFullhashResult(badbin_url, safe_browsing::BINURL, 1033 GenUrlFullhashResult(badbin_url, safe_browsing_util::BINURL,
1034 &full_hash_result); 1034 &full_hash_result);
1035 SetupResponseForUrl(badbin_url, full_hash_result); 1035 SetupResponseForUrl(badbin_url, full_hash_result);
1036 client->CheckDownloadUrl(badbin_urls); 1036 client->CheckDownloadUrl(badbin_urls);
1037 1037
1038 // badbin_url is not safe since it is added to download database. 1038 // badbin_url is not safe since it is added to download database.
1039 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); 1039 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType());
1040 1040
1041 // 1041 //
1042 // Now introducing delays and we should hit timeout. 1042 // Now introducing delays and we should hit timeout.
1043 // 1043 //
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 content::WindowedNotificationObserver observer( 1353 content::WindowedNotificationObserver observer(
1354 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, 1354 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
1355 content::Source<SafeBrowsingDatabaseManager>( 1355 content::Source<SafeBrowsingDatabaseManager>(
1356 sb_service_->database_manager().get())); 1356 sb_service_->database_manager().get()));
1357 BrowserThread::PostTask( 1357 BrowserThread::PostTask(
1358 BrowserThread::IO, 1358 BrowserThread::IO,
1359 FROM_HERE, 1359 FROM_HERE,
1360 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); 1360 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this));
1361 observer.Wait(); 1361 observer.Wait();
1362 } 1362 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698