OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
23 #include "chrome/browser/safe_browsing/database_manager.h" | 23 #include "chrome/browser/safe_browsing/database_manager.h" |
24 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 24 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
26 #include "chrome/browser/safe_browsing/signature_util.h" | 26 #include "chrome/browser/safe_browsing/signature_util.h" |
27 #include "chrome/common/safe_browsing/csd.pb.h" | 27 #include "chrome/common/safe_browsing/csd.pb.h" |
28 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
29 #include "content/public/test/mock_download_item.h" | 29 #include "content/public/test/mock_download_item.h" |
30 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
31 #include "net/cert/x509_certificate.h" | 31 #include "net/cert/x509_certificate.h" |
| 32 #include "net/http/http_status_code.h" |
32 #include "net/url_request/test_url_fetcher_factory.h" | 33 #include "net/url_request/test_url_fetcher_factory.h" |
33 #include "net/url_request/url_fetcher_delegate.h" | 34 #include "net/url_request/url_fetcher_delegate.h" |
34 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
36 #include "third_party/zlib/google/zip.h" | 37 #include "third_party/zlib/google/zip.h" |
37 #include "url/gurl.h" | 38 #include "url/gurl.h" |
38 | 39 |
39 using ::testing::Assign; | 40 using ::testing::Assign; |
40 using ::testing::ContainerEq; | 41 using ::testing::ContainerEq; |
41 using ::testing::DoAll; | 42 using ::testing::DoAll; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 394 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
394 base::Unretained(this))); | 395 base::Unretained(this))); |
395 MessageLoop::current()->Run(); | 396 MessageLoop::current()->Run(); |
396 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 397 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
397 } | 398 } |
398 | 399 |
399 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadFetchFailed) { | 400 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadFetchFailed) { |
400 net::FakeURLFetcherFactory factory(NULL); | 401 net::FakeURLFetcherFactory factory(NULL); |
401 // HTTP request will fail. | 402 // HTTP request will fail. |
402 factory.SetFakeResponse( | 403 factory.SetFakeResponse( |
403 DownloadProtectionService::GetDownloadRequestUrl(), std::string(), false); | 404 DownloadProtectionService::GetDownloadRequestUrl(), |
| 405 std::string(), |
| 406 net::HTTP_INTERNAL_SERVER_ERROR); |
404 | 407 |
405 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); | 408 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); |
406 base::FilePath a_exe(FILE_PATH_LITERAL("a.exe")); | 409 base::FilePath a_exe(FILE_PATH_LITERAL("a.exe")); |
407 std::vector<GURL> url_chain; | 410 std::vector<GURL> url_chain; |
408 url_chain.push_back(GURL("http://www.evil.com/a.exe")); | 411 url_chain.push_back(GURL("http://www.evil.com/a.exe")); |
409 GURL referrer("http://www.google.com/"); | 412 GURL referrer("http://www.google.com/"); |
410 std::string hash = "hash"; | 413 std::string hash = "hash"; |
411 | 414 |
412 content::MockDownloadItem item; | 415 content::MockDownloadItem item; |
413 EXPECT_CALL(item, AddObserver(_)); | 416 EXPECT_CALL(item, AddObserver(_)); |
(...skipping 21 matching lines...) Expand all Loading... |
435 } | 438 } |
436 | 439 |
437 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { | 440 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { |
438 ClientDownloadResponse response; | 441 ClientDownloadResponse response; |
439 response.set_verdict(ClientDownloadResponse::SAFE); | 442 response.set_verdict(ClientDownloadResponse::SAFE); |
440 net::FakeURLFetcherFactory factory(NULL); | 443 net::FakeURLFetcherFactory factory(NULL); |
441 // Empty response means SAFE. | 444 // Empty response means SAFE. |
442 factory.SetFakeResponse( | 445 factory.SetFakeResponse( |
443 DownloadProtectionService::GetDownloadRequestUrl(), | 446 DownloadProtectionService::GetDownloadRequestUrl(), |
444 response.SerializeAsString(), | 447 response.SerializeAsString(), |
445 true); | 448 net::HTTP_OK); |
446 | 449 |
447 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); | 450 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); |
448 base::FilePath a_exe(FILE_PATH_LITERAL("a.exe")); | 451 base::FilePath a_exe(FILE_PATH_LITERAL("a.exe")); |
449 std::vector<GURL> url_chain; | 452 std::vector<GURL> url_chain; |
450 url_chain.push_back(GURL("http://www.evil.com/a.exe")); | 453 url_chain.push_back(GURL("http://www.evil.com/a.exe")); |
451 GURL referrer("http://www.google.com/"); | 454 GURL referrer("http://www.google.com/"); |
452 std::string hash = "hash"; | 455 std::string hash = "hash"; |
453 | 456 |
454 content::MockDownloadItem item; | 457 content::MockDownloadItem item; |
455 EXPECT_CALL(item, AddObserver(_)).Times(6); | 458 EXPECT_CALL(item, AddObserver(_)).Times(6); |
(...skipping 17 matching lines...) Expand all Loading... |
473 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 476 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
474 base::Unretained(this))); | 477 base::Unretained(this))); |
475 MessageLoop::current()->Run(); | 478 MessageLoop::current()->Run(); |
476 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 479 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
477 | 480 |
478 // Invalid response should be safe too. | 481 // Invalid response should be safe too. |
479 response.Clear(); | 482 response.Clear(); |
480 factory.SetFakeResponse( | 483 factory.SetFakeResponse( |
481 DownloadProtectionService::GetDownloadRequestUrl(), | 484 DownloadProtectionService::GetDownloadRequestUrl(), |
482 response.SerializePartialAsString(), | 485 response.SerializePartialAsString(), |
483 true); | 486 net::HTTP_OK); |
484 | 487 |
485 download_service_->CheckClientDownload( | 488 download_service_->CheckClientDownload( |
486 &item, | 489 &item, |
487 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 490 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
488 base::Unretained(this))); | 491 base::Unretained(this))); |
489 MessageLoop::current()->Run(); | 492 MessageLoop::current()->Run(); |
490 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 493 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
491 std::string feedback_ping; | 494 std::string feedback_ping; |
492 std::string feedback_response; | 495 std::string feedback_response; |
493 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting( | 496 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting( |
494 item, &feedback_ping, &feedback_response)); | 497 item, &feedback_ping, &feedback_response)); |
495 | 498 |
496 // If the response is dangerous the result should also be marked as dangerous. | 499 // If the response is dangerous the result should also be marked as dangerous. |
497 response.set_verdict(ClientDownloadResponse::DANGEROUS); | 500 response.set_verdict(ClientDownloadResponse::DANGEROUS); |
498 factory.SetFakeResponse( | 501 factory.SetFakeResponse( |
499 DownloadProtectionService::GetDownloadRequestUrl(), | 502 DownloadProtectionService::GetDownloadRequestUrl(), |
500 response.SerializeAsString(), | 503 response.SerializeAsString(), |
501 true); | 504 net::HTTP_OK); |
502 | 505 |
503 download_service_->CheckClientDownload( | 506 download_service_->CheckClientDownload( |
504 &item, | 507 &item, |
505 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 508 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
506 base::Unretained(this))); | 509 base::Unretained(this))); |
507 MessageLoop::current()->Run(); | 510 MessageLoop::current()->Run(); |
508 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting( | 511 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting( |
509 item, &feedback_ping, &feedback_response)); | 512 item, &feedback_ping, &feedback_response)); |
510 #if defined(OS_WIN) | 513 #if defined(OS_WIN) |
511 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 514 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
512 #else | 515 #else |
513 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 516 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
514 #endif | 517 #endif |
515 | 518 |
516 // If the response is uncommon the result should also be marked as uncommon. | 519 // If the response is uncommon the result should also be marked as uncommon. |
517 response.set_verdict(ClientDownloadResponse::UNCOMMON); | 520 response.set_verdict(ClientDownloadResponse::UNCOMMON); |
518 factory.SetFakeResponse( | 521 factory.SetFakeResponse( |
519 DownloadProtectionService::GetDownloadRequestUrl(), | 522 DownloadProtectionService::GetDownloadRequestUrl(), |
520 response.SerializeAsString(), | 523 response.SerializeAsString(), |
521 true); | 524 net::HTTP_OK); |
522 | 525 |
523 download_service_->CheckClientDownload( | 526 download_service_->CheckClientDownload( |
524 &item, | 527 &item, |
525 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 528 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
526 base::Unretained(this))); | 529 base::Unretained(this))); |
527 MessageLoop::current()->Run(); | 530 MessageLoop::current()->Run(); |
528 #if defined(OS_WIN) | 531 #if defined(OS_WIN) |
529 EXPECT_TRUE(IsResult(DownloadProtectionService::UNCOMMON)); | 532 EXPECT_TRUE(IsResult(DownloadProtectionService::UNCOMMON)); |
530 EXPECT_TRUE(DownloadFeedbackService::GetPingsForDownloadForTesting( | 533 EXPECT_TRUE(DownloadFeedbackService::GetPingsForDownloadForTesting( |
531 item, &feedback_ping, &feedback_response)); | 534 item, &feedback_ping, &feedback_response)); |
532 ClientDownloadRequest decoded_request; | 535 ClientDownloadRequest decoded_request; |
533 EXPECT_TRUE(decoded_request.ParseFromString(feedback_ping)); | 536 EXPECT_TRUE(decoded_request.ParseFromString(feedback_ping)); |
534 EXPECT_EQ(url_chain.back().spec(), decoded_request.url()); | 537 EXPECT_EQ(url_chain.back().spec(), decoded_request.url()); |
535 EXPECT_EQ(response.SerializeAsString(), feedback_response); | 538 EXPECT_EQ(response.SerializeAsString(), feedback_response); |
536 #else | 539 #else |
537 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 540 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
538 #endif | 541 #endif |
539 | 542 |
540 // If the response is dangerous_host the result should also be marked as | 543 // If the response is dangerous_host the result should also be marked as |
541 // dangerous_host. | 544 // dangerous_host. |
542 response.set_verdict(ClientDownloadResponse::DANGEROUS_HOST); | 545 response.set_verdict(ClientDownloadResponse::DANGEROUS_HOST); |
543 factory.SetFakeResponse( | 546 factory.SetFakeResponse( |
544 DownloadProtectionService::GetDownloadRequestUrl(), | 547 DownloadProtectionService::GetDownloadRequestUrl(), |
545 response.SerializeAsString(), | 548 response.SerializeAsString(), |
546 true); | 549 net::HTTP_OK); |
547 | 550 |
548 download_service_->CheckClientDownload( | 551 download_service_->CheckClientDownload( |
549 &item, | 552 &item, |
550 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 553 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
551 base::Unretained(this))); | 554 base::Unretained(this))); |
552 MessageLoop::current()->Run(); | 555 MessageLoop::current()->Run(); |
553 #if defined(OS_WIN) | 556 #if defined(OS_WIN) |
554 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS_HOST)); | 557 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS_HOST)); |
555 EXPECT_TRUE(DownloadFeedbackService::GetPingsForDownloadForTesting( | 558 EXPECT_TRUE(DownloadFeedbackService::GetPingsForDownloadForTesting( |
556 item, &feedback_ping, &feedback_response)); | 559 item, &feedback_ping, &feedback_response)); |
557 EXPECT_EQ(response.SerializeAsString(), feedback_response); | 560 EXPECT_EQ(response.SerializeAsString(), feedback_response); |
558 #else | 561 #else |
559 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 562 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
560 #endif | 563 #endif |
561 | 564 |
562 // If the response is POTENTIALLY_UNWANTED the result should also be marked as | 565 // If the response is POTENTIALLY_UNWANTED the result should also be marked as |
563 // POTENTIALLY_UNWANTED. | 566 // POTENTIALLY_UNWANTED. |
564 response.set_verdict(ClientDownloadResponse::POTENTIALLY_UNWANTED); | 567 response.set_verdict(ClientDownloadResponse::POTENTIALLY_UNWANTED); |
565 factory.SetFakeResponse( | 568 factory.SetFakeResponse( |
566 DownloadProtectionService::GetDownloadRequestUrl(), | 569 DownloadProtectionService::GetDownloadRequestUrl(), |
567 response.SerializeAsString(), | 570 response.SerializeAsString(), |
568 true); | 571 net::HTTP_OK); |
569 | 572 |
570 download_service_->CheckClientDownload( | 573 download_service_->CheckClientDownload( |
571 &item, | 574 &item, |
572 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 575 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
573 base::Unretained(this))); | 576 base::Unretained(this))); |
574 MessageLoop::current()->Run(); | 577 MessageLoop::current()->Run(); |
575 #if defined(OS_WIN) | 578 #if defined(OS_WIN) |
576 EXPECT_TRUE(IsResult(DownloadProtectionService::POTENTIALLY_UNWANTED)); | 579 EXPECT_TRUE(IsResult(DownloadProtectionService::POTENTIALLY_UNWANTED)); |
577 #else | 580 #else |
578 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 581 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
579 #endif | 582 #endif |
580 } | 583 } |
581 | 584 |
582 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) { | 585 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) { |
583 ClientDownloadResponse response; | 586 ClientDownloadResponse response; |
584 response.set_verdict(ClientDownloadResponse::DANGEROUS); | 587 response.set_verdict(ClientDownloadResponse::DANGEROUS); |
585 net::FakeURLFetcherFactory factory(NULL); | 588 net::FakeURLFetcherFactory factory(NULL); |
586 factory.SetFakeResponse( | 589 factory.SetFakeResponse( |
587 DownloadProtectionService::GetDownloadRequestUrl(), | 590 DownloadProtectionService::GetDownloadRequestUrl(), |
588 response.SerializeAsString(), | 591 response.SerializeAsString(), |
589 true); | 592 net::HTTP_OK); |
590 | 593 |
591 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); | 594 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); |
592 base::FilePath a_exe(FILE_PATH_LITERAL("a.exe")); | 595 base::FilePath a_exe(FILE_PATH_LITERAL("a.exe")); |
593 std::vector<GURL> url_chain; | 596 std::vector<GURL> url_chain; |
594 url_chain.push_back(GURL("http://www.evil.com/a.exe")); | 597 url_chain.push_back(GURL("http://www.evil.com/a.exe")); |
595 GURL referrer("http://www.google.com/"); | 598 GURL referrer("http://www.google.com/"); |
596 std::string hash = "hash"; | 599 std::string hash = "hash"; |
597 | 600 |
598 content::MockDownloadItem item; | 601 content::MockDownloadItem item; |
599 EXPECT_CALL(item, AddObserver(_)).Times(1); | 602 EXPECT_CALL(item, AddObserver(_)).Times(1); |
(...skipping 25 matching lines...) Expand all Loading... |
625 } | 628 } |
626 | 629 |
627 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) { | 630 TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) { |
628 ClientDownloadResponse response; | 631 ClientDownloadResponse response; |
629 response.set_verdict(ClientDownloadResponse::SAFE); | 632 response.set_verdict(ClientDownloadResponse::SAFE); |
630 net::FakeURLFetcherFactory factory(NULL); | 633 net::FakeURLFetcherFactory factory(NULL); |
631 // Empty response means SAFE. | 634 // Empty response means SAFE. |
632 factory.SetFakeResponse( | 635 factory.SetFakeResponse( |
633 DownloadProtectionService::GetDownloadRequestUrl(), | 636 DownloadProtectionService::GetDownloadRequestUrl(), |
634 response.SerializeAsString(), | 637 response.SerializeAsString(), |
635 true); | 638 net::HTTP_OK); |
636 | 639 |
637 base::ScopedTempDir download_dir; | 640 base::ScopedTempDir download_dir; |
638 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); | 641 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); |
639 | 642 |
640 base::FilePath a_tmp(download_dir.path().Append(FILE_PATH_LITERAL("a.tmp"))); | 643 base::FilePath a_tmp(download_dir.path().Append(FILE_PATH_LITERAL("a.tmp"))); |
641 base::FilePath a_zip(FILE_PATH_LITERAL("a.zip")); | 644 base::FilePath a_zip(FILE_PATH_LITERAL("a.zip")); |
642 std::vector<GURL> url_chain; | 645 std::vector<GURL> url_chain; |
643 url_chain.push_back(GURL("http://www.evil.com/a.zip")); | 646 url_chain.push_back(GURL("http://www.evil.com/a.zip")); |
644 GURL referrer("http://www.google.com/"); | 647 GURL referrer("http://www.google.com/"); |
645 std::string hash = "hash"; | 648 std::string hash = "hash"; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 MessageLoop::current()->Run(); | 695 MessageLoop::current()->Run(); |
693 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 696 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
694 Mock::VerifyAndClearExpectations(signature_util_.get()); | 697 Mock::VerifyAndClearExpectations(signature_util_.get()); |
695 | 698 |
696 // If the response is dangerous the result should also be marked as | 699 // If the response is dangerous the result should also be marked as |
697 // dangerous. | 700 // dangerous. |
698 response.set_verdict(ClientDownloadResponse::DANGEROUS); | 701 response.set_verdict(ClientDownloadResponse::DANGEROUS); |
699 factory.SetFakeResponse( | 702 factory.SetFakeResponse( |
700 DownloadProtectionService::GetDownloadRequestUrl(), | 703 DownloadProtectionService::GetDownloadRequestUrl(), |
701 response.SerializeAsString(), | 704 response.SerializeAsString(), |
702 true); | 705 net::HTTP_OK); |
703 | 706 |
704 download_service_->CheckClientDownload( | 707 download_service_->CheckClientDownload( |
705 &item, | 708 &item, |
706 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, | 709 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
707 base::Unretained(this))); | 710 base::Unretained(this))); |
708 MessageLoop::current()->Run(); | 711 MessageLoop::current()->Run(); |
709 #if defined(OS_WIN) | 712 #if defined(OS_WIN) |
710 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); | 713 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
711 #else | 714 #else |
712 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); | 715 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 ClientDownloadResponse response; | 758 ClientDownloadResponse response; |
756 // Even if the server verdict is dangerous we should return SAFE because | 759 // Even if the server verdict is dangerous we should return SAFE because |
757 // DownloadProtectionService::IsSupportedDownload() will return false | 760 // DownloadProtectionService::IsSupportedDownload() will return false |
758 // for crx downloads. | 761 // for crx downloads. |
759 response.set_verdict(ClientDownloadResponse::DANGEROUS); | 762 response.set_verdict(ClientDownloadResponse::DANGEROUS); |
760 net::FakeURLFetcherFactory factory(NULL); | 763 net::FakeURLFetcherFactory factory(NULL); |
761 // Empty response means SAFE. | 764 // Empty response means SAFE. |
762 factory.SetFakeResponse( | 765 factory.SetFakeResponse( |
763 DownloadProtectionService::GetDownloadRequestUrl(), | 766 DownloadProtectionService::GetDownloadRequestUrl(), |
764 response.SerializeAsString(), | 767 response.SerializeAsString(), |
765 true); | 768 net::HTTP_OK); |
766 | 769 |
767 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); | 770 base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp")); |
768 base::FilePath a_crx(FILE_PATH_LITERAL("a.crx")); | 771 base::FilePath a_crx(FILE_PATH_LITERAL("a.crx")); |
769 std::vector<GURL> url_chain; | 772 std::vector<GURL> url_chain; |
770 url_chain.push_back(GURL("http://www.evil.com/a.crx")); | 773 url_chain.push_back(GURL("http://www.evil.com/a.crx")); |
771 GURL referrer("http://www.google.com/"); | 774 GURL referrer("http://www.google.com/"); |
772 std::string hash = "hash"; | 775 std::string hash = "hash"; |
773 | 776 |
774 content::MockDownloadItem item; | 777 content::MockDownloadItem item; |
775 EXPECT_CALL(item, AddObserver(_)).Times(1); | 778 EXPECT_CALL(item, AddObserver(_)).Times(1); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit")); | 1170 EXPECT_THAT(whitelist_strings, ElementsAre(cert_base + "/OU=unit")); |
1168 | 1171 |
1169 cert = ReadTestCertificate("test_c.pem"); | 1172 cert = ReadTestCertificate("test_c.pem"); |
1170 ASSERT_TRUE(cert.get()); | 1173 ASSERT_TRUE(cert.get()); |
1171 whitelist_strings.clear(); | 1174 whitelist_strings.clear(); |
1172 GetCertificateWhitelistStrings( | 1175 GetCertificateWhitelistStrings( |
1173 *cert.get(), *issuer_cert.get(), &whitelist_strings); | 1176 *cert.get(), *issuer_cert.get(), &whitelist_strings); |
1174 EXPECT_THAT(whitelist_strings, ElementsAre()); | 1177 EXPECT_THAT(whitelist_strings, ElementsAre()); |
1175 } | 1178 } |
1176 } // namespace safe_browsing | 1179 } // namespace safe_browsing |
OLD | NEW |