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

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

Issue 1918353002: 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());
649 ClearClientDownloadRequest(); 651 ClearClientDownloadRequest();
650 652
651 // Check that the referrer is not matched against the whitelist. 653 // Check that the referrer is not matched against the whitelist.
652 referrer_ = GURL("http://www.google.com/"); 654 referrer_ = GURL("http://www.google.com/");
653 download_service_->CheckClientDownload( 655 download_service_->CheckClientDownload(
654 &item, 656 &item,
655 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 657 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
656 base::Unretained(this))); 658 base::Unretained(this)));
657 MessageLoop::current()->Run(); 659 MessageLoop::current()->Run();
658 660
659 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 661 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
660 EXPECT_TRUE(HasClientDownloadRequest()); 662 EXPECT_TRUE(HasClientDownloadRequest());
663 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
664 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
661 ClearClientDownloadRequest(); 665 ClearClientDownloadRequest();
662 666
663 // Redirect from a site shouldn't be checked either. 667 // Redirect from a site shouldn't be checked either.
664 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect")); 668 url_chain_.insert(url_chain_.begin(), GURL("http://www.google.com/redirect"));
665 download_service_->CheckClientDownload( 669 download_service_->CheckClientDownload(
666 &item, 670 &item,
667 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 671 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
668 base::Unretained(this))); 672 base::Unretained(this)));
669 MessageLoop::current()->Run(); 673 MessageLoop::current()->Run();
670 674
671 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 675 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
672 EXPECT_TRUE(HasClientDownloadRequest()); 676 EXPECT_TRUE(HasClientDownloadRequest());
677 EXPECT_FALSE(GetClientDownloadRequest()->skipped_url_whitelist());
678 EXPECT_FALSE(GetClientDownloadRequest()->skipped_certificate_whitelist());
673 ClearClientDownloadRequest(); 679 ClearClientDownloadRequest();
674 680
675 // Only if the final url is whitelisted should it be SAFE. 681 // Only if the final url is whitelisted should it be SAFE.
676 url_chain_.push_back(GURL("http://www.google.com/a.exe")); 682 url_chain_.push_back(GURL("http://www.google.com/a.exe"));
677 download_service_->CheckClientDownload( 683 download_service_->CheckClientDownload(
678 &item, 684 &item,
679 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 685 base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
680 base::Unretained(this))); 686 base::Unretained(this)));
681 MessageLoop::current()->Run(); 687 MessageLoop::current()->Run();
682 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); 688 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1910 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1905 base::Unretained(this))); 1911 base::Unretained(this)));
1906 MessageLoop::current()->Run(); 1912 MessageLoop::current()->Run();
1907 1913
1908 EXPECT_FALSE(HasClientDownloadRequest()); 1914 EXPECT_FALSE(HasClientDownloadRequest());
1909 // Overriden by flag: 1915 // Overriden by flag:
1910 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 1916 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
1911 } 1917 }
1912 1918
1913 } // namespace safe_browsing 1919 } // 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