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

Side by Side Diff: chrome/browser/net/ssl_config_service_manager_pref_unittest.cc

Issue 14125003: Do not roll back to SSL 3.0 for Google properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove learning mode. Enforce TLS for Google's properties. Created 7 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/net/ssl_config_service_manager.h" 5 #include "chrome/browser/net/ssl_config_service_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 SSLConfig config; 214 SSLConfig config;
215 config_service->GetSSLConfig(&config); 215 config_service->GetSSLConfig(&config);
216 216
217 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); 217 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites);
218 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); 218 ASSERT_EQ(2u, config.disabled_cipher_suites.size());
219 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); 219 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]);
220 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); 220 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]);
221 } 221 }
222 222
223 // Test that without command-line settings for minimum and maximum SSL 223 // Test that without command-line settings:
224 // versions, SSL 3.0 ~ default_version_max() are enabled. 224 // * for minimum and maximum SSL versions, SSL 3.0 ~ default_version_max() are
225 // enabled;
226 // * |ssl_version_min_preloaded_disabled| is false;
227 // * |ssl_version_min_learning_enabled| is false.
agl 2013/04/15 15:23:51 This comment line looks to be a left-over.
thaidn_google 2013/04/16 00:38:16 Done.
225 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { 228 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) {
226 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 229 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
227 230
228 PrefServiceMockBuilder builder; 231 PrefServiceMockBuilder builder;
229 builder.WithUserPrefs(local_state_store.get()); 232 builder.WithUserPrefs(local_state_store.get());
230 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; 233 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
231 scoped_ptr<PrefService> local_state(builder.Create(registry)); 234 scoped_ptr<PrefService> local_state(builder.Create(registry));
232 235
233 SSLConfigServiceManager::RegisterPrefs(registry); 236 SSLConfigServiceManager::RegisterPrefs(registry);
234 237
235 scoped_ptr<SSLConfigServiceManager> config_manager( 238 scoped_ptr<SSLConfigServiceManager> config_manager(
236 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL)); 239 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL));
237 ASSERT_TRUE(config_manager.get()); 240 ASSERT_TRUE(config_manager.get());
238 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 241 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
239 ASSERT_TRUE(config_service.get()); 242 ASSERT_TRUE(config_service.get());
240 243
241 SSLConfig ssl_config; 244 SSLConfig ssl_config;
242 config_service->GetSSLConfig(&ssl_config); 245 config_service->GetSSLConfig(&ssl_config);
243 // The default value in the absence of command-line options is that 246 // The default value in the absence of command-line options is that
244 // SSL 3.0 ~ default_version_max() are enabled. 247 // SSL 3.0 ~ default_version_max() are enabled.
245 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_min); 248 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_min);
246 EXPECT_EQ(net::SSLConfigService::default_version_max(), 249 EXPECT_EQ(net::SSLConfigService::default_version_max(),
247 ssl_config.version_max); 250 ssl_config.version_max);
251 EXPECT_FALSE(ssl_config.ssl_version_min_preloaded_disabled);
248 252
249 // The settings should not be added to the local_state. 253 // The settings should not be added to the local_state.
250 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMin)); 254 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMin));
251 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMax)); 255 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMax));
256 EXPECT_FALSE(local_state->HasPrefPath(
257 prefs::kDisableSSLVersionMinPreloaded));
252 258
253 // Explicitly double-check the settings are not in the preference store. 259 // Explicitly double-check the settings are not in the preference store.
254 std::string version_min_str; 260 std::string version_min_str;
255 std::string version_max_str; 261 std::string version_max_str;
256 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, 262 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin,
257 &version_min_str)); 263 &version_min_str));
258 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, 264 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax,
259 &version_max_str)); 265 &version_max_str));
266 bool tmp;
agl 2013/04/15 15:23:51 I'd use a real variable name rather than just |tmp
thaidn_google 2013/04/16 00:38:16 Done.
267 EXPECT_FALSE(local_state_store->GetBoolean(
268 prefs::kDisableSSLVersionMinPreloaded,
269 &tmp));
260 } 270 }
261 271
262 // Test that command-line settings for minimum and maximum SSL versions are 272 // Test that command-line settings for minimum and maximum SSL versions are
263 // respected and that they do not persist to the preferences files. 273 // respected and that they do not persist to the preferences files.
264 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { 274 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) {
265 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 275 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
266 276
267 CommandLine command_line(CommandLine::NO_PROGRAM); 277 CommandLine command_line(CommandLine::NO_PROGRAM);
268 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1"); 278 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1");
269 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3"); 279 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3");
280 command_line.AppendSwitch(switches::kDisableSSLVersionMinPreloaded);
270 281
271 PrefServiceMockBuilder builder; 282 PrefServiceMockBuilder builder;
272 builder.WithUserPrefs(local_state_store.get()); 283 builder.WithUserPrefs(local_state_store.get());
273 builder.WithCommandLine(&command_line); 284 builder.WithCommandLine(&command_line);
274 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; 285 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
275 scoped_ptr<PrefService> local_state(builder.Create(registry)); 286 scoped_ptr<PrefService> local_state(builder.Create(registry));
276 287
277 SSLConfigServiceManager::RegisterPrefs(registry); 288 SSLConfigServiceManager::RegisterPrefs(registry);
278 289
279 scoped_ptr<SSLConfigServiceManager> config_manager( 290 scoped_ptr<SSLConfigServiceManager> config_manager(
280 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL)); 291 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL));
281 ASSERT_TRUE(config_manager.get()); 292 ASSERT_TRUE(config_manager.get());
282 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 293 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
283 ASSERT_TRUE(config_service.get()); 294 ASSERT_TRUE(config_service.get());
284 295
285 SSLConfig ssl_config; 296 SSLConfig ssl_config;
286 config_service->GetSSLConfig(&ssl_config); 297 config_service->GetSSLConfig(&ssl_config);
287 // Command-line flags should be respected. 298 // Command-line flags should be respected.
288 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); 299 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min);
289 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max); 300 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max);
301 EXPECT_TRUE(ssl_config.ssl_version_min_preloaded_disabled);
290 302
291 // Explicitly double-check the settings are not in the preference store. 303 // Explicitly double-check the settings are not in the preference store.
292 const PrefService::Preference* version_min_pref = 304 const PrefService::Preference* version_min_pref =
293 local_state->FindPreference(prefs::kSSLVersionMin); 305 local_state->FindPreference(prefs::kSSLVersionMin);
294 EXPECT_FALSE(version_min_pref->IsUserModifiable()); 306 EXPECT_FALSE(version_min_pref->IsUserModifiable());
295 307
296 const PrefService::Preference* version_max_pref = 308 const PrefService::Preference* version_max_pref =
297 local_state->FindPreference(prefs::kSSLVersionMax); 309 local_state->FindPreference(prefs::kSSLVersionMax);
298 EXPECT_FALSE(version_max_pref->IsUserModifiable()); 310 EXPECT_FALSE(version_max_pref->IsUserModifiable());
299 311
312 const PrefService::Preference* preloaded_pref =
313 local_state->FindPreference(prefs::kDisableSSLVersionMinPreloaded);
314 EXPECT_FALSE(preloaded_pref->IsUserModifiable());
315
300 std::string version_min_str; 316 std::string version_min_str;
301 std::string version_max_str; 317 std::string version_max_str;
302 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, 318 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin,
303 &version_min_str)); 319 &version_min_str));
304 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, 320 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax,
305 &version_max_str)); 321 &version_max_str));
322 bool tmp;
agl 2013/04/15 15:23:51 ditto.
thaidn_google 2013/04/16 00:38:16 Done.
323 EXPECT_FALSE(local_state_store->GetBoolean(
324 prefs::kDisableSSLVersionMinPreloaded,
325 &tmp));
306 } 326 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698