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

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

Issue 1911543002: Bug fix in sampling whitelisted download. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 9
10 #include <map> 10 #include <map>
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // Set sample rate to 0 to prevent sampling. 655 // Set sample rate to 0 to prevent sampling.
656 SetWhitelistedDownloadSampleRate(0); 656 SetWhitelistedDownloadSampleRate(0);
657 download_service_->CheckClientDownload( 657 download_service_->CheckClientDownload(
658 &item, 658 &item,
659 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 659 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
660 base::Unretained(this))); 660 base::Unretained(this)));
661 MessageLoop::current()->Run(); 661 MessageLoop::current()->Run();
662 662
663 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 663 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
664 EXPECT_TRUE(HasClientDownloadRequest()); 664 EXPECT_TRUE(HasClientDownloadRequest());
665 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
666 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
665 ClearClientDownloadRequest(); 667 ClearClientDownloadRequest();
666 668
667 // Check that the referrer is not matched against the whitelist. 669 // Check that the referrer is not matched against the whitelist.
668 referrer_ = GURL("http://www.google.com/"); 670 referrer_ = GURL("http://www.google.com/");
669 download_service_->CheckClientDownload( 671 download_service_->CheckClientDownload(
670 &item, 672 &item,
671 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 673 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
672 base::Unretained(this))); 674 base::Unretained(this)));
673 MessageLoop::current()->Run(); 675 MessageLoop::current()->Run();
674 676
675 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 677 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
676 EXPECT_TRUE(HasClientDownloadRequest()); 678 EXPECT_TRUE(HasClientDownloadRequest());
679 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
680 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
677 ClearClientDownloadRequest(); 681 ClearClientDownloadRequest();
678 682
679 // Redirect from a site shouldn't be checked either. 683 // Redirect from a site shouldn't be checked either.
680 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect")); 684 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect"));
681 download_service_->CheckClientDownload( 685 download_service_->CheckClientDownload(
682 &item, 686 &item,
683 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 687 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
684 base::Unretained(this))); 688 base::Unretained(this)));
685 MessageLoop::current()->Run(); 689 MessageLoop::current()->Run();
686 690
687 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 691 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
688 EXPECT_TRUE(HasClientDownloadRequest()); 692 EXPECT_TRUE(HasClientDownloadRequest());
693 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
694 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
689 ClearClientDownloadRequest(); 695 ClearClientDownloadRequest();
690 696
691 // Only if the final url is whitelisted should it be SAFE. 697 // Only if the final url is whitelisted should it be SAFE.
692 url_chain_.push_back(GURL("http://www.google.com/a.exe")); 698 url_chain_.push_back(GURL("http://www.google.com/a.exe"));
693 download_service_->CheckClientDownload( 699 download_service_->CheckClientDownload(
694 &item, 700 &item,
695 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 701 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
696 base::Unretained(this))); 702 base::Unretained(this)));
697 MessageLoop::current()->Run(); 703 MessageLoop::current()->Run();
698 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); 704 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1913 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1908 base::Unretained(this))); 1914 base::Unretained(this)));
1909 MessageLoop::current()->Run(); 1915 MessageLoop::current()->Run();
1910 1916
1911 EXPECT_FALSE(HasClientDownloadRequest()); 1917 EXPECT_FALSE(HasClientDownloadRequest());
1912 // Overriden by flag: 1918 // Overriden by flag:
1913 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 1919 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
1914 } 1920 }
1915 1921
1916 } // namespace safe_browsing 1922 } // 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