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

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

Issue 2926473002: Mac Archive Type Sniffing (Closed)
Patch Set: adding tester for download protection service Created 3 years, 6 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 e8d6a592bce135a9bc4ae9942de860e06deee307..8f0067d799707c8e7ff75ba6c9bea789edf5e254 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.h"
#include "chrome/browser/safe_browsing/local_database_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/safe_browsing/binary_feature_extractor.h"
#include "chrome/common/safe_browsing/file_type_policies_test_util.h"
#include "chrome/test/base/testing_profile.h"
@@ -1443,6 +1444,74 @@ TEST_F(DownloadProtectionServiceTest,
CheckClientDownloadReportCorruptDmg) {
CheckClientDownloadReportCorruptArchive(DMG);
}
+
+TEST_F(DownloadProtectionServiceTest,
+ CheckClientDownloadReportDmgWithoutExtension) {
+ net::FakeURLFetcherFactory factory(NULL);
+ PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
+
+ base::FilePath test_data;
+ EXPECT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &test_data));
+ test_data = test_data.AppendASCII("chrome")
+ .AppendASCII("safe_browsing_dmg")
+ .AppendASCII("mach_o_in_dmg.txt");
+
+ NiceMockDownloadItem item;
+ PrepareBasicDownloadItem(&item, {"http://www.evil.com/a.dmg"}, // url_chain
+ "http://www.google.com/", // referrer
+ FILE_PATH_LITERAL("a.tmp"), // tmp_path
+ FILE_PATH_LITERAL("a.dmg")); // final_path
+
+ tmp_path_ = test_data;
+
+ RunLoop run_loop;
+ download_service_->CheckClientDownload(
+ &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
+ base::Unretained(this), run_loop.QuitClosure()));
+ run_loop.Run();
+
+ ASSERT_TRUE(HasClientDownloadRequest());
+ EXPECT_TRUE(GetClientDownloadRequest()->archive_valid());
+ ClearClientDownloadRequest();
+
+ Mock::VerifyAndClearExpectations(sb_service_.get());
+ Mock::VerifyAndClearExpectations(binary_feature_extractor_.get());
+}
+
+TEST_F(DownloadProtectionServiceTest, CheckClientDownloadReportDmgWithoutKoly) {
+ net::FakeURLFetcherFactory factory(NULL);
+ PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
+
+ base::FilePath test_data;
+ EXPECT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &test_data));
+ test_data = test_data.AppendASCII("chrome")
+ .AppendASCII("safe_browsing_dmg")
+ .AppendASCII("mach_o_in_dmg_no_koly_signature.txt");
+
+ NiceMockDownloadItem item;
+ PrepareBasicDownloadItem(&item, {"http://www.evil.com/a.dmg"}, // url_chain
+ "http://www.google.com/", // referrer
+ FILE_PATH_LITERAL("a.tmp"), // tmp_path
+ FILE_PATH_LITERAL("a.dmg")); // final_path
+
+ tmp_path_ = test_data;
+
+ RunLoop run_loop;
+ download_service_->CheckClientDownload(
+ &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
+ base::Unretained(this), run_loop.QuitClosure()));
+ run_loop.Run();
+
+ ASSERT_TRUE(HasClientDownloadRequest());
+ EXPECT_FALSE(GetClientDownloadRequest()->archive_valid());
+ ClearClientDownloadRequest();
+
+ Mock::VerifyAndClearExpectations(sb_service_.get());
+ Mock::VerifyAndClearExpectations(binary_feature_extractor_.get());
+}
+
#endif
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadValidateRequest) {

Powered by Google App Engine
This is Rietveld 408576698