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

Side by Side Diff: components/security_state/content/content_utils_unittest.cc

Issue 2770703002: Rename SecurityStyleExplanations and WebSecurityStyle fields (Closed)
Patch Set: Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/content/content_utils.h" 5 #include "components/security_state/content/content_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "components/security_state/core/security_state.h" 9 #include "components/security_state/core/security_state.h"
10 #include "components/security_state/core/switches.h" 10 #include "components/security_state/core/switches.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 explanations.secure_explanations, "Secure Connection", &explanation)); 196 explanations.secure_explanations, "Secure Connection", &explanation));
197 EXPECT_EQ( 197 EXPECT_EQ(
198 "The connection to this site is encrypted and authenticated using a " 198 "The connection to this site is encrypted and authenticated using a "
199 "strong protocol (TLS 1.3), a strong key exchange (X25519), and a " 199 "strong protocol (TLS 1.3), a strong key exchange (X25519), and a "
200 "strong cipher (AES_128_GCM).", 200 "strong cipher (AES_128_GCM).",
201 explanation.description); 201 explanation.description);
202 } 202 }
203 } 203 }
204 204
205 // Tests that a security level of HTTP_SHOW_WARNING produces 205 // Tests that a security level of HTTP_SHOW_WARNING produces
206 // blink::WebSecurityStyleUnauthenticated and an explanation if appropriate. 206 // blink::WebSecurityStyleNeutral and an explanation if appropriate.
207 TEST(SecurityStateContentUtilsTest, HTTPWarning) { 207 TEST(SecurityStateContentUtilsTest, HTTPWarning) {
208 security_state::SecurityInfo security_info; 208 security_state::SecurityInfo security_info;
209 content::SecurityStyleExplanations explanations; 209 content::SecurityStyleExplanations explanations;
210 security_info.security_level = security_state::HTTP_SHOW_WARNING; 210 security_info.security_level = security_state::HTTP_SHOW_WARNING;
211 blink::WebSecurityStyle security_style = 211 blink::WebSecurityStyle security_style =
212 GetSecurityStyle(security_info, &explanations); 212 GetSecurityStyle(security_info, &explanations);
213 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated, security_style); 213 EXPECT_EQ(blink::WebSecurityStyleNeutral, security_style);
214 // Verify no explanation was shown, because Form Not Secure was not triggered. 214 // Verify no explanation was shown, because Form Not Secure was not triggered.
215 EXPECT_EQ(0u, explanations.unauthenticated_explanations.size()); 215 EXPECT_EQ(0u, explanations.neutral_explanations.size());
216 216
217 explanations.unauthenticated_explanations.clear(); 217 explanations.neutral_explanations.clear();
218 security_info.displayed_credit_card_field_on_http = true; 218 security_info.displayed_credit_card_field_on_http = true;
219 security_style = GetSecurityStyle(security_info, &explanations); 219 security_style = GetSecurityStyle(security_info, &explanations);
220 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated, security_style); 220 EXPECT_EQ(blink::WebSecurityStyleNeutral, security_style);
221 // Verify one explanation was shown, because Form Not Secure was triggered. 221 // Verify one explanation was shown, because Form Not Secure was triggered.
222 EXPECT_EQ(1u, explanations.unauthenticated_explanations.size()); 222 EXPECT_EQ(1u, explanations.neutral_explanations.size());
223 223
224 // Check that when both password and credit card fields get displayed, only 224 // Check that when both password and credit card fields get displayed, only
225 // one explanation is added. 225 // one explanation is added.
226 explanations.unauthenticated_explanations.clear(); 226 explanations.neutral_explanations.clear();
227 security_info.displayed_credit_card_field_on_http = true; 227 security_info.displayed_credit_card_field_on_http = true;
228 security_info.displayed_password_field_on_http = true; 228 security_info.displayed_password_field_on_http = true;
229 security_style = GetSecurityStyle(security_info, &explanations); 229 security_style = GetSecurityStyle(security_info, &explanations);
230 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated, security_style); 230 EXPECT_EQ(blink::WebSecurityStyleNeutral, security_style);
231 // Verify only one explanation was shown when Form Not Secure is triggered. 231 // Verify only one explanation was shown when Form Not Secure is triggered.
232 EXPECT_EQ(1u, explanations.unauthenticated_explanations.size()); 232 EXPECT_EQ(1u, explanations.neutral_explanations.size());
233 } 233 }
234 234
235 } // namespace 235 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698