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

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

Issue 2424223002: Update devtools security panel for HTTP-bad (Closed)
Patch Set: lgarron comments Created 4 years, 2 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 | « components/security_state/security_state_model.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 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 "components/security_state/security_state_model_client.h" 10 #include "components/security_state/security_state_model_client.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 243 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
244 switches::kMarkHttpAs, 244 switches::kMarkHttpAs,
245 switches::kMarkHttpWithPasswordsOrCcWithChip); 245 switches::kMarkHttpWithPasswordsOrCcWithChip);
246 TestSecurityStateModelClient client; 246 TestSecurityStateModelClient client;
247 client.UseHttpUrl(); 247 client.UseHttpUrl();
248 SecurityStateModel model; 248 SecurityStateModel model;
249 model.SetClient(&client); 249 model.SetClient(&client);
250 client.set_displayed_password_field_on_http(true); 250 client.set_displayed_password_field_on_http(true);
251 SecurityStateModel::SecurityInfo security_info; 251 SecurityStateModel::SecurityInfo security_info;
252 model.GetSecurityInfo(&security_info); 252 model.GetSecurityInfo(&security_info);
253 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
253 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING, 254 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING,
254 security_info.security_level); 255 security_info.security_level);
255 } 256 }
256 257
257 // Tests that credit card fields cause the security level to be downgraded 258 // Tests that credit card fields cause the security level to be downgraded
258 // to HTTP_SHOW_WARNING when the command-line switch is set. 259 // to HTTP_SHOW_WARNING when the command-line switch is set.
259 TEST(SecurityStateModelTest, CreditCardFieldWarning) { 260 TEST(SecurityStateModelTest, CreditCardFieldWarning) {
260 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 261 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
261 switches::kMarkHttpAs, 262 switches::kMarkHttpAs,
262 switches::kMarkHttpWithPasswordsOrCcWithChip); 263 switches::kMarkHttpWithPasswordsOrCcWithChip);
263 TestSecurityStateModelClient client; 264 TestSecurityStateModelClient client;
264 client.UseHttpUrl(); 265 client.UseHttpUrl();
265 SecurityStateModel model; 266 SecurityStateModel model;
266 model.SetClient(&client); 267 model.SetClient(&client);
267 client.set_displayed_credit_card_field_on_http(true); 268 client.set_displayed_credit_card_field_on_http(true);
268 SecurityStateModel::SecurityInfo security_info; 269 SecurityStateModel::SecurityInfo security_info;
269 model.GetSecurityInfo(&security_info); 270 model.GetSecurityInfo(&security_info);
271 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
270 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING, 272 EXPECT_EQ(SecurityStateModel::HTTP_SHOW_WARNING,
271 security_info.security_level); 273 security_info.security_level);
272 } 274 }
273 275
274 // Tests that neither password nor credit fields cause the security 276 // Tests that neither password nor credit fields cause the security
275 // level to be downgraded to HTTP_SHOW_WARNING when the command-line switch 277 // level to be downgraded to HTTP_SHOW_WARNING when the command-line switch
276 // is NOT set. 278 // is NOT set.
277 TEST(SecurityStateModelTest, HttpWarningNotSetWithoutSwitch) { 279 TEST(SecurityStateModelTest, HttpWarningNotSetWithoutSwitch) {
278 TestSecurityStateModelClient client; 280 TestSecurityStateModelClient client;
279 client.UseHttpUrl(); 281 client.UseHttpUrl();
280 SecurityStateModel model; 282 SecurityStateModel model;
281 model.SetClient(&client); 283 model.SetClient(&client);
282 client.set_displayed_password_field_on_http(true); 284 client.set_displayed_password_field_on_http(true);
283 client.set_displayed_credit_card_field_on_http(true); 285 client.set_displayed_credit_card_field_on_http(true);
284 SecurityStateModel::SecurityInfo security_info; 286 SecurityStateModel::SecurityInfo security_info;
285 model.GetSecurityInfo(&security_info); 287 model.GetSecurityInfo(&security_info);
288 EXPECT_TRUE(security_info.displayed_private_user_data_input_on_http);
286 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level); 289 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
287 } 290 }
288 291
292 // Tests that |displayed_private_user_data_input_on_http| is not set
293 // when the corresponding VisibleSecurityState flags are not set.
294 TEST(SecurityStateModelTest, PrivateUserDataNotSet) {
295 TestSecurityStateModelClient client;
296 client.UseHttpUrl();
297 SecurityStateModel model;
298 model.SetClient(&client);
299 SecurityStateModel::SecurityInfo security_info;
300 model.GetSecurityInfo(&security_info);
301 EXPECT_FALSE(security_info.displayed_private_user_data_input_on_http);
302 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level);
303 }
304
289 } // namespace 305 } // namespace
290 306
291 } // namespace security_state 307 } // namespace security_state
OLDNEW
« no previous file with comments | « components/security_state/security_state_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698