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

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

Issue 2128583005: DownloadProtection: Add more graceful handling of verdict=UNKNOWN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/download_protection_service_unittest.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index 891ac1df00b5a851908fb0fd245d7f87c5b37f46..9431d67b6e56de458bc969111bcd39806dbc66e1 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -966,11 +966,11 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
MatchDownloadWhitelistUrl(_))
.WillRepeatedly(Return(false));
EXPECT_CALL(*binary_feature_extractor_.get(), CheckSignature(tmp_path_, _))
- .Times(6);
+ .Times(7);
EXPECT_CALL(*binary_feature_extractor_.get(),
ExtractImageFeatures(
tmp_path_, BinaryFeatureExtractor::kDefaultOptions, _, _))
- .Times(6);
+ .Times(7);
download_service_->CheckClientDownload(
&item,
@@ -1075,6 +1075,22 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
EXPECT_TRUE(IsResult(DownloadProtectionService::POTENTIALLY_UNWANTED));
EXPECT_TRUE(HasClientDownloadRequest());
ClearClientDownloadRequest();
+
+ // If the response is UNKNOWN the result should also be marked as
+ // UNKNOWN
+ PrepareResponse(
+ &factory, ClientDownloadResponse::UNKNOWN, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
+
+ download_service_->CheckClientDownload(
+ &item,
+ base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
+ base::Unretained(this)));
+ base::RunLoop().Run();
+
+ EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
+ EXPECT_TRUE(HasClientDownloadRequest());
+ ClearClientDownloadRequest();
}
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) {
@@ -1345,42 +1361,6 @@ TEST_F(DownloadProtectionServiceTest,
CheckClientDownloadReportCorruptZip(true, true);
}
-TEST_F(DownloadProtectionServiceTest, CheckClientCrxDownloadSuccess) {
- // Even if the server verdict is dangerous we should return SAFE because
- // DownloadProtectionService::IsSupportedDownload() will return false
- // for crx downloads.
- net::FakeURLFetcherFactory factory(NULL);
- PrepareResponse(
- &factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- content::MockDownloadItem item;
- PrepareBasicDownloadItem(
- &item,
- {"http://www.evil.com/a.crx"}, // url_chain
- "http://www.google.com/", // referrer
- FILE_PATH_LITERAL("a.tmp"), // tmp_path
- FILE_PATH_LITERAL("a.crx")); // final_path
-
- EXPECT_CALL(*sb_service_->mock_database_manager(),
- MatchDownloadWhitelistUrl(_))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*binary_feature_extractor_.get(), CheckSignature(tmp_path_, _))
- .Times(1);
- EXPECT_CALL(*binary_feature_extractor_.get(),
- ExtractImageFeatures(
- tmp_path_, BinaryFeatureExtractor::kDefaultOptions, _, _))
- .Times(1);
-
- EXPECT_FALSE(download_service_->IsSupportedDownload(item, final_path_));
- download_service_->CheckClientDownload(
- &item,
- base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
- base::Unretained(this)));
- base::RunLoop().Run();
- EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
-}
-
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadValidateRequest) {
net::TestURLFetcherFactory factory;
@@ -2003,6 +1983,7 @@ TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedDefault) {
DownloadProtectionService::DANGEROUS_HOST},
{ClientDownloadResponse::POTENTIALLY_UNWANTED,
DownloadProtectionService::POTENTIALLY_UNWANTED},
+ {ClientDownloadResponse::UNKNOWN, DownloadProtectionService::UNKNOWN},
};
for (const auto& test_case : kExpectedResults) {

Powered by Google App Engine
This is Rietveld 408576698