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

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

Issue 8536041: This CL integrates the new SafeBrowsing download service class (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix uninitialized variable issue. Created 9 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 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 82054eabc3364eec9c4900ef407f905347f7b92e..97a895acca56a99c7b17f9c84d1d803c724d3b00 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -214,8 +214,9 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadInvalidUrl) {
msg_loop_.Run();
EXPECT_EQ(DownloadProtectionService::SAFE, result_);
- // Only http is supported for now.
- info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
+ // Only https is not supported for now for privacy reasons.
+ info.local_file = FilePath(FILE_PATH_LITERAL("a.tmp"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("a.exe"));
info.download_url_chain.push_back(GURL("https://www.google.com/"));
download_service_->CheckClientDownload(
info,
@@ -223,19 +224,12 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadInvalidUrl) {
base::Unretained(this)));
msg_loop_.Run();
EXPECT_EQ(DownloadProtectionService::SAFE, result_);
-
- info.download_url_chain[0] = GURL("ftp://www.google.com/");
- download_service_->CheckClientDownload(
- info,
- base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
- base::Unretained(this)));
- msg_loop_.Run();
- EXPECT_EQ(DownloadProtectionService::SAFE, result_);
}
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadWhitelistedUrl) {
DownloadProtectionService::DownloadInfo info;
- info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
+ info.local_file = FilePath(FILE_PATH_LITERAL("a.tmp"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("a.exe"));
info.download_url_chain.push_back(GURL("http://www.evil.com/bla.exe"));
info.download_url_chain.push_back(GURL("http://www.google.com/a.exe"));
info.referrer_url = GURL("http://www.google.com/");
@@ -272,7 +266,8 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadFetchFailed) {
DownloadProtectionService::kDownloadRequestUrl, "", false);
DownloadProtectionService::DownloadInfo info;
- info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
+ info.local_file = FilePath(FILE_PATH_LITERAL("a.tmp"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("a.exe"));
info.download_url_chain.push_back(GURL("http://www.evil.com/a.exe"));
info.referrer_url = GURL("http://www.google.com/");
@@ -299,7 +294,8 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
true);
DownloadProtectionService::DownloadInfo info;
- info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
+ info.local_file = FilePath(FILE_PATH_LITERAL("a.tmp"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("a.exe"));
info.download_url_chain.push_back(GURL("http://www.evil.com/a.exe"));
info.referrer_url = GURL("http://www.google.com/");
@@ -347,7 +343,8 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadValidateRequest) {
TestURLFetcherFactory factory;
DownloadProtectionService::DownloadInfo info;
- info.local_file = FilePath(FILE_PATH_LITERAL("bla.exe"));
+ info.local_file = FilePath(FILE_PATH_LITERAL("bla.tmp"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("bla.exe"));
info.download_url_chain.push_back(GURL("http://www.google.com/"));
info.download_url_chain.push_back(GURL("http://www.google.com/bla.exe"));
info.referrer_url = GURL("http://www.google.com/");
@@ -401,7 +398,8 @@ TEST_F(DownloadProtectionServiceTest,
TestURLFetcherFactory factory;
DownloadProtectionService::DownloadInfo info;
- info.local_file = FilePath(FILE_PATH_LITERAL("bla.exe"));
+ info.local_file = FilePath(FILE_PATH_LITERAL("bla.tmp"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("bla.exe"));
info.download_url_chain.push_back(GURL("http://www.google.com/"));
info.download_url_chain.push_back(GURL("http://www.google.com/bla.exe"));
info.referrer_url = GURL("http://www.google.com/");
@@ -449,7 +447,9 @@ TEST_F(DownloadProtectionServiceTest,
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadDigestList) {
DownloadProtectionService::DownloadInfo info;
- info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
+ info.local_file = FilePath(FILE_PATH_LITERAL("a.tmp"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("a.exe"));
+
// HTTPs URLs never result in a server ping for privacy reasons. However,
// we do lookup the bad binary digest list.
info.download_url_chain.push_back(GURL("https://www.evil.com/a.exe"));
@@ -498,7 +498,8 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadDigestList) {
EXPECT_EQ(DownloadProtectionService::SAFE, result_);
Mock::VerifyAndClearExpectations(sb_service_);
- // A match is found with the bad binary digest list.
+ // A match is found with the bad binary digest list. We currently do not
+ // warn based on the digest list. Hence we should always return SAFE.
EXPECT_CALL(*sb_service_,
CheckDownloadHash(info.sha256_hash, NotNull()))
.WillOnce(DoAll(
@@ -509,12 +510,12 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadDigestList) {
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
msg_loop_.Run();
- EXPECT_EQ(DownloadProtectionService::DANGEROUS, result_);
+ EXPECT_EQ(DownloadProtectionService::SAFE, result_);
Mock::VerifyAndClearExpectations(sb_service_);
// If the download is not an executable we do not send a server ping but we
// still want to lookup the binary digest list.
- info.local_file = FilePath(FILE_PATH_LITERAL("a.pdf"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("a.pdf"));
info.download_url_chain[0] = GURL("http://www.evil.com/a.pdf");
EXPECT_CALL(*sb_service_,
CheckDownloadHash(info.sha256_hash, NotNull()))
@@ -526,13 +527,13 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadDigestList) {
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
msg_loop_.Run();
- EXPECT_EQ(DownloadProtectionService::DANGEROUS, result_);
+ EXPECT_EQ(DownloadProtectionService::SAFE, result_);
Mock::VerifyAndClearExpectations(sb_service_);
// If the URL or the referrer matches the download whitelist we cannot send
// a server ping for privacy reasons but we still match the digest against
// the bad binary digest list.
- info.local_file = FilePath(FILE_PATH_LITERAL("a.exe"));
+ info.target_file = FilePath(FILE_PATH_LITERAL("a.exe"));
info.download_url_chain[0] = GURL("http://www.evil.com/a.exe");
EXPECT_CALL(*sb_service_, MatchDownloadWhitelistUrl(_))
.WillRepeatedly(Return(true));
@@ -547,7 +548,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadDigestList) {
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
msg_loop_.Run();
- EXPECT_EQ(DownloadProtectionService::DANGEROUS, result_);
+ EXPECT_EQ(DownloadProtectionService::SAFE, result_);
}
TEST_F(DownloadProtectionServiceTest, TestCheckDownloadUrl) {

Powered by Google App Engine
This is Rietveld 408576698