| OLD | NEW |
| 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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/prefs/testing_pref_store.h" | 11 #include "base/prefs/testing_pref_store.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/prefs/command_line_pref_store.h" |
| 13 #include "chrome/browser/prefs/pref_service_mock_factory.h" | 14 #include "chrome/browser/prefs/pref_service_mock_factory.h" |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/test/base/testing_pref_service_syncable.h" | 17 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 18 #include "components/content_settings/core/browser/host_content_settings_map.h" | 19 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 19 #include "components/content_settings/core/common/content_settings.h" | 20 #include "components/content_settings/core/common/content_settings.h" |
| 20 #include "content/public/test/test_browser_thread.h" | 21 #include "content/public/test/test_browser_thread.h" |
| 21 #include "net/socket/ssl_client_socket.h" | 22 #include "net/socket/ssl_client_socket.h" |
| 22 #include "net/ssl/ssl_config_service.h" | 23 #include "net/ssl/ssl_config_service.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // respected and that they do not persist to the preferences files. | 172 // respected and that they do not persist to the preferences files. |
| 172 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { | 173 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { |
| 173 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 174 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
| 174 | 175 |
| 175 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 176 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 176 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1"); | 177 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1"); |
| 177 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1"); | 178 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1"); |
| 178 | 179 |
| 179 PrefServiceMockFactory factory; | 180 PrefServiceMockFactory factory; |
| 180 factory.set_user_prefs(local_state_store); | 181 factory.set_user_prefs(local_state_store); |
| 181 factory.SetCommandLine(&command_line); | 182 factory.set_command_line_prefs(new CommandLinePrefStore(&command_line)); |
| 182 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 183 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
| 183 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); | 184 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
| 184 | 185 |
| 185 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 186 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
| 186 | 187 |
| 187 scoped_ptr<SSLConfigServiceManager> config_manager( | 188 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 188 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 189 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); |
| 189 ASSERT_TRUE(config_manager.get()); | 190 ASSERT_TRUE(config_manager.get()); |
| 190 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 191 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 191 ASSERT_TRUE(config_service.get()); | 192 ASSERT_TRUE(config_service.get()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 215 | 216 |
| 216 // Tests that "ssl3" is not treated as a valid minimum version. | 217 // Tests that "ssl3" is not treated as a valid minimum version. |
| 217 TEST_F(SSLConfigServiceManagerPrefTest, NoSSL3) { | 218 TEST_F(SSLConfigServiceManagerPrefTest, NoSSL3) { |
| 218 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 219 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
| 219 | 220 |
| 220 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 221 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 221 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "ssl3"); | 222 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "ssl3"); |
| 222 | 223 |
| 223 PrefServiceMockFactory factory; | 224 PrefServiceMockFactory factory; |
| 224 factory.set_user_prefs(local_state_store); | 225 factory.set_user_prefs(local_state_store); |
| 225 factory.SetCommandLine(&command_line); | 226 factory.set_command_line_prefs(new CommandLinePrefStore(&command_line)); |
| 226 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 227 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
| 227 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); | 228 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
| 228 | 229 |
| 229 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 230 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
| 230 | 231 |
| 231 scoped_ptr<SSLConfigServiceManager> config_manager( | 232 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 232 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 233 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); |
| 233 ASSERT_TRUE(config_manager.get()); | 234 ASSERT_TRUE(config_manager.get()); |
| 234 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 235 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 235 ASSERT_TRUE(config_service.get()); | 236 ASSERT_TRUE(config_service.get()); |
| 236 | 237 |
| 237 SSLConfig ssl_config; | 238 SSLConfig ssl_config; |
| 238 config_service->GetSSLConfig(&ssl_config); | 239 config_service->GetSSLConfig(&ssl_config); |
| 239 // The command-line option must not have been honored. | 240 // The command-line option must not have been honored. |
| 240 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); | 241 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); |
| 241 } | 242 } |
| OLD | NEW |