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 "chrome/browser/safe_browsing/safe_browsing_service.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "components/safe_browsing_db/database_manager.h" | 55 #include "components/safe_browsing_db/database_manager.h" |
56 #include "components/safe_browsing_db/metadata.pb.h" | 56 #include "components/safe_browsing_db/metadata.pb.h" |
57 #include "components/safe_browsing_db/test_database_manager.h" | 57 #include "components/safe_browsing_db/test_database_manager.h" |
58 #include "components/safe_browsing_db/util.h" | 58 #include "components/safe_browsing_db/util.h" |
59 #include "components/safe_browsing_db/v4_database.h" | 59 #include "components/safe_browsing_db/v4_database.h" |
60 #include "components/safe_browsing_db/v4_feature_list.h" | 60 #include "components/safe_browsing_db/v4_feature_list.h" |
61 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" | 61 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
62 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 62 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
63 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" | 63 #include "components/subresource_filter/core/browser/subresource_filter_features
.h" |
64 #include "components/subresource_filter/core/browser/subresource_filter_features
_test_support.h" | 64 #include "components/subresource_filter/core/browser/subresource_filter_features
_test_support.h" |
| 65 #include "components/subresource_filter/core/common/activation_level.h" |
| 66 #include "components/subresource_filter/core/common/activation_list.h" |
| 67 #include "components/subresource_filter/core/common/activation_state.h" |
65 #include "components/subresource_filter/core/common/test_ruleset_creator.h" | 68 #include "components/subresource_filter/core/common/test_ruleset_creator.h" |
66 #include "content/public/browser/interstitial_page.h" | 69 #include "content/public/browser/interstitial_page.h" |
67 #include "content/public/browser/navigation_entry.h" | 70 #include "content/public/browser/navigation_entry.h" |
68 #include "content/public/browser/render_frame_host.h" | 71 #include "content/public/browser/render_frame_host.h" |
69 #include "content/public/browser/web_contents.h" | 72 #include "content/public/browser/web_contents.h" |
70 #include "content/public/common/content_switches.h" | 73 #include "content/public/common/content_switches.h" |
71 #include "content/public/test/browser_test_utils.h" | 74 #include "content/public/test/browser_test_utils.h" |
72 #include "crypto/sha2.h" | 75 #include "crypto/sha2.h" |
73 #include "net/cookies/cookie_store.h" | 76 #include "net/cookies/cookie_store.h" |
74 #include "net/cookies/cookie_util.h" | 77 #include "net/cookies/cookie_util.h" |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 900 |
898 EXPECT_TRUE(ShowingInterstitialPage()); | 901 EXPECT_TRUE(ShowingInterstitialPage()); |
899 EXPECT_TRUE(got_hit_report()); | 902 EXPECT_TRUE(got_hit_report()); |
900 EXPECT_EQ(bad_url, hit_report().malicious_url); | 903 EXPECT_EQ(bad_url, hit_report().malicious_url); |
901 EXPECT_EQ(bad_url, hit_report().page_url); | 904 EXPECT_EQ(bad_url, hit_report().page_url); |
902 EXPECT_EQ(first_url, hit_report().referrer_url); | 905 EXPECT_EQ(first_url, hit_report().referrer_url); |
903 EXPECT_FALSE(hit_report().is_subresource); | 906 EXPECT_FALSE(hit_report().is_subresource); |
904 } | 907 } |
905 | 908 |
906 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, SubresourceFilterEndToEndTest) { | 909 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, SubresourceFilterEndToEndTest) { |
907 subresource_filter::testing::ScopedSubresourceFilterFeatureToggle | 910 subresource_filter::testing::ScopedSubresourceFilterConfigurator |
908 scoped_feature_toggle( | 911 scoped_configuration(subresource_filter::Configuration( |
909 base::FeatureList::OVERRIDE_ENABLE_FEATURE, | 912 subresource_filter::ActivationLevel::ENABLED, |
910 subresource_filter::kActivationLevelEnabled, | 913 subresource_filter::ActivationScope::ACTIVATION_LIST, |
911 subresource_filter::kActivationScopeActivationList, | 914 subresource_filter::ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); |
912 subresource_filter::kActivationListSocialEngineeringAdsInterstitial); | |
913 | 915 |
914 subresource_filter::testing::TestRulesetCreator ruleset_creator; | 916 subresource_filter::testing::TestRulesetCreator ruleset_creator; |
915 subresource_filter::testing::TestRulesetPair test_ruleset_pair; | 917 subresource_filter::testing::TestRulesetPair test_ruleset_pair; |
916 ruleset_creator.CreateRulesetToDisallowURLsWithPathSuffix( | 918 ruleset_creator.CreateRulesetToDisallowURLsWithPathSuffix( |
917 "included_script.js", &test_ruleset_pair); | 919 "included_script.js", &test_ruleset_pair); |
918 subresource_filter::testing::TestRulesetPublisher test_ruleset_publisher; | 920 subresource_filter::testing::TestRulesetPublisher test_ruleset_publisher; |
919 ASSERT_NO_FATAL_FAILURE( | 921 ASSERT_NO_FATAL_FAILURE( |
920 test_ruleset_publisher.SetRuleset(test_ruleset_pair.unindexed)); | 922 test_ruleset_publisher.SetRuleset(test_ruleset_pair.unindexed)); |
921 | 923 |
922 GURL phishing_url = embedded_test_server()->GetURL( | 924 GURL phishing_url = embedded_test_server()->GetURL( |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 EXPECT_TRUE(ShowingInterstitialPage()); | 1972 EXPECT_TRUE(ShowingInterstitialPage()); |
1971 EXPECT_TRUE(got_hit_report()); | 1973 EXPECT_TRUE(got_hit_report()); |
1972 EXPECT_EQ(bad_url, hit_report().malicious_url); | 1974 EXPECT_EQ(bad_url, hit_report().malicious_url); |
1973 EXPECT_EQ(bad_url, hit_report().page_url); | 1975 EXPECT_EQ(bad_url, hit_report().page_url); |
1974 EXPECT_EQ(first_url, hit_report().referrer_url); | 1976 EXPECT_EQ(first_url, hit_report().referrer_url); |
1975 EXPECT_FALSE(hit_report().is_subresource); | 1977 EXPECT_FALSE(hit_report().is_subresource); |
1976 } | 1978 } |
1977 | 1979 |
1978 IN_PROC_BROWSER_TEST_F(V4SafeBrowsingServiceTest, | 1980 IN_PROC_BROWSER_TEST_F(V4SafeBrowsingServiceTest, |
1979 SubresourceFilterEndToEndTest) { | 1981 SubresourceFilterEndToEndTest) { |
1980 subresource_filter::testing::ScopedSubresourceFilterFeatureToggle | 1982 subresource_filter::testing::ScopedSubresourceFilterConfigurator |
1981 scoped_feature_toggle( | 1983 scoped_configuration(subresource_filter::Configuration( |
1982 base::FeatureList::OVERRIDE_ENABLE_FEATURE, | 1984 subresource_filter::ActivationLevel::ENABLED, |
1983 subresource_filter::kActivationLevelEnabled, | 1985 subresource_filter::ActivationScope::ACTIVATION_LIST, |
1984 subresource_filter::kActivationScopeActivationList, | 1986 subresource_filter::ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); |
1985 subresource_filter::kActivationListSocialEngineeringAdsInterstitial); | |
1986 | 1987 |
1987 subresource_filter::testing::TestRulesetCreator ruleset_creator; | 1988 subresource_filter::testing::TestRulesetCreator ruleset_creator; |
1988 subresource_filter::testing::TestRulesetPair test_ruleset_pair; | 1989 subresource_filter::testing::TestRulesetPair test_ruleset_pair; |
1989 ruleset_creator.CreateRulesetToDisallowURLsWithPathSuffix( | 1990 ruleset_creator.CreateRulesetToDisallowURLsWithPathSuffix( |
1990 "included_script.js", &test_ruleset_pair); | 1991 "included_script.js", &test_ruleset_pair); |
1991 subresource_filter::testing::TestRulesetPublisher test_ruleset_publisher; | 1992 subresource_filter::testing::TestRulesetPublisher test_ruleset_publisher; |
1992 ASSERT_NO_FATAL_FAILURE( | 1993 ASSERT_NO_FATAL_FAILURE( |
1993 test_ruleset_publisher.SetRuleset(test_ruleset_pair.unindexed)); | 1994 test_ruleset_publisher.SetRuleset(test_ruleset_pair.unindexed)); |
1994 | 1995 |
1995 GURL phishing_url = embedded_test_server()->GetURL( | 1996 GURL phishing_url = embedded_test_server()->GetURL( |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 } | 2490 } |
2490 | 2491 |
2491 INSTANTIATE_TEST_CASE_P( | 2492 INSTANTIATE_TEST_CASE_P( |
2492 MaybeSetMetadata, | 2493 MaybeSetMetadata, |
2493 V4SafeBrowsingServiceMetadataTest, | 2494 V4SafeBrowsingServiceMetadataTest, |
2494 testing::Values(ThreatPatternType::NONE, | 2495 testing::Values(ThreatPatternType::NONE, |
2495 ThreatPatternType::MALWARE_LANDING, | 2496 ThreatPatternType::MALWARE_LANDING, |
2496 ThreatPatternType::MALWARE_DISTRIBUTION)); | 2497 ThreatPatternType::MALWARE_DISTRIBUTION)); |
2497 | 2498 |
2498 } // namespace safe_browsing | 2499 } // namespace safe_browsing |
OLD | NEW |