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

Side by Side Diff: chrome/browser/ssl/chrome_security_state_model_client_browser_tests.cc

Issue 1727133002: Expose TLS settings in the Security panel overview, and call out individual obsolete settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and update tests. Created 4 years, 4 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 "chrome/browser/ssl/chrome_security_state_model_client.h" 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 secure_explanations[0].description); 151 secure_explanations[0].description);
152 int cert_id = browser->tab_strip_model() 152 int cert_id = browser->tab_strip_model()
153 ->GetActiveWebContents() 153 ->GetActiveWebContents()
154 ->GetController() 154 ->GetController()
155 .GetActiveEntry() 155 .GetActiveEntry()
156 ->GetSSL() 156 ->GetSSL()
157 .cert_id; 157 .cert_id;
158 EXPECT_EQ(cert_id, secure_explanations[0].cert_id); 158 EXPECT_EQ(cert_id, secure_explanations[0].cert_id);
159 } 159 }
160 160
161 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), 161 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_STRONG_SSL_SUMMARY),
162 secure_explanations.back().summary); 162 secure_explanations.back().summary);
163 EXPECT_EQ( 163
164 l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE_DESCRIPTION), 164 content::WebContents* web_contents =
165 secure_explanations.back().description); 165 browser->tab_strip_model()->GetActiveWebContents();
166 const SecurityStateModel::SecurityInfo& security_info =
167 ChromeSecurityStateModelClient::FromWebContents(web_contents)
168 ->GetSecurityInfo();
169
170 const char *protocol, *key_exchange, *cipher, *mac;
171 int ssl_version =
172 net::SSLConnectionStatusToVersion(security_info.connection_status);
173 net::SSLVersionToString(&protocol, ssl_version);
174 bool is_aead;
175 uint16_t cipher_suite =
176 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
177 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
178 cipher_suite);
179 EXPECT_EQ(TRUE, is_aead);
estark 2016/08/08 18:01:38 nit: EXPECT_TRUE(is_aead)
lgarron 2016/08/08 20:38:26 Done.
180 EXPECT_EQ(NULL, mac); // The default secure cipher does not have a MAC.
181
182 std::vector<base::string16> description_replacements;
183 description_replacements.push_back(base::ASCIIToUTF16(protocol));
184 description_replacements.push_back(base::ASCIIToUTF16(key_exchange));
185 description_replacements.push_back(base::ASCIIToUTF16(cipher));
186 base::string16 secure_description = l10n_util::GetStringFUTF16(
187 IDS_STRONG_SSL_DESCRIPTION, description_replacements, nullptr);
188
189 EXPECT_EQ(secure_description,
190 base::ASCIIToUTF16(secure_explanations.back().description));
166 } 191 }
167 192
168 void CheckSecurityInfoForSecure( 193 void CheckSecurityInfoForSecure(
169 content::WebContents* contents, 194 content::WebContents* contents,
170 SecurityStateModel::SecurityLevel expect_security_level, 195 SecurityStateModel::SecurityLevel expect_security_level,
171 SecurityStateModel::SHA1DeprecationStatus expect_sha1_status, 196 SecurityStateModel::SHA1DeprecationStatus expect_sha1_status,
172 SecurityStateModel::MixedContentStatus expect_mixed_content_status, 197 SecurityStateModel::MixedContentStatus expect_mixed_content_status,
173 bool pkp_bypassed, 198 bool pkp_bypassed,
174 bool expect_cert_error) { 199 bool expect_cert_error) {
175 ASSERT_TRUE(contents); 200 ASSERT_TRUE(contents);
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); 1002 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic);
978 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); 1003 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed);
979 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); 1004 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty());
980 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); 1005 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content);
981 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); 1006 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content);
982 } 1007 }
983 1008
984 // After AddNonsecureUrlHandler() is called, requests to this hostname 1009 // After AddNonsecureUrlHandler() is called, requests to this hostname
985 // will use obsolete TLS settings. 1010 // will use obsolete TLS settings.
986 const char kMockNonsecureHostname[] = "example-nonsecure.test"; 1011 const char kMockNonsecureHostname[] = "example-nonsecure.test";
1012 const int kObsoleteTLSVersion = net::SSL_CONNECTION_VERSION_TLS1_1;
1013 // ECDHE_RSA + AES_128_CBC with HMAC-SHA1
1014 const uint16_t kObsoleteCipherSuite = 0xc013;
987 1015
988 // A URLRequestMockHTTPJob that mocks a TLS connection with an obsolete 1016 // A URLRequestMockHTTPJob that mocks a TLS connection with the obsolete
989 // protocol version. 1017 // TLS settings specified in kObsoleteTLSVersion and
1018 // kObsoleteCipherSuite.
990 class URLRequestObsoleteTLSJob : public net::URLRequestMockHTTPJob { 1019 class URLRequestObsoleteTLSJob : public net::URLRequestMockHTTPJob {
991 public: 1020 public:
992 URLRequestObsoleteTLSJob(net::URLRequest* request, 1021 URLRequestObsoleteTLSJob(net::URLRequest* request,
993 net::NetworkDelegate* network_delegate, 1022 net::NetworkDelegate* network_delegate,
994 const base::FilePath& file_path, 1023 const base::FilePath& file_path,
995 scoped_refptr<net::X509Certificate> cert, 1024 scoped_refptr<net::X509Certificate> cert,
996 scoped_refptr<base::TaskRunner> task_runner) 1025 scoped_refptr<base::TaskRunner> task_runner)
997 : net::URLRequestMockHTTPJob(request, 1026 : net::URLRequestMockHTTPJob(request,
998 network_delegate, 1027 network_delegate,
999 file_path, 1028 file_path,
1000 task_runner), 1029 task_runner),
1001 cert_(std::move(cert)) {} 1030 cert_(std::move(cert)) {}
1002 1031
1003 void GetResponseInfo(net::HttpResponseInfo* info) override { 1032 void GetResponseInfo(net::HttpResponseInfo* info) override {
1004 net::URLRequestMockHTTPJob::GetResponseInfo(info); 1033 net::URLRequestMockHTTPJob::GetResponseInfo(info);
1005 net::SSLConnectionStatusSetVersion(net::SSL_CONNECTION_VERSION_TLS1_1, 1034 net::SSLConnectionStatusSetVersion(kObsoleteTLSVersion,
1006 &info->ssl_info.connection_status); 1035 &info->ssl_info.connection_status);
1007 const uint16_t kTlsEcdheRsaWithAes128CbcSha = 0xc013; 1036 net::SSLConnectionStatusSetCipherSuite(kObsoleteCipherSuite,
1008 net::SSLConnectionStatusSetCipherSuite(kTlsEcdheRsaWithAes128CbcSha,
1009 &info->ssl_info.connection_status); 1037 &info->ssl_info.connection_status);
1010 info->ssl_info.cert = cert_; 1038 info->ssl_info.cert = cert_;
1011 } 1039 }
1012 1040
1013 protected: 1041 protected:
1014 ~URLRequestObsoleteTLSJob() override {} 1042 ~URLRequestObsoleteTLSJob() override {}
1015 1043
1016 private: 1044 private:
1017 const scoped_refptr<net::X509Certificate> cert_; 1045 const scoped_refptr<net::X509Certificate> cert_;
1018 1046
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 // The security style of the page doesn't get downgraded for obsolete 1134 // The security style of the page doesn't get downgraded for obsolete
1107 // TLS settings, so it should remain at SECURITY_STYLE_AUTHENTICATED. 1135 // TLS settings, so it should remain at SECURITY_STYLE_AUTHENTICATED.
1108 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, 1136 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED,
1109 observer.latest_security_style()); 1137 observer.latest_security_style());
1110 1138
1111 // The messages explaining the security style do, however, get 1139 // The messages explaining the security style do, however, get
1112 // downgraded: SECURE_PROTOCOL_AND_CIPHERSUITE should not show up when 1140 // downgraded: SECURE_PROTOCOL_AND_CIPHERSUITE should not show up when
1113 // the TLS settings are obsolete. 1141 // the TLS settings are obsolete.
1114 for (const auto& explanation : 1142 for (const auto& explanation :
1115 observer.latest_explanations().secure_explanations) { 1143 observer.latest_explanations().secure_explanations) {
1116 EXPECT_NE(l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), 1144 EXPECT_NE(l10n_util::GetStringUTF8(IDS_STRONG_SSL_SUMMARY),
1117 explanation.summary); 1145 explanation.summary);
1118 } 1146 }
1147
1148 // Populate description string replacement with values corresponding
1149 // to test constants.
1150 std::vector<base::string16> description_replacements;
1151 description_replacements.push_back(
1152 l10n_util::GetStringUTF16(IDS_SSL_AN_OBSOLETE_PROTOCOL));
1153 description_replacements.push_back(base::ASCIIToUTF16("TLS 1.1"));
1154 description_replacements.push_back(
1155 l10n_util::GetStringUTF16(IDS_SSL_A_STRONG_KEY_EXCHANGE));
1156 description_replacements.push_back(base::ASCIIToUTF16("ECDHE_RSA"));
1157 description_replacements.push_back(
1158 l10n_util::GetStringUTF16(IDS_SSL_AN_OBSOLETE_CIPHER));
1159 description_replacements.push_back(
1160 base::ASCIIToUTF16("AES_128_CBC with HMAC-SHA1"));
1161 base::string16 obsolete_description = l10n_util::GetStringFUTF16(
1162 IDS_OBSOLETE_SSL_DESCRIPTION, description_replacements, nullptr);
1163
1164 EXPECT_EQ(
1165 obsolete_description,
1166 base::ASCIIToUTF16(
1167 observer.latest_explanations().info_explanations[0].description));
1119 } 1168 }
1120 1169
1121 // After AddSCTUrlHandler() is called, requests to this hostname 1170 // After AddSCTUrlHandler() is called, requests to this hostname
1122 // will be served with Signed Certificate Timestamps. 1171 // will be served with Signed Certificate Timestamps.
1123 const char kMockHostnameWithSCTs[] = "example-scts.test"; 1172 const char kMockHostnameWithSCTs[] = "example-scts.test";
1124 1173
1125 // URLRequestJobWithSCTs mocks a connection that includes a set of dummy 1174 // URLRequestJobWithSCTs mocks a connection that includes a set of dummy
1126 // SCTs with these statuses. 1175 // SCTs with these statuses.
1127 const std::vector<net::ct::SCTVerifyStatus> kTestSCTStatuses{ 1176 const std::vector<net::ct::SCTVerifyStatus> kTestSCTStatuses{
1128 net::ct::SCT_STATUS_OK, net::ct::SCT_STATUS_LOG_UNKNOWN, 1177 net::ct::SCT_STATUS_OK, net::ct::SCT_STATUS_LOG_UNKNOWN,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 ChromeSecurityStateModelClient* model_client = 1298 ChromeSecurityStateModelClient* model_client =
1250 ChromeSecurityStateModelClient::FromWebContents(web_contents); 1299 ChromeSecurityStateModelClient::FromWebContents(web_contents);
1251 ASSERT_TRUE(model_client); 1300 ASSERT_TRUE(model_client);
1252 const SecurityStateModel::SecurityInfo& security_info = 1301 const SecurityStateModel::SecurityInfo& security_info =
1253 model_client->GetSecurityInfo(); 1302 model_client->GetSecurityInfo();
1254 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level); 1303 EXPECT_EQ(SecurityStateModel::SECURE, security_info.security_level);
1255 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); 1304 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses);
1256 } 1305 }
1257 1306
1258 } // namespace 1307 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_security_state_model_client.cc ('k') | chrome/browser/ui/website_settings/website_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698