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

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

Issue 923263002: Report HTTPS links in MalwareDetails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lint nits Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/malware_details.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/malware_details_unittest.cc
diff --git a/chrome/browser/safe_browsing/malware_details_unittest.cc b/chrome/browser/safe_browsing/malware_details_unittest.cc
index 8b4dae492ac01c696205497cf478a9b2a0f81cf1..57b8c4f93a14460384098fe4267ecf457f5f22a0 100644
--- a/chrome/browser/safe_browsing/malware_details_unittest.cc
+++ b/chrome/browser/safe_browsing/malware_details_unittest.cc
@@ -34,26 +34,30 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
-static const char* kOriginalLandingURL = "http://www.originallandingpage.com/";
-static const char* kHttpsURL = "https://www.url.com/";
-static const char* kDOMChildURL = "http://www.domparent.com/";
-static const char* kDOMParentURL = "http://www.domchild.com/";
-static const char* kFirstRedirectURL = "http://redirectone.com/";
-static const char* kSecondRedirectURL = "http://redirecttwo.com/";
-
-static const char* kMalwareURL = "http://www.malware.com/";
+// Mixture of HTTP and HTTPS. No special treatment for HTTPS.
+static const char* kOriginalLandingURL =
+ "http://www.originallandingpage.com/with/path";
+static const char* kDOMChildURL = "https://www.domparent.com/with/path";
+static const char* kDOMParentURL = "https://www.domchild.com/with/path";
+static const char* kFirstRedirectURL = "http://redirectone.com/with/path";
+static const char* kSecondRedirectURL = "https://redirecttwo.com/with/path";
+static const char* kReferrerURL = "http://www.referrer.com/with/path";
+
+static const char* kMalwareURL = "http://www.malware.com/with/path";
static const char* kMalwareHeaders =
"HTTP/1.1 200 OK\n"
"Content-Type: image/jpeg\n";
static const char* kMalwareData = "exploit();";
-static const char* kLandingURL = "http://www.landingpage.com/";
+static const char* kLandingURL = "http://www.landingpage.com/with/path";
static const char* kLandingHeaders =
"HTTP/1.1 200 OK\n"
"Content-Type: text/html\n"
"Content-Length: 1024\n"
"Set-Cookie: tastycookie\n"; // This header is stripped.
-static const char* kLandingData = "<iframe src='http://www.malware.com'>";
+static const char* kLandingData =
+ "<iframe src='http://www.malware.com/with/path'>";
+
using content::BrowserThread;
using content::WebContents;
@@ -131,7 +135,6 @@ class MalwareDetailsWrap : public MalwareDetails {
const SafeBrowsingUIManager::UnsafeResource& unsafe_resource,
net::URLRequestContextGetter* request_context_getter)
: MalwareDetails(ui_manager, web_contents, unsafe_resource) {
-
request_context_getter_ = request_context_getter;
}
@@ -321,8 +324,10 @@ class MalwareDetailsTest : public ChromeRenderViewHostTestHarness {
// Tests creating a simple malware report.
TEST_F(MalwareDetailsTest, MalwareSubResource) {
// Start a load.
- controller().LoadURL(GURL(kLandingURL), content::Referrer(),
- ui::PAGE_TRANSITION_TYPED, std::string());
+ controller().LoadURL(
+ GURL(kLandingURL),
+ content::Referrer(GURL(kReferrerURL), blink::WebReferrerPolicyDefault),
+ ui::PAGE_TRANSITION_TYPED, std::string());
UnsafeResource resource;
InitResource(&resource, true, GURL(kMalwareURL));
@@ -338,7 +343,9 @@ TEST_F(MalwareDetailsTest, MalwareSubResource) {
ClientMalwareReportRequest expected;
expected.set_malware_url(kMalwareURL);
expected.set_page_url(kLandingURL);
- expected.set_referrer_url("");
+ // Note that the referrer policy is not actually enacted here, since that's
+ // done in Blink.
+ expected.set_referrer_url(kReferrerURL);
ClientMalwareReportRequest::Resource* pb_resource = expected.add_resources();
pb_resource->set_id(0);
@@ -346,6 +353,9 @@ TEST_F(MalwareDetailsTest, MalwareSubResource) {
pb_resource = expected.add_resources();
pb_resource->set_id(1);
pb_resource->set_url(kMalwareURL);
+ pb_resource = expected.add_resources();
+ pb_resource->set_id(2);
+ pb_resource->set_url(kReferrerURL);
VerifyResults(actual, expected);
}
@@ -384,7 +394,7 @@ TEST_F(MalwareDetailsTest, MalwareSubResourceWithOriginalUrl) {
pb_resource = expected.add_resources();
pb_resource->set_id(2);
pb_resource->set_url(kMalwareURL);
- // The Resource for kMmalwareUrl should have the Resource for
+ // The Resource for kMalwareUrl should have the Resource for
// kOriginalLandingURL (with id 1) as parent.
pb_resource->set_parent_id(1);
@@ -446,29 +456,6 @@ TEST_F(MalwareDetailsTest, MalwareDOMDetails) {
VerifyResults(actual, expected);
}
-// Verify that https:// urls are dropped.
-TEST_F(MalwareDetailsTest, NotPublicUrl) {
- controller().LoadURL(GURL(kHttpsURL), content::Referrer(),
- ui::PAGE_TRANSITION_TYPED, std::string());
- UnsafeResource resource;
- InitResource(&resource, true, GURL(kMalwareURL));
- scoped_refptr<MalwareDetailsWrap> report = new MalwareDetailsWrap(
- ui_manager_.get(), web_contents(), resource, NULL);
-
- std::string serialized = WaitForSerializedReport(report.get());
- ClientMalwareReportRequest actual;
- actual.ParseFromString(serialized);
-
- ClientMalwareReportRequest expected;
- expected.set_malware_url(kMalwareURL); // No page_url
- expected.set_referrer_url("");
-
- ClientMalwareReportRequest::Resource* pb_resource = expected.add_resources();
- pb_resource->set_url(kMalwareURL); // Only one resource
-
- VerifyResults(actual, expected);
-}
-
// Tests creating a malware report where there are redirect urls to an unsafe
// resource url
TEST_F(MalwareDetailsTest, MalwareWithRedirectUrl) {
@@ -573,8 +560,8 @@ TEST_F(MalwareDetailsTest, HTTPCache) {
pb_header->set_name("Set-Cookie");
pb_header->set_value(""); // The cookie is dropped.
pb_response->set_body(kLandingData);
- pb_response->set_bodylength(37);
- pb_response->set_bodydigest("9ca97475598a79bc1e8fc9bd6c72cd35");
+ pb_response->set_bodylength(47);
+ pb_response->set_bodydigest("5abb4e63d806ec2c16a40b2699700554");
pb_response->set_remote_ip("1.2.3.4:80");
pb_resource = expected.add_resources();
« no previous file with comments | « chrome/browser/safe_browsing/malware_details.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698