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

Side by Side Diff: components/security_state/core/security_state_unittest.cc

Issue 2616553002: Remove obsolete SHA-1 UX elements (Closed)
Patch Set: Address Emily's feedback Created 3 years, 11 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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 int connection_status_; 107 int connection_status_;
108 net::CertStatus cert_status_; 108 net::CertStatus cert_status_;
109 bool displayed_mixed_content_; 109 bool displayed_mixed_content_;
110 bool ran_mixed_content_; 110 bool ran_mixed_content_;
111 MaliciousContentStatus malicious_content_status_; 111 MaliciousContentStatus malicious_content_status_;
112 bool displayed_password_field_on_http_; 112 bool displayed_password_field_on_http_;
113 bool displayed_credit_card_field_on_http_; 113 bool displayed_credit_card_field_on_http_;
114 }; 114 };
115 115
116 } // namespace 116 } // namespace
117 117
estark 2017/01/08 16:39:59 Could you add a test for the cert-error SHA1 case,
elawrence 2017/01/09 18:13:12 Done.
118 // Tests that SHA1-signed certificates expiring in 2016 downgrade the 118 // Tests that SHA1-signed certificates expiring in 2016 downgrade the
estark 2017/01/08 16:39:58 the "expiring in 2016" bit should be removed, yeah
elawrence 2017/01/09 18:13:11 Done.
119 // security state of the page. 119 // security state of the page.
120 TEST(SecurityStateTest, SHA1Warning) { 120 TEST(SecurityStateTest, SHA1Warning) {
121 TestSecurityStateHelper helper; 121 TestSecurityStateHelper helper;
122 SecurityInfo security_info; 122 SecurityInfo security_info;
123 helper.GetSecurityInfo(&security_info); 123 helper.GetSecurityInfo(&security_info);
124 EXPECT_EQ(DEPRECATED_SHA1_MINOR, security_info.sha1_deprecation_status); 124 EXPECT_EQ(true, security_info.sha1_in_chain);
estark 2017/01/08 16:39:59 nit: EXPECT_TRUE
elawrence 2017/01/09 18:13:12 Done.
125 EXPECT_EQ(DANGEROUS, security_info.security_level); 125 EXPECT_EQ(NONE, security_info.security_level);
126 } 126 }
127 127
128 // Tests that SHA1 warnings don't interfere with the handling of mixed 128 // Tests that SHA1 warnings don't interfere with the handling of mixed
129 // content. 129 // content.
130 TEST(SecurityStateTest, SHA1WarningMixedContent) { 130 TEST(SecurityStateTest, SHA1WarningMixedContent) {
131 TestSecurityStateHelper helper; 131 TestSecurityStateHelper helper;
132 helper.SetDisplayedMixedContent(true); 132 helper.SetDisplayedMixedContent(true);
133 SecurityInfo security_info1; 133 SecurityInfo security_info1;
134 helper.GetSecurityInfo(&security_info1); 134 helper.GetSecurityInfo(&security_info1);
135 EXPECT_EQ(DEPRECATED_SHA1_MINOR, security_info1.sha1_deprecation_status); 135 EXPECT_EQ(true, security_info1.sha1_in_chain);
estark 2017/01/08 16:39:59 nit: EXPECT_TRUE
elawrence 2017/01/09 18:13:12 Done.
136 EXPECT_EQ(CONTENT_STATUS_DISPLAYED, security_info1.mixed_content_status); 136 EXPECT_EQ(CONTENT_STATUS_DISPLAYED, security_info1.mixed_content_status);
137 EXPECT_EQ(DANGEROUS, security_info1.security_level); 137 EXPECT_EQ(NONE, security_info1.security_level);
138 138
139 helper.SetDisplayedMixedContent(false); 139 helper.SetDisplayedMixedContent(false);
140 helper.SetRanMixedContent(true); 140 helper.SetRanMixedContent(true);
141 SecurityInfo security_info2; 141 SecurityInfo security_info2;
142 helper.GetSecurityInfo(&security_info2); 142 helper.GetSecurityInfo(&security_info2);
143 EXPECT_EQ(DEPRECATED_SHA1_MINOR, security_info2.sha1_deprecation_status); 143 EXPECT_EQ(true, security_info2.sha1_in_chain);
estark 2017/01/08 16:39:59 nit: EXPECT_TRUE
elawrence 2017/01/09 18:13:11 Done.
144 EXPECT_EQ(CONTENT_STATUS_RAN, security_info2.mixed_content_status); 144 EXPECT_EQ(CONTENT_STATUS_RAN, security_info2.mixed_content_status);
145 EXPECT_EQ(DANGEROUS, security_info2.security_level); 145 EXPECT_EQ(DANGEROUS, security_info2.security_level);
146 } 146 }
147 147
148 // Tests that SHA1 warnings don't interfere with the handling of major 148 // Tests that SHA1 warnings don't interfere with the handling of major
149 // cert errors. 149 // cert errors.
150 TEST(SecurityStateTest, SHA1WarningBrokenHTTPS) { 150 TEST(SecurityStateTest, SHA1WarningBrokenHTTPS) {
151 TestSecurityStateHelper helper; 151 TestSecurityStateHelper helper;
152 helper.AddCertStatus(net::CERT_STATUS_DATE_INVALID); 152 helper.AddCertStatus(net::CERT_STATUS_DATE_INVALID);
153 SecurityInfo security_info; 153 SecurityInfo security_info;
154 helper.GetSecurityInfo(&security_info); 154 helper.GetSecurityInfo(&security_info);
155 EXPECT_EQ(DEPRECATED_SHA1_MINOR, security_info.sha1_deprecation_status); 155 EXPECT_EQ(true, security_info.sha1_in_chain);
estark 2017/01/08 16:39:59 nit: EXPECT_TRUE
elawrence 2017/01/09 18:13:11 Done.
156 EXPECT_EQ(DANGEROUS, security_info.security_level); 156 EXPECT_EQ(DANGEROUS, security_info.security_level);
157 } 157 }
158 158
159 // Tests that |security_info.is_secure_protocol_and_ciphersuite| is 159 // Tests that |security_info.is_secure_protocol_and_ciphersuite| is
160 // computed correctly. 160 // computed correctly.
161 TEST(SecurityStateTest, SecureProtocolAndCiphersuite) { 161 TEST(SecurityStateTest, SecureProtocolAndCiphersuite) {
162 TestSecurityStateHelper helper; 162 TestSecurityStateHelper helper;
163 // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 from 163 // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 from
164 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-param eters-4 164 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-param eters-4
165 const uint16_t ciphersuite = 0xc02f; 165 const uint16_t ciphersuite = 0xc02f;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 helper.GetSecurityInfo(&security_info); 311 helper.GetSecurityInfo(&security_info);
312 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 1); 312 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 1);
313 313
314 // Ensure histogram recorded correctly even without a password input. 314 // Ensure histogram recorded correctly even without a password input.
315 helper.set_displayed_password_field_on_http(false); 315 helper.set_displayed_password_field_on_http(false);
316 helper.GetSecurityInfo(&security_info); 316 helper.GetSecurityInfo(&security_info);
317 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2); 317 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2);
318 } 318 }
319 319
320 } // namespace security_state 320 } // namespace security_state
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698