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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 // Since badbin_url is not in database, it is considered to be safe. | 1213 // Since badbin_url is not in database, it is considered to be safe. |
1214 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); | 1214 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); |
1215 | 1215 |
1216 SBFullHashResult full_hash_result; | 1216 SBFullHashResult full_hash_result; |
1217 GenUrlFullHashResult(badbin_url, BINURL, &full_hash_result); | 1217 GenUrlFullHashResult(badbin_url, BINURL, &full_hash_result); |
1218 SetupResponseForUrl(badbin_url, full_hash_result); | 1218 SetupResponseForUrl(badbin_url, full_hash_result); |
1219 | 1219 |
1220 client->CheckDownloadUrl(badbin_urls); | 1220 client->CheckDownloadUrl(badbin_urls); |
1221 | 1221 |
1222 // Now, the badbin_url is not safe since it is added to download database. | 1222 // Now, the badbin_url is not safe since it is added to download database. |
1223 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); | 1223 EXPECT_EQ(SB_THREAT_TYPE_URL_BINARY_MALWARE, client->GetThreatType()); |
1224 } | 1224 } |
1225 | 1225 |
1226 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckUnwantedSoftwareUrl) { | 1226 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckUnwantedSoftwareUrl) { |
1227 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile); | 1227 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile); |
1228 { | 1228 { |
1229 scoped_refptr<TestSBClient> client(new TestSBClient); | 1229 scoped_refptr<TestSBClient> client(new TestSBClient); |
1230 | 1230 |
1231 // Since bad_url is not in database, it is considered to be | 1231 // Since bad_url is not in database, it is considered to be |
1232 // safe. | 1232 // safe. |
1233 client->CheckBrowseUrl(bad_url); | 1233 client->CheckBrowseUrl(bad_url); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 // Since badbin_url is not in database, it is considered to be safe. | 1319 // Since badbin_url is not in database, it is considered to be safe. |
1320 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); | 1320 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); |
1321 | 1321 |
1322 SBFullHashResult full_hash_result; | 1322 SBFullHashResult full_hash_result; |
1323 GenUrlFullHashResult(badbin_url, BINURL, &full_hash_result); | 1323 GenUrlFullHashResult(badbin_url, BINURL, &full_hash_result); |
1324 SetupResponseForUrl(badbin_url, full_hash_result); | 1324 SetupResponseForUrl(badbin_url, full_hash_result); |
1325 | 1325 |
1326 client->CheckDownloadUrl(badbin_urls); | 1326 client->CheckDownloadUrl(badbin_urls); |
1327 | 1327 |
1328 // Now, the badbin_url is not safe since it is added to download database. | 1328 // Now, the badbin_url is not safe since it is added to download database. |
1329 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); | 1329 EXPECT_EQ(SB_THREAT_TYPE_URL_BINARY_MALWARE, client->GetThreatType()); |
1330 } | 1330 } |
1331 | 1331 |
1332 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckResourceUrl) { | 1332 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckResourceUrl) { |
1333 GURL blacklist_resource = embedded_test_server()->GetURL(kBlacklistResource); | 1333 GURL blacklist_resource = embedded_test_server()->GetURL(kBlacklistResource); |
1334 std::string blacklist_resource_hash; | 1334 std::string blacklist_resource_hash; |
1335 GURL malware_resource = embedded_test_server()->GetURL(kMaliciousResource); | 1335 GURL malware_resource = embedded_test_server()->GetURL(kMaliciousResource); |
1336 std::string malware_resource_hash; | 1336 std::string malware_resource_hash; |
1337 | 1337 |
1338 { | 1338 { |
1339 SBFullHashResult full_hash; | 1339 SBFullHashResult full_hash; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile); | 1379 GURL badbin_url = embedded_test_server()->GetURL(kMalwareFile); |
1380 std::vector<GURL> badbin_urls(1, badbin_url); | 1380 std::vector<GURL> badbin_urls(1, badbin_url); |
1381 | 1381 |
1382 scoped_refptr<TestSBClient> client(new TestSBClient); | 1382 scoped_refptr<TestSBClient> client(new TestSBClient); |
1383 SBFullHashResult full_hash_result; | 1383 SBFullHashResult full_hash_result; |
1384 GenUrlFullHashResult(badbin_url, BINURL, &full_hash_result); | 1384 GenUrlFullHashResult(badbin_url, BINURL, &full_hash_result); |
1385 SetupResponseForUrl(badbin_url, full_hash_result); | 1385 SetupResponseForUrl(badbin_url, full_hash_result); |
1386 client->CheckDownloadUrl(badbin_urls); | 1386 client->CheckDownloadUrl(badbin_urls); |
1387 | 1387 |
1388 // badbin_url is not safe since it is added to download database. | 1388 // badbin_url is not safe since it is added to download database. |
1389 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); | 1389 EXPECT_EQ(SB_THREAT_TYPE_URL_BINARY_MALWARE, client->GetThreatType()); |
1390 | 1390 |
1391 // | 1391 // |
1392 // Now introducing delays and we should hit timeout. | 1392 // Now introducing delays and we should hit timeout. |
1393 // | 1393 // |
1394 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); | 1394 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); |
1395 base::TimeDelta default_urlcheck_timeout = GetCheckTimeout(sb_service); | 1395 base::TimeDelta default_urlcheck_timeout = GetCheckTimeout(sb_service); |
1396 IntroduceGetHashDelay(base::TimeDelta::FromSeconds(1)); | 1396 IntroduceGetHashDelay(base::TimeDelta::FromSeconds(1)); |
1397 SetCheckTimeout(sb_service, base::TimeDelta::FromMilliseconds(1)); | 1397 SetCheckTimeout(sb_service, base::TimeDelta::FromMilliseconds(1)); |
1398 client->CheckDownloadUrl(badbin_urls); | 1398 client->CheckDownloadUrl(badbin_urls); |
1399 | 1399 |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 client->CheckDownloadUrl(badbin_urls); | 2106 client->CheckDownloadUrl(badbin_urls); |
2107 | 2107 |
2108 // Since badbin_url is not in database, it is considered to be safe. | 2108 // Since badbin_url is not in database, it is considered to be safe. |
2109 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); | 2109 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); |
2110 | 2110 |
2111 MarkUrlForMalwareBinaryUnexpired(badbin_url); | 2111 MarkUrlForMalwareBinaryUnexpired(badbin_url); |
2112 | 2112 |
2113 client->CheckDownloadUrl(badbin_urls); | 2113 client->CheckDownloadUrl(badbin_urls); |
2114 | 2114 |
2115 // Now, the badbin_url is not safe since it is added to download database. | 2115 // Now, the badbin_url is not safe since it is added to download database. |
2116 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); | 2116 EXPECT_EQ(SB_THREAT_TYPE_URL_BINARY_MALWARE, client->GetThreatType()); |
2117 } | 2117 } |
2118 #endif // defined(GOOGLE_CHROME_BUILD) | 2118 #endif // defined(GOOGLE_CHROME_BUILD) |
2119 | 2119 |
2120 IN_PROC_BROWSER_TEST_F(V4SafeBrowsingServiceTest, CheckUnwantedSoftwareUrl) { | 2120 IN_PROC_BROWSER_TEST_F(V4SafeBrowsingServiceTest, CheckUnwantedSoftwareUrl) { |
2121 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile); | 2121 const GURL bad_url = embedded_test_server()->GetURL(kMalwareFile); |
2122 { | 2122 { |
2123 scoped_refptr<TestSBClient> client(new TestSBClient); | 2123 scoped_refptr<TestSBClient> client(new TestSBClient); |
2124 | 2124 |
2125 // Since bad_url is not in database, it is considered to be | 2125 // Since bad_url is not in database, it is considered to be |
2126 // safe. | 2126 // safe. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 client->CheckDownloadUrl(badbin_urls); | 2206 client->CheckDownloadUrl(badbin_urls); |
2207 | 2207 |
2208 // Since badbin_url is not in database, it is considered to be safe. | 2208 // Since badbin_url is not in database, it is considered to be safe. |
2209 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); | 2209 EXPECT_EQ(SB_THREAT_TYPE_SAFE, client->GetThreatType()); |
2210 | 2210 |
2211 MarkUrlForMalwareBinaryUnexpired(badbin_url); | 2211 MarkUrlForMalwareBinaryUnexpired(badbin_url); |
2212 | 2212 |
2213 client->CheckDownloadUrl(badbin_urls); | 2213 client->CheckDownloadUrl(badbin_urls); |
2214 | 2214 |
2215 // Now, the badbin_url is not safe since it is added to download database. | 2215 // Now, the badbin_url is not safe since it is added to download database. |
2216 EXPECT_EQ(SB_THREAT_TYPE_BINARY_MALWARE_URL, client->GetThreatType()); | 2216 EXPECT_EQ(SB_THREAT_TYPE_URL_BINARY_MALWARE, client->GetThreatType()); |
2217 } | 2217 } |
2218 #endif // defined(GOOGLE_CHROME_BUILD) | 2218 #endif // defined(GOOGLE_CHROME_BUILD) |
2219 | 2219 |
2220 #if defined(GOOGLE_CHROME_BUILD) | 2220 #if defined(GOOGLE_CHROME_BUILD) |
2221 // This test is only enabled when GOOGLE_CHROME_BUILD is true because the store | 2221 // This test is only enabled when GOOGLE_CHROME_BUILD is true because the store |
2222 // that this test uses is only populated on GOOGLE_CHROME_BUILD builds. | 2222 // that this test uses is only populated on GOOGLE_CHROME_BUILD builds. |
2223 IN_PROC_BROWSER_TEST_F(V4SafeBrowsingServiceTest, CheckResourceUrl) { | 2223 IN_PROC_BROWSER_TEST_F(V4SafeBrowsingServiceTest, CheckResourceUrl) { |
2224 GURL blacklist_url = embedded_test_server()->GetURL(kBlacklistResource); | 2224 GURL blacklist_url = embedded_test_server()->GetURL(kBlacklistResource); |
2225 GURL malware_url = embedded_test_server()->GetURL(kMaliciousResource); | 2225 GURL malware_url = embedded_test_server()->GetURL(kMaliciousResource); |
2226 std::string blacklist_url_hash, malware_url_hash; | 2226 std::string blacklist_url_hash, malware_url_hash; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 } | 2356 } |
2357 | 2357 |
2358 INSTANTIATE_TEST_CASE_P( | 2358 INSTANTIATE_TEST_CASE_P( |
2359 MaybeSetMetadata, | 2359 MaybeSetMetadata, |
2360 V4SafeBrowsingServiceMetadataTest, | 2360 V4SafeBrowsingServiceMetadataTest, |
2361 testing::Values(ThreatPatternType::NONE, | 2361 testing::Values(ThreatPatternType::NONE, |
2362 ThreatPatternType::MALWARE_LANDING, | 2362 ThreatPatternType::MALWARE_LANDING, |
2363 ThreatPatternType::MALWARE_DISTRIBUTION)); | 2363 ThreatPatternType::MALWARE_DISTRIBUTION)); |
2364 | 2364 |
2365 } // namespace safe_browsing | 2365 } // namespace safe_browsing |
OLD | NEW |