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

Side by Side Diff: components/safe_browsing/base_ping_manager_unittest.cc

Issue 2925693003: Making CSD ReportType enum consistent. (Closed)
Patch Set: Handling SBThreatType enums as well Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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 5
6 #include "components/safe_browsing/base_ping_manager.h" 6 #include "components/safe_browsing/base_ping_manager.h"
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 key_param_ + 118 key_param_ +
119 "&ext=2&evts=phishblhit&" 119 "&ext=2&evts=phishblhit&"
120 "evtd=http%3A%2F%2Fmalicious.url.com%2F&" 120 "evtd=http%3A%2F%2Fmalicious.url.com%2F&"
121 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer." 121 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
122 "url.com%2F&evtb=0&src=ds&m=1", 122 "url.com%2F&evtb=0&src=ds&m=1",
123 ping_manager()->SafeBrowsingHitUrl(hp).spec()); 123 ping_manager()->SafeBrowsingHitUrl(hp).spec());
124 } 124 }
125 125
126 { 126 {
127 HitReport hp(base_hp); 127 HitReport hp(base_hp);
128 hp.threat_type = SB_THREAT_TYPE_BINARY_MALWARE_URL; 128 hp.threat_type = SB_THREAT_TYPE_URL_BINARY_MALWARE;
129 hp.threat_source = ThreatSource::REMOTE; 129 hp.threat_source = ThreatSource::REMOTE;
130 hp.extended_reporting_level = SBER_LEVEL_OFF; 130 hp.extended_reporting_level = SBER_LEVEL_OFF;
131 hp.is_metrics_reporting_active = true; 131 hp.is_metrics_reporting_active = true;
132 hp.is_subresource = false; 132 hp.is_subresource = false;
133 EXPECT_EQ( 133 EXPECT_EQ(
134 "https://prefix.com/foo/report?client=unittest&appver=1.0&" 134 "https://prefix.com/foo/report?client=unittest&appver=1.0&"
135 "pver=3.0" + 135 "pver=3.0" +
136 key_param_ + 136 key_param_ +
137 "&ext=0&evts=binurlhit&" 137 "&ext=0&evts=binurlhit&"
138 "evtd=http%3A%2F%2Fmalicious.url.com%2F&" 138 "evtd=http%3A%2F%2Fmalicious.url.com%2F&"
139 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer." 139 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
140 "url.com%2F&evtb=0&src=rem&m=1", 140 "url.com%2F&evtb=0&src=rem&m=1",
141 ping_manager()->SafeBrowsingHitUrl(hp).spec()); 141 ping_manager()->SafeBrowsingHitUrl(hp).spec());
142 } 142 }
143 143
144 { 144 {
145 HitReport hp(base_hp); 145 HitReport hp(base_hp);
146 hp.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL; 146 hp.threat_type = SB_THREAT_TYPE_URL_CLIENT_SIDE_PHISHING;
147 hp.threat_source = ThreatSource::LOCAL_PVER4; 147 hp.threat_source = ThreatSource::LOCAL_PVER4;
148 hp.extended_reporting_level = SBER_LEVEL_OFF; 148 hp.extended_reporting_level = SBER_LEVEL_OFF;
149 hp.is_metrics_reporting_active = false; 149 hp.is_metrics_reporting_active = false;
150 hp.is_subresource = false; 150 hp.is_subresource = false;
151 EXPECT_EQ( 151 EXPECT_EQ(
152 "https://prefix.com/foo/report?client=unittest&appver=1.0&" 152 "https://prefix.com/foo/report?client=unittest&appver=1.0&"
153 "pver=3.0" + 153 "pver=3.0" +
154 key_param_ + 154 key_param_ +
155 "&ext=0&evts=phishcsdhit&" 155 "&ext=0&evts=phishcsdhit&"
156 "evtd=http%3A%2F%2Fmalicious.url.com%2F&" 156 "evtd=http%3A%2F%2Fmalicious.url.com%2F&"
157 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer." 157 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
158 "url.com%2F&evtb=0&src=l4&m=0", 158 "url.com%2F&evtb=0&src=l4&m=0",
159 ping_manager()->SafeBrowsingHitUrl(hp).spec()); 159 ping_manager()->SafeBrowsingHitUrl(hp).spec());
160 } 160 }
161 161
162 { 162 {
163 HitReport hp(base_hp); 163 HitReport hp(base_hp);
164 hp.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; 164 hp.threat_type = SB_THREAT_TYPE_URL_CLIENT_SIDE_MALWARE;
165 hp.threat_source = ThreatSource::LOCAL_PVER4; 165 hp.threat_source = ThreatSource::LOCAL_PVER4;
166 hp.extended_reporting_level = SBER_LEVEL_OFF; 166 hp.extended_reporting_level = SBER_LEVEL_OFF;
167 hp.is_metrics_reporting_active = false; 167 hp.is_metrics_reporting_active = false;
168 hp.is_subresource = true; 168 hp.is_subresource = true;
169 EXPECT_EQ( 169 EXPECT_EQ(
170 "https://prefix.com/foo/report?client=unittest&appver=1.0&" 170 "https://prefix.com/foo/report?client=unittest&appver=1.0&"
171 "pver=3.0" + 171 "pver=3.0" +
172 key_param_ + 172 key_param_ +
173 "&ext=0&evts=malcsdhit&" 173 "&ext=0&evts=malcsdhit&"
174 "evtd=http%3A%2F%2Fmalicious.url.com%2F&" 174 "evtd=http%3A%2F%2Fmalicious.url.com%2F&"
175 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer." 175 "evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
176 "url.com%2F&evtb=1&src=l4&m=0", 176 "url.com%2F&evtb=1&src=l4&m=0",
177 ping_manager()->SafeBrowsingHitUrl(hp).spec()); 177 ping_manager()->SafeBrowsingHitUrl(hp).spec());
178 } 178 }
179 179
180 // Same as above, but add population_id 180 // Same as above, but add population_id
181 { 181 {
182 HitReport hp(base_hp); 182 HitReport hp(base_hp);
183 hp.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; 183 hp.threat_type = SB_THREAT_TYPE_URL_CLIENT_SIDE_MALWARE;
184 hp.threat_source = ThreatSource::LOCAL_PVER4; 184 hp.threat_source = ThreatSource::LOCAL_PVER4;
185 hp.extended_reporting_level = SBER_LEVEL_OFF; 185 hp.extended_reporting_level = SBER_LEVEL_OFF;
186 hp.is_metrics_reporting_active = false; 186 hp.is_metrics_reporting_active = false;
187 hp.is_subresource = true; 187 hp.is_subresource = true;
188 hp.population_id = "foo bar"; 188 hp.population_id = "foo bar";
189 EXPECT_EQ( 189 EXPECT_EQ(
190 "https://prefix.com/foo/report?client=unittest&appver=1.0&" 190 "https://prefix.com/foo/report?client=unittest&appver=1.0&"
191 "pver=3.0" + 191 "pver=3.0" +
192 key_param_ + 192 key_param_ +
193 "&ext=0&evts=malcsdhit&" 193 "&ext=0&evts=malcsdhit&"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 TEST_F(BasePingManagerTest, TestReportSafeBrowsingHit) { 264 TEST_F(BasePingManagerTest, TestReportSafeBrowsingHit) {
265 const std::string kHitReportPostData = "Hit Report POST Data"; 265 const std::string kHitReportPostData = "Hit Report POST Data";
266 std::string encoded_post_data = ""; 266 std::string encoded_post_data = "";
267 base::Base64Encode(kHitReportPostData, &encoded_post_data); 267 base::Base64Encode(kHitReportPostData, &encoded_post_data);
268 268
269 HitReport hp; 269 HitReport hp;
270 hp.malicious_url = GURL("http://malicious.url.com"); 270 hp.malicious_url = GURL("http://malicious.url.com");
271 hp.page_url = GURL("http://page.url.com"); 271 hp.page_url = GURL("http://page.url.com");
272 hp.referrer_url = GURL("http://referrer.url.com"); 272 hp.referrer_url = GURL("http://referrer.url.com");
273 hp.threat_type = SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL; 273 hp.threat_type = SB_THREAT_TYPE_URL_CLIENT_SIDE_MALWARE;
274 hp.threat_source = ThreatSource::LOCAL_PVER4; 274 hp.threat_source = ThreatSource::LOCAL_PVER4;
275 hp.extended_reporting_level = SBER_LEVEL_OFF; 275 hp.extended_reporting_level = SBER_LEVEL_OFF;
276 hp.is_metrics_reporting_active = false; 276 hp.is_metrics_reporting_active = false;
277 hp.is_subresource = true; 277 hp.is_subresource = true;
278 hp.population_id = "foo bar"; 278 hp.population_id = "foo bar";
279 hp.post_data = kHitReportPostData; 279 hp.post_data = kHitReportPostData;
280 std::string expected_hit_report_url = 280 std::string expected_hit_report_url =
281 ping_manager()->SafeBrowsingHitUrl(hp).spec(); 281 ping_manager()->SafeBrowsingHitUrl(hp).spec();
282 const int kRequestErrorCode = -321; 282 const int kRequestErrorCode = -321;
283 283
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 322
323 EXPECT_TRUE(end_entry.GetIntegerValue("error", &int_value)); 323 EXPECT_TRUE(end_entry.GetIntegerValue("error", &int_value));
324 EXPECT_EQ(kRequestErrorCode, int_value); 324 EXPECT_EQ(kRequestErrorCode, int_value);
325 325
326 // We don't really care what the source_dependency value is, just making sure 326 // We don't really care what the source_dependency value is, just making sure
327 // it's there. 327 // it's there.
328 EXPECT_TRUE(end_entry.params->HasKey("source_dependency")); 328 EXPECT_TRUE(end_entry.params->HasKey("source_dependency"));
329 } 329 }
330 330
331 } // namespace safe_browsing 331 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing/base_ping_manager.cc ('k') | components/safe_browsing/browser/threat_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698