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

Side by Side Diff: components/security_state/security_state_model_unittest.cc

Issue 2494033002: Revert "HTTP Bad: Split out UMA metrics for password vs credit card "Not secure" warnings" (Closed)
Patch Set: Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/security_state/security_state_model.h" 5 #include "components/security_state/security_state_model.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/test/histogram_tester.h" 10 #include "base/test/histogram_tester.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 244 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
245 switches::kMarkHttpAs, 245 switches::kMarkHttpAs,
246 switches::kMarkHttpWithPasswordsOrCcWithChip); 246 switches::kMarkHttpWithPasswordsOrCcWithChip);
247 TestSecurityStateModelClient client; 247 TestSecurityStateModelClient client;
248 client.UseHttpUrl(); 248 client.UseHttpUrl();
249 SecurityStateModel model; 249 SecurityStateModel model;
250 model.SetClient(&client); 250 model.SetClient(&client);
251 client.set_displayed_password_field_on_http(true); 251 client.set_displayed_password_field_on_http(true);
252 SecurityStateModel::SecurityInfo security_info; 252 SecurityStateModel::SecurityInfo security_info;
253 model.GetSecurityInfo(&security_info); 253 model.GetSecurityInfo(&security_info);
254 EXPECT_TRUE(security_info.displayed_password_field_on_http); 254 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
255 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING, 255 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING,
256 security_info.security_level); 256 security_info.security_level);
257 } 257 }
258 258
259 // Tests that credit card fields cause the security level to be downgraded 259 // Tests that credit card fields cause the security level to be downgraded
260 // to HTTP_SHOW_WARNING when the command-line switch is set. 260 // to HTTP_SHOW_WARNING when the command-line switch is set.
261 TEST(SecurityStateModelTest, CreditCardFieldWarning) { 261 TEST(SecurityStateModelTest, CreditCardFieldWarning) {
262 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 262 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
263 switches::kMarkHttpAs, 263 switches::kMarkHttpAs,
264 switches::kMarkHttpWithPasswordsOrCcWithChip); 264 switches::kMarkHttpWithPasswordsOrCcWithChip);
265 TestSecurityStateModelClient client; 265 TestSecurityStateModelClient client;
266 client.UseHttpUrl(); 266 client.UseHttpUrl();
267 SecurityStateModel model; 267 SecurityStateModel model;
268 model.SetClient(&client); 268 model.SetClient(&client);
269 client.set_displayed_credit_card_field_on_http(true); 269 client.set_displayed_credit_card_field_on_http(true);
270 SecurityStateModel::SecurityInfo security_info; 270 SecurityStateModel::SecurityInfo security_info;
271 model.GetSecurityInfo(&security_info); 271 model.GetSecurityInfo(&security_info);
272 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http); 272 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
273 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING, 273 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING,
274 security_info.security_level); 274 security_info.security_level);
275 } 275 }
276 276
277 // Tests that neither password nor credit fields cause the security 277 // Tests that neither password nor credit fields cause the security
278 // level to be downgraded to HTTP_SHOW_WARNING when the command-line switch 278 // level to be downgraded to HTTP_SHOW_WARNING when the command-line switch
279 // is NOT set. 279 // is NOT set.
280 TEST(SecurityStateModelTest, HttpWarningNotSetWithoutSwitch) { 280 TEST(SecurityStateModelTest, HttpWarningNotSetWithoutSwitch) {
281 TestSecurityStateModelClient client; 281 TestSecurityStateModelClient client;
282 client.UseHttpUrl(); 282 client.UseHttpUrl();
283 SecurityStateModel model; 283 SecurityStateModel model;
284 model.SetClient(&client); 284 model.SetClient(&client);
285 client.set_displayed_password_field_on_http(true); 285 client.set_displayed_password_field_on_http(true);
286 client.set_displayed_credit_card_field_on_http(true);
286 SecurityStateModel::SecurityInfo security_info; 287 SecurityStateModel::SecurityInfo security_info;
287 model.GetSecurityInfo(&security_info); 288 model.GetSecurityInfo(&security_info);
288 EXPECT_TRUE(security_info.displayed_password_field_on_http); 289 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
289 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
290
291 client.set_displayed_credit_card_field_on_http(true);
292 model.GetSecurityInfo(&security_info);
293 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http);
294 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level); 290 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
295 } 291 }
296 292
297 // Tests that neither |displayed_password_field_on_http| nor 293 // Tests that |displayed_private_user_data_input_on_http| is not set
298 // |displayed_credit_card_field_on_http| is set when the corresponding 294 // when the corresponding VisibleSecurityState flags are not set.
299 // VisibleSecurityState flags are not set.
300 TEST(SecurityStateModelTest, PrivateUserDataNotSet) { 295 TEST(SecurityStateModelTest, PrivateUserDataNotSet) {
301 TestSecurityStateModelClient client; 296 TestSecurityStateModelClient client;
302 client.UseHttpUrl(); 297 client.UseHttpUrl();
303 SecurityStateModel model; 298 SecurityStateModel model;
304 model.SetClient(&client); 299 model.SetClient(&client);
305 SecurityStateModel::SecurityInfo security_info; 300 SecurityStateModel::SecurityInfo security_info;
306 model.GetSecurityInfo(&security_info); 301 model.GetSecurityInfo(&security_info);
307 EXPECT_FALSE(security_info.displayed_password_field_on_http); 302 EXPECT_FALSE(security_info.displayed_private_user_data_input_on_http);
308 EXPECT_FALSE(security_info.displayed_credit_card_field_on_http);
309 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level); 303 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
310 } 304 }
311 305
312 // Tests that SSL.MarkHttpAsStatus histogram is updated when security state is 306 // Tests that SSL.MarkHttpAsStatus histogram is updated when security state is
313 // computed for a page. 307 // computed for a page.
314 TEST(SecurityStateModelTest, MarkHttpAsStatusHistogram) { 308 TEST(SecurityStateModelTest, MarkHttpAsStatusHistogram) {
315 const char* kHistogramName = "SSL.MarkHttpAsStatus"; 309 const char* kHistogramName = "SSL.MarkHttpAsStatus";
316 base::HistogramTester histograms; 310 base::HistogramTester histograms;
317 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 311 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
318 switches::kMarkHttpAs, switches::kMarkHttpWithPasswordsOrCcWithChip); 312 switches::kMarkHttpAs, switches::kMarkHttpWithPasswordsOrCcWithChip);
(...skipping 12 matching lines...) Expand all
331 325
332 // Ensure histogram recorded correctly even without a password input. 326 // Ensure histogram recorded correctly even without a password input.
333 client.set_displayed_password_field_on_http(false); 327 client.set_displayed_password_field_on_http(false);
334 model.GetSecurityInfo(&security_info); 328 model.GetSecurityInfo(&security_info);
335 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2); 329 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2);
336 } 330 }
337 331
338 } // namespace 332 } // namespace
339 333
340 } // namespace security_state 334 } // namespace security_state
OLDNEW
« no previous file with comments | « components/security_state/security_state_model.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698