| OLD | NEW |
| 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/core/security_state.h" | 5 #include "components/security_state/core/security_state.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 switches::kMarkHttpAs, switches::kMarkHttpWithPasswordsOrCcWithChip); | 267 switches::kMarkHttpAs, switches::kMarkHttpWithPasswordsOrCcWithChip); |
| 268 TestSecurityStateHelper helper; | 268 TestSecurityStateHelper helper; |
| 269 helper.UseHttpUrl(); | 269 helper.UseHttpUrl(); |
| 270 helper.set_displayed_credit_card_field_on_http(true); | 270 helper.set_displayed_credit_card_field_on_http(true); |
| 271 SecurityInfo security_info; | 271 SecurityInfo security_info; |
| 272 helper.GetSecurityInfo(&security_info); | 272 helper.GetSecurityInfo(&security_info); |
| 273 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http); | 273 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http); |
| 274 EXPECT_EQ(HTTP_SHOW_WARNING, security_info.security_level); | 274 EXPECT_EQ(HTTP_SHOW_WARNING, security_info.security_level); |
| 275 } | 275 } |
| 276 | 276 |
| 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 | |
| 279 // is NOT set. | |
| 280 TEST(SecurityStateTest, HttpWarningNotSetWithoutSwitch) { | |
| 281 TestSecurityStateHelper helper; | |
| 282 helper.UseHttpUrl(); | |
| 283 helper.set_displayed_password_field_on_http(true); | |
| 284 SecurityInfo security_info; | |
| 285 helper.GetSecurityInfo(&security_info); | |
| 286 EXPECT_TRUE(security_info.displayed_password_field_on_http); | |
| 287 EXPECT_EQ(NONE, security_info.security_level); | |
| 288 | |
| 289 helper.set_displayed_credit_card_field_on_http(true); | |
| 290 helper.GetSecurityInfo(&security_info); | |
| 291 EXPECT_TRUE(security_info.displayed_credit_card_field_on_http); | |
| 292 EXPECT_EQ(NONE, security_info.security_level); | |
| 293 } | |
| 294 | |
| 295 // Tests that neither |displayed_password_field_on_http| nor | 277 // Tests that neither |displayed_password_field_on_http| nor |
| 296 // |displayed_credit_card_field_on_http| is set when the corresponding | 278 // |displayed_credit_card_field_on_http| is set when the corresponding |
| 297 // VisibleSecurityState flags are not set. | 279 // VisibleSecurityState flags are not set. |
| 298 TEST(SecurityStateTest, PrivateUserDataNotSet) { | 280 TEST(SecurityStateTest, PrivateUserDataNotSet) { |
| 299 TestSecurityStateHelper helper; | 281 TestSecurityStateHelper helper; |
| 300 helper.UseHttpUrl(); | 282 helper.UseHttpUrl(); |
| 301 SecurityInfo security_info; | 283 SecurityInfo security_info; |
| 302 helper.GetSecurityInfo(&security_info); | 284 helper.GetSecurityInfo(&security_info); |
| 303 EXPECT_FALSE(security_info.displayed_password_field_on_http); | 285 EXPECT_FALSE(security_info.displayed_password_field_on_http); |
| 304 EXPECT_FALSE(security_info.displayed_credit_card_field_on_http); | 286 EXPECT_FALSE(security_info.displayed_credit_card_field_on_http); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 323 helper.GetSecurityInfo(&security_info); | 305 helper.GetSecurityInfo(&security_info); |
| 324 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 1); | 306 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 1); |
| 325 | 307 |
| 326 // Ensure histogram recorded correctly even without a password input. | 308 // Ensure histogram recorded correctly even without a password input. |
| 327 helper.set_displayed_password_field_on_http(false); | 309 helper.set_displayed_password_field_on_http(false); |
| 328 helper.GetSecurityInfo(&security_info); | 310 helper.GetSecurityInfo(&security_info); |
| 329 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2); | 311 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2); |
| 330 } | 312 } |
| 331 | 313 |
| 332 } // namespace security_state | 314 } // namespace security_state |
| OLD | NEW |