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

Unified Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 8790006: Add download server IP address to the SafeBrowsing download protection ping. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/download_protection_service_unittest.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index 01845d0d1aaba254c258de6cf04590e08d106e15..ae7f52a514e8a496e69eb71408b34ef8859fd3fd 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -173,6 +173,21 @@ class DownloadProtectionServiceTest : public testing::Test {
return false;
}
+ // At this point we only set the server IP for the download itself.
+ bool RequestContainsServerIp(const ClientDownloadRequest& request,
+ const std::string& remote_address) {
+ for (int i = 0; i < request.resources_size(); ++i) {
+ // We want the last DOWNLOAD_URL in the chain.
+ if (request.resources(i).type() == ClientDownloadRequest::DOWNLOAD_URL &&
+ (i + 1 == request.resources_size() ||
+ request.resources(i + 1).type() !=
+ ClientDownloadRequest::DOWNLOAD_URL)) {
+ return remote_address == request.resources(i).remote_ip();
+ }
+ }
+ return false;
+ }
+
// Flushes any pending tasks in the message loops of all threads.
void FlushThreadMessageLoops() {
FlushMessageLoop(BrowserThread::FILE);
@@ -406,7 +421,8 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadValidateRequest) {
info.referrer_url = GURL("http://www.google.com/");
info.sha256_hash = "hash";
info.total_bytes = 100;
- info.user_initiated = false;
+ info.user_initiated = true;
+ info.remote_address = "10.11.12.13";
EXPECT_CALL(*sb_service_, MatchDownloadWhitelistUrl(_))
.WillRepeatedly(Return(false));
@@ -438,6 +454,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadValidateRequest) {
EXPECT_EQ(info.sha256_hash, request.digests().sha256());
EXPECT_EQ(info.total_bytes, request.length());
EXPECT_EQ(info.user_initiated, request.user_initiated());
+ EXPECT_TRUE(RequestContainsServerIp(request, info.remote_address));
EXPECT_EQ(2, request.resources_size());
EXPECT_TRUE(RequestContainsResource(request,
ClientDownloadRequest::DOWNLOAD_REDIRECT,
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | content/browser/download/download_create_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698