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

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 2146703002: Sample 1% url whitelisted PPAPI downloads to ping safe browsing server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address asanka@'s comment 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 547
548 548
549 void DownloadProtectionServiceTest::CheckClientDownloadReportCorruptZip( 549 void DownloadProtectionServiceTest::CheckClientDownloadReportCorruptZip(
550 bool is_extended_reporting, 550 bool is_extended_reporting,
551 bool is_incognito) { 551 bool is_incognito) {
552 net::FakeURLFetcherFactory factory(NULL); 552 net::FakeURLFetcherFactory factory(NULL);
553 PrepareResponse( 553 PrepareResponse(
554 &factory, ClientDownloadResponse::SAFE, net::HTTP_OK, 554 &factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
555 net::URLRequestStatus::SUCCESS); 555 net::URLRequestStatus::SUCCESS);
556 556
557 profile_->GetPrefs()->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, 557 SetExtendedReportingPreference(is_extended_reporting);
558 is_extended_reporting);
559 content::MockDownloadItem item; 558 content::MockDownloadItem item;
560 PrepareBasicDownloadItem( 559 PrepareBasicDownloadItem(
561 &item, 560 &item,
562 {"http://www.evil.com/a.zip"}, // url_chain 561 {"http://www.evil.com/a.zip"}, // url_chain
563 "http://www.google.com/", // referrer 562 "http://www.google.com/", // referrer
564 FILE_PATH_LITERAL("a.tmp"), // tmp_path 563 FILE_PATH_LITERAL("a.tmp"), // tmp_path
565 FILE_PATH_LITERAL("a.zip")); // final_path 564 FILE_PATH_LITERAL("a.zip")); // final_path
566 565
567 if (is_incognito) { 566 if (is_incognito) {
568 EXPECT_CALL(item, GetBrowserContext()) 567 EXPECT_CALL(item, GetBrowserContext())
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 EXPECT_EQ(token, DownloadProtectionService::GetDownloadPingToken(&item)); 1970 EXPECT_EQ(token, DownloadProtectionService::GetDownloadPingToken(&item));
1972 1971
1973 DownloadProtectionService::SetDownloadPingToken(&item, std::string()); 1972 DownloadProtectionService::SetDownloadPingToken(&item, std::string());
1974 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty()); 1973 EXPECT_TRUE(DownloadProtectionService::GetDownloadPingToken(&item).empty());
1975 } 1974 }
1976 1975
1977 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) { 1976 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Unsupported) {
1978 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); 1977 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt"));
1979 std::vector<base::FilePath::StringType> alternate_extensions{ 1978 std::vector<base::FilePath::StringType> alternate_extensions{
1980 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")}; 1979 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".asdfasdf")};
1980 SetExtendedReportingPreference(false);
1981 download_service_->CheckPPAPIDownloadRequest( 1981 download_service_->CheckPPAPIDownloadRequest(
1982 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 1982 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
1983 profile_.get(),
1983 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback, 1984 base::Bind(&DownloadProtectionServiceTest::SyncCheckDoneCallback,
1984 base::Unretained(this))); 1985 base::Unretained(this)));
1985 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); 1986 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE));
1986 } 1987 }
1987 1988
1988 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedDefault) { 1989 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedDefault) {
1989 net::FakeURLFetcherFactory factory(nullptr); 1990 net::FakeURLFetcherFactory factory(nullptr);
1990 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 1991 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
1991 std::vector<base::FilePath::StringType> alternate_extensions; 1992 std::vector<base::FilePath::StringType> alternate_extensions;
1992 EXPECT_CALL(*sb_service_->mock_database_manager(), 1993 EXPECT_CALL(*sb_service_->mock_database_manager(),
1993 MatchDownloadWhitelistUrl(_)) 1994 MatchDownloadWhitelistUrl(_))
1994 .WillRepeatedly(Return(false)); 1995 .WillRepeatedly(Return(false));
1995 struct { 1996 struct {
1996 ClientDownloadResponse::Verdict verdict; 1997 ClientDownloadResponse::Verdict verdict;
1997 DownloadProtectionService::DownloadCheckResult expected_result; 1998 DownloadProtectionService::DownloadCheckResult expected_result;
1998 } kExpectedResults[] = { 1999 } kExpectedResults[] = {
1999 {ClientDownloadResponse::SAFE, DownloadProtectionService::SAFE}, 2000 {ClientDownloadResponse::SAFE, DownloadProtectionService::SAFE},
2000 {ClientDownloadResponse::DANGEROUS, DownloadProtectionService::DANGEROUS}, 2001 {ClientDownloadResponse::DANGEROUS, DownloadProtectionService::DANGEROUS},
2001 {ClientDownloadResponse::UNCOMMON, DownloadProtectionService::UNCOMMON}, 2002 {ClientDownloadResponse::UNCOMMON, DownloadProtectionService::UNCOMMON},
2002 {ClientDownloadResponse::DANGEROUS_HOST, 2003 {ClientDownloadResponse::DANGEROUS_HOST,
2003 DownloadProtectionService::DANGEROUS_HOST}, 2004 DownloadProtectionService::DANGEROUS_HOST},
2004 {ClientDownloadResponse::POTENTIALLY_UNWANTED, 2005 {ClientDownloadResponse::POTENTIALLY_UNWANTED,
2005 DownloadProtectionService::POTENTIALLY_UNWANTED}, 2006 DownloadProtectionService::POTENTIALLY_UNWANTED},
2006 }; 2007 };
2007 2008
2008 for (const auto& test_case : kExpectedResults) { 2009 for (const auto& test_case : kExpectedResults) {
2009 factory.ClearFakeResponses(); 2010 factory.ClearFakeResponses();
2010 PrepareResponse(&factory, test_case.verdict, net::HTTP_OK, 2011 PrepareResponse(&factory, test_case.verdict, net::HTTP_OK,
2011 net::URLRequestStatus::SUCCESS); 2012 net::URLRequestStatus::SUCCESS);
2013 SetExtendedReportingPreference(false);
2012 download_service_->CheckPPAPIDownloadRequest( 2014 download_service_->CheckPPAPIDownloadRequest(
2013 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2015 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2016 profile_.get(),
2014 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2017 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2015 base::Unretained(this))); 2018 base::Unretained(this)));
2016 MessageLoop::current()->Run(); 2019 MessageLoop::current()->Run();
2017 ASSERT_TRUE(IsResult(test_case.expected_result)); 2020 ASSERT_TRUE(IsResult(test_case.expected_result));
2018 } 2021 }
2019 } 2022 }
2020 2023
2021 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedAlternate) { 2024 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_SupportedAlternate) {
2022 net::FakeURLFetcherFactory factory(nullptr); 2025 net::FakeURLFetcherFactory factory(nullptr);
2023 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt")); 2026 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.txt"));
2024 std::vector<base::FilePath::StringType> alternate_extensions{ 2027 std::vector<base::FilePath::StringType> alternate_extensions{
2025 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".crx")}; 2028 FILE_PATH_LITERAL(".tmp"), FILE_PATH_LITERAL(".crx")};
2026 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, 2029 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2027 net::URLRequestStatus::SUCCESS); 2030 net::URLRequestStatus::SUCCESS);
2028 EXPECT_CALL(*sb_service_->mock_database_manager(), 2031 EXPECT_CALL(*sb_service_->mock_database_manager(),
2029 MatchDownloadWhitelistUrl(_)) 2032 MatchDownloadWhitelistUrl(_))
2030 .WillRepeatedly(Return(false)); 2033 .WillRepeatedly(Return(false));
2034 SetExtendedReportingPreference(false);
2031 download_service_->CheckPPAPIDownloadRequest( 2035 download_service_->CheckPPAPIDownloadRequest(
2032 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2036 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2037 profile_.get(),
2033 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2038 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2034 base::Unretained(this))); 2039 base::Unretained(this)));
2035 MessageLoop::current()->Run(); 2040 MessageLoop::current()->Run();
2036 2041
2037 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2042 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2038 } 2043 }
2039 2044
2040 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_WhitelistedURL) { 2045 TEST_F(DownloadProtectionServiceTest,
2046 PPAPIDownloadRequest_WhitelistedURLNotExtendedReporting) {
2041 net::FakeURLFetcherFactory factory(nullptr); 2047 net::FakeURLFetcherFactory factory(nullptr);
2042 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2048 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2043 std::vector<base::FilePath::StringType> alternate_extensions; 2049 std::vector<base::FilePath::StringType> alternate_extensions;
2050 // Configs "server" side response to DANGEROUS, in case a request is send out.
2051 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2052 net::URLRequestStatus::SUCCESS);
2044 EXPECT_CALL(*sb_service_->mock_database_manager(), 2053 EXPECT_CALL(*sb_service_->mock_database_manager(),
2045 MatchDownloadWhitelistUrl(_)) 2054 MatchDownloadWhitelistUrl(_))
2046 .WillRepeatedly(Return(true)); 2055 .WillRepeatedly(Return(true));
2056 SetExtendedReportingPreference(false);
2057 // Sets the sample rate to 1.00.
2058 SetWhitelistedDownloadSampleRate(1.00);
2047 download_service_->CheckPPAPIDownloadRequest( 2059 download_service_->CheckPPAPIDownloadRequest(
2048 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2060 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2061 profile_.get(),
2049 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2062 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2050 base::Unretained(this))); 2063 base::Unretained(this)));
2051 MessageLoop::current()->Run(); 2064 MessageLoop::current()->Run();
2052 2065
2066 // Result should be SAFE, since download matches whitelist but user is not in
2067 // extended reporting group (a.k.a no request sents out).
2053 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE)); 2068 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE));
2054 } 2069 }
2055 2070
2071 TEST_F(DownloadProtectionServiceTest,
2072 PPAPIDownloadRequest_WhitelistedURLIncognito) {
2073 net::FakeURLFetcherFactory factory(nullptr);
2074 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2075 std::vector<base::FilePath::StringType> alternate_extensions;
2076 // Configs "server" side response to DANGEROUS, in case a request is send out.
2077 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2078 net::URLRequestStatus::SUCCESS);
2079 EXPECT_CALL(*sb_service_->mock_database_manager(),
2080 MatchDownloadWhitelistUrl(_))
2081 .WillRepeatedly(Return(true));
2082 SetExtendedReportingPreference(true);
2083 download_service_->CheckPPAPIDownloadRequest(
2084 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2085 profile_->GetOffTheRecordProfile(),
2086 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2087 base::Unretained(this)));
2088 MessageLoop::current()->Run();
2089
2090 // Result should still be SAFE, since download matches whitelist and user is
2091 // in incognito mode.
2092 ASSERT_TRUE(IsResult(DownloadProtectionService::SAFE));
2093 }
2094
2095 TEST_F(DownloadProtectionServiceTest,
2096 PPAPIDownloadRequest_SampleWhitelistedURL) {
2097 net::FakeURLFetcherFactory factory(nullptr);
2098 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2099 std::vector<base::FilePath::StringType> alternate_extensions;
2100 // Configs "server" side response to DANGEROUS.
2101 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2102 net::URLRequestStatus::SUCCESS);
2103 EXPECT_CALL(*sb_service_->mock_database_manager(),
2104 MatchDownloadWhitelistUrl(_))
2105 .WillRepeatedly(Return(true));
2106 // Sets the sample rate to 1.00 to trigger ClientDownloadRequest.
2107 SetWhitelistedDownloadSampleRate(1.00);
2108 SetExtendedReportingPreference(true);
2109 download_service_->CheckPPAPIDownloadRequest(
2110 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2111 profile_.get(),
2112 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2113 base::Unretained(this)));
2114 MessageLoop::current()->Run();
Lei Zhang 2016/07/14 23:56:11 This is deprecated. Use a base::RunLoop instead. S
Jialiu Lin 2016/07/15 01:20:06 Done.
2115
2116 // Result should be Dangerous, since we will sample this download and ping SB
2117 // Server (server returns DANGEROUS verdict).
2118 ASSERT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2119 }
2120
2056 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_FetchFailed) { 2121 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_FetchFailed) {
2057 net::FakeURLFetcherFactory factory(nullptr); 2122 net::FakeURLFetcherFactory factory(nullptr);
2058 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2123 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2059 std::vector<base::FilePath::StringType> alternate_extensions; 2124 std::vector<base::FilePath::StringType> alternate_extensions;
2060 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, 2125 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
2061 net::URLRequestStatus::FAILED); 2126 net::URLRequestStatus::FAILED);
2062 EXPECT_CALL(*sb_service_->mock_database_manager(), 2127 EXPECT_CALL(*sb_service_->mock_database_manager(),
2063 MatchDownloadWhitelistUrl(_)) 2128 MatchDownloadWhitelistUrl(_))
2064 .WillRepeatedly(Return(false)); 2129 .WillRepeatedly(Return(false));
2130 SetExtendedReportingPreference(false);
2065 download_service_->CheckPPAPIDownloadRequest( 2131 download_service_->CheckPPAPIDownloadRequest(
2066 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2132 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2133 profile_.get(),
2067 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2134 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2068 base::Unretained(this))); 2135 base::Unretained(this)));
2069 MessageLoop::current()->Run(); 2136 MessageLoop::current()->Run();
2070 2137
2071 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); 2138 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
2072 } 2139 }
2073 2140
2074 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_InvalidResponse) { 2141 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_InvalidResponse) {
2075 net::FakeURLFetcherFactory factory(nullptr); 2142 net::FakeURLFetcherFactory factory(nullptr);
2076 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2143 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2077 std::vector<base::FilePath::StringType> alternate_extensions; 2144 std::vector<base::FilePath::StringType> alternate_extensions;
2078 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(), 2145 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(),
2079 "Hello world!", net::HTTP_OK, 2146 "Hello world!", net::HTTP_OK,
2080 net::URLRequestStatus::SUCCESS); 2147 net::URLRequestStatus::SUCCESS);
2081 EXPECT_CALL(*sb_service_->mock_database_manager(), 2148 EXPECT_CALL(*sb_service_->mock_database_manager(),
2082 MatchDownloadWhitelistUrl(_)) 2149 MatchDownloadWhitelistUrl(_))
2083 .WillRepeatedly(Return(false)); 2150 .WillRepeatedly(Return(false));
2151 SetExtendedReportingPreference(false);
2084 download_service_->CheckPPAPIDownloadRequest( 2152 download_service_->CheckPPAPIDownloadRequest(
2085 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2153 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2154 profile_.get(),
2086 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2155 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2087 base::Unretained(this))); 2156 base::Unretained(this)));
2088 MessageLoop::current()->Run(); 2157 MessageLoop::current()->Run();
2089 2158
2090 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); 2159 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
2091 } 2160 }
2092 2161
2093 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Timeout) { 2162 TEST_F(DownloadProtectionServiceTest, PPAPIDownloadRequest_Timeout) {
2094 net::FakeURLFetcherFactory factory(nullptr); 2163 net::FakeURLFetcherFactory factory(nullptr);
2095 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2164 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2096 std::vector<base::FilePath::StringType> alternate_extensions; 2165 std::vector<base::FilePath::StringType> alternate_extensions;
2097 EXPECT_CALL(*sb_service_->mock_database_manager(), 2166 EXPECT_CALL(*sb_service_->mock_database_manager(),
2098 MatchDownloadWhitelistUrl(_)) 2167 MatchDownloadWhitelistUrl(_))
2099 .WillRepeatedly(Return(false)); 2168 .WillRepeatedly(Return(false));
2100 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, 2169 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
2101 net::URLRequestStatus::SUCCESS); 2170 net::URLRequestStatus::SUCCESS);
2102 download_service_->download_request_timeout_ms_ = 0; 2171 download_service_->download_request_timeout_ms_ = 0;
2172 SetExtendedReportingPreference(false);
2103 download_service_->CheckPPAPIDownloadRequest( 2173 download_service_->CheckPPAPIDownloadRequest(
2104 GURL("http://example.com/foo"), default_file_path, alternate_extensions, 2174 GURL("http://example.com/foo"), default_file_path, alternate_extensions,
2175 profile_.get(),
2105 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2176 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2106 base::Unretained(this))); 2177 base::Unretained(this)));
2107 MessageLoop::current()->Run(); 2178 MessageLoop::current()->Run();
2108 2179
2109 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); 2180 ASSERT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
2110 } 2181 }
2111 2182
2112 namespace { 2183 namespace {
2113 2184
2114 std::unique_ptr<net::FakeURLFetcher> FakeURLFetcherCreatorFunc( 2185 std::unique_ptr<net::FakeURLFetcher> FakeURLFetcherCreatorFunc(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx")); 2224 base::FilePath default_file_path(FILE_PATH_LITERAL("/foo/bar/test.crx"));
2154 std::vector<base::FilePath::StringType> alternate_extensions{ 2225 std::vector<base::FilePath::StringType> alternate_extensions{
2155 FILE_PATH_LITERAL(".txt"), FILE_PATH_LITERAL(".abc"), 2226 FILE_PATH_LITERAL(".txt"), FILE_PATH_LITERAL(".abc"),
2156 FILE_PATH_LITERAL(""), FILE_PATH_LITERAL(".sdF")}; 2227 FILE_PATH_LITERAL(""), FILE_PATH_LITERAL(".sdF")};
2157 EXPECT_CALL(*sb_service_->mock_database_manager(), 2228 EXPECT_CALL(*sb_service_->mock_database_manager(),
2158 MatchDownloadWhitelistUrl(_)) 2229 MatchDownloadWhitelistUrl(_))
2159 .WillRepeatedly(Return(false)); 2230 .WillRepeatedly(Return(false));
2160 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK, 2231 PrepareResponse(&factory, ClientDownloadResponse::SAFE, net::HTTP_OK,
2161 net::URLRequestStatus::SUCCESS); 2232 net::URLRequestStatus::SUCCESS);
2162 const GURL kRequestorUrl("http://example.com/foo"); 2233 const GURL kRequestorUrl("http://example.com/foo");
2234 SetExtendedReportingPreference(false);
2163 download_service_->CheckPPAPIDownloadRequest( 2235 download_service_->CheckPPAPIDownloadRequest(
2164 kRequestorUrl, default_file_path, alternate_extensions, 2236 kRequestorUrl, default_file_path, alternate_extensions, profile_.get(),
2165 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2237 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2166 base::Unretained(this))); 2238 base::Unretained(this)));
2167 MessageLoop::current()->Run(); 2239 MessageLoop::current()->Run();
2168 2240
2169 ASSERT_FALSE(upload_data.empty()); 2241 ASSERT_FALSE(upload_data.empty());
2170 2242
2171 ClientDownloadRequest request; 2243 ClientDownloadRequest request;
2172 ASSERT_TRUE(request.ParseFromString(upload_data)); 2244 ASSERT_TRUE(request.ParseFromString(upload_data));
2173 2245
2174 EXPECT_EQ(ClientDownloadRequest::PPAPI_SAVE_REQUEST, request.download_type()); 2246 EXPECT_EQ(ClientDownloadRequest::PPAPI_SAVE_REQUEST, request.download_type());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2327 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2256 base::Unretained(this))); 2328 base::Unretained(this)));
2257 MessageLoop::current()->Run(); 2329 MessageLoop::current()->Run();
2258 2330
2259 EXPECT_FALSE(HasClientDownloadRequest()); 2331 EXPECT_FALSE(HasClientDownloadRequest());
2260 // Overriden by flag: 2332 // Overriden by flag:
2261 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2333 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2262 } 2334 }
2263 2335
2264 } // namespace safe_browsing 2336 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698