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

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

Issue 1923033002: Revert of Bug fix in sampling whitelisted download. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 8 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
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // Set sample rate to 0 to prevent sampling. 639 // Set sample rate to 0 to prevent sampling.
640 SetWhitelistedDownloadSampleRate(0); 640 SetWhitelistedDownloadSampleRate(0);
641 download_service_->CheckClientDownload( 641 download_service_->CheckClientDownload(
642 &item, 642 &item,
643 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 643 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
644 base::Unretained(this))); 644 base::Unretained(this)));
645 MessageLoop::current()->Run(); 645 MessageLoop::current()->Run();
646 646
647 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 647 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
648 EXPECT_TRUE(HasClientDownloadRequest()); 648 EXPECT_TRUE(HasClientDownloadRequest());
649 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
650 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
651 ClearClientDownloadRequest(); 649 ClearClientDownloadRequest();
652 650
653 // Check that the referrer is not matched against the whitelist. 651 // Check that the referrer is not matched against the whitelist.
654 referrer_ = GURL("http://www.google.com/"); 652 referrer_ = GURL("http://www.google.com/");
655 download_service_->CheckClientDownload( 653 download_service_->CheckClientDownload(
656 &item, 654 &item,
657 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 655 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
658 base::Unretained(this))); 656 base::Unretained(this)));
659 MessageLoop::current()->Run(); 657 MessageLoop::current()->Run();
660 658
661 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 659 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
662 EXPECT_TRUE(HasClientDownloadRequest()); 660 EXPECT_TRUE(HasClientDownloadRequest());
663 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
664 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
665 ClearClientDownloadRequest(); 661 ClearClientDownloadRequest();
666 662
667 // Redirect from a site shouldn't be checked either. 663 // Redirect from a site shouldn't be checked either.
668 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect")); 664 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect"));
669 download_service_->CheckClientDownload( 665 download_service_->CheckClientDownload(
670 &item, 666 &item,
671 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 667 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
672 base::Unretained(this))); 668 base::Unretained(this)));
673 MessageLoop::current()->Run(); 669 MessageLoop::current()->Run();
674 670
675 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 671 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
676 EXPECT_TRUE(HasClientDownloadRequest()); 672 EXPECT_TRUE(HasClientDownloadRequest());
677 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
678 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
679 ClearClientDownloadRequest(); 673 ClearClientDownloadRequest();
680 674
681 // Only if the final url is whitelisted should it be SAFE. 675 // Only if the final url is whitelisted should it be SAFE.
682 url_chain_.push_back(GURL("http://www.google.com/a.exe")); 676 url_chain_.push_back(GURL("http://www.google.com/a.exe"));
683 download_service_->CheckClientDownload( 677 download_service_->CheckClientDownload(
684 &item, 678 &item,
685 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 679 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
686 base::Unretained(this))); 680 base::Unretained(this)));
687 MessageLoop::current()->Run(); 681 MessageLoop::current()->Run();
688 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); 682 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1904 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1911 base::Unretained(this))); 1905 base::Unretained(this)));
1912 MessageLoop::current()->Run(); 1906 MessageLoop::current()->Run();
1913 1907
1914 EXPECT_FALSE(HasClientDownloadRequest()); 1908 EXPECT_FALSE(HasClientDownloadRequest());
1915 // Overriden by flag: 1909 // Overriden by flag:
1916 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 1910 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
1917 } 1911 }
1918 1912
1919 } // namespace safe_browsing 1913 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698