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

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

Issue 12087095: Sync csd.proto with server-side version. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing comma Created 7 years, 10 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 | Annotate | Revision Log
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 <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 399
400 DownloadProtectionService::DownloadInfo info; 400 DownloadProtectionService::DownloadInfo info;
401 info.local_file = FilePath(FILE_PATH_LITERAL("a.tmp")); 401 info.local_file = FilePath(FILE_PATH_LITERAL("a.tmp"));
402 info.target_file = FilePath(FILE_PATH_LITERAL("a.exe")); 402 info.target_file = FilePath(FILE_PATH_LITERAL("a.exe"));
403 info.download_url_chain.push_back(GURL("http://www.evil.com/a.exe")); 403 info.download_url_chain.push_back(GURL("http://www.evil.com/a.exe"));
404 info.referrer_url = GURL("http://www.google.com/"); 404 info.referrer_url = GURL("http://www.google.com/");
405 405
406 EXPECT_CALL(*sb_service_->mock_database_manager(), 406 EXPECT_CALL(*sb_service_->mock_database_manager(),
407 MatchDownloadWhitelistUrl(_)) 407 MatchDownloadWhitelistUrl(_))
408 .WillRepeatedly(Return(false)); 408 .WillRepeatedly(Return(false));
409 EXPECT_CALL(*signature_util_, CheckSignature(info.local_file, _)).Times(4); 409 EXPECT_CALL(*signature_util_, CheckSignature(info.local_file, _)).Times(5);
410 410
411 download_service_->CheckClientDownload( 411 download_service_->CheckClientDownload(
412 info, 412 info,
413 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 413 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
414 base::Unretained(this))); 414 base::Unretained(this)));
415 msg_loop_.Run(); 415 msg_loop_.Run();
416 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); 416 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
417 417
418 // Invalid response should be safe too. 418 // Invalid response should be safe too.
419 response.Clear(); 419 response.Clear();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 download_service_->CheckClientDownload( 457 download_service_->CheckClientDownload(
458 info, 458 info,
459 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 459 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
460 base::Unretained(this))); 460 base::Unretained(this)));
461 msg_loop_.Run(); 461 msg_loop_.Run();
462 #if defined(OS_WIN) 462 #if defined(OS_WIN)
463 EXPECT_TRUE(IsResult(DownloadProtectionService::UNCOMMON)); 463 EXPECT_TRUE(IsResult(DownloadProtectionService::UNCOMMON));
464 #else 464 #else
465 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); 465 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
466 #endif 466 #endif
467
468 // If the response is dangerous_host the result should also be marked as
469 // dangerous_host.
470 response.set_verdict(ClientDownloadResponse::DANGEROUS_HOST);
471 factory.SetFakeResponse(
472 DownloadProtectionService::GetDownloadRequestUrl(),
473 response.SerializeAsString(),
474 true);
475
476 download_service_->CheckClientDownload(
477 info,
478 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
479 base::Unretained(this)));
480 msg_loop_.Run();
481 #if defined(OS_WIN)
482 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS_HOST));
483 #else
484 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
485 #endif
467 } 486 }
468 487
469 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) { 488 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) {
470 ClientDownloadResponse response; 489 ClientDownloadResponse response;
471 response.set_verdict(ClientDownloadResponse::DANGEROUS); 490 response.set_verdict(ClientDownloadResponse::DANGEROUS);
472 net::FakeURLFetcherFactory factory; 491 net::FakeURLFetcherFactory factory;
473 factory.SetFakeResponse( 492 factory.SetFakeResponse(
474 DownloadProtectionService::GetDownloadRequestUrl(), 493 DownloadProtectionService::GetDownloadRequestUrl(),
475 response.SerializeAsString(), 494 response.SerializeAsString(),
476 true); 495 true);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); 936 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings);
918 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit")); 937 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit"));
919 938
920 cert = ReadTestCertificate("test_c.pem"); 939 cert = ReadTestCertificate("test_c.pem");
921 ASSERT_TRUE(cert.get()); 940 ASSERT_TRUE(cert.get());
922 whitelist_strings.clear(); 941 whitelist_strings.clear();
923 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings); 942 GetCertificateWhitelistStrings(*cert, *issuer_cert, &whitelist_strings);
924 EXPECT_THAT(whitelist_strings, ElementsAre()); 943 EXPECT_THAT(whitelist_strings, ElementsAre());
925 } 944 }
926 } // namespace safe_browsing 945 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | chrome/browser/ui/webui/downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698