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/content_settings/host_content_settings_map.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map.h" |
14 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 14 #include "chrome/browser/prefs/pref_service_mock_factory.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/content_settings.h" | 16 #include "chrome/common/content_settings.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chrome/test/base/testing_pref_service_syncable.h" | 18 #include "chrome/test/base/testing_pref_service_syncable.h" |
19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
20 #include "content/public/test/test_browser_thread.h" | 20 #include "content/public/test/test_browser_thread.h" |
21 #include "net/ssl/ssl_config_service.h" | 21 #include "net/ssl/ssl_config_service.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 using base::ListValue; | 24 using base::ListValue; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 // Test that | 148 // Test that |
149 // * without command-line settings for minimum and maximum SSL versions, | 149 // * without command-line settings for minimum and maximum SSL versions, |
150 // SSL 3.0 ~ default_version_max() are enabled; | 150 // SSL 3.0 ~ default_version_max() are enabled; |
151 // * without --enable-unrestricted-ssl3-fallback, | 151 // * without --enable-unrestricted-ssl3-fallback, |
152 // |unrestricted_ssl3_fallback_enabled| is false. | 152 // |unrestricted_ssl3_fallback_enabled| is false. |
153 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { | 153 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { |
154 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 154 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
155 | 155 |
156 PrefServiceMockBuilder builder; | 156 PrefServiceMockFactory factory; |
157 builder.WithUserPrefs(local_state_store.get()); | 157 factory.set_user_prefs(local_state_store); |
158 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 158 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
159 scoped_ptr<PrefService> local_state(builder.Create(registry.get())); | 159 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
160 | 160 |
161 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 161 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
162 | 162 |
163 scoped_ptr<SSLConfigServiceManager> config_manager( | 163 scoped_ptr<SSLConfigServiceManager> config_manager( |
164 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 164 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); |
165 ASSERT_TRUE(config_manager.get()); | 165 ASSERT_TRUE(config_manager.get()); |
166 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 166 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
167 ASSERT_TRUE(config_service.get()); | 167 ASSERT_TRUE(config_service.get()); |
168 | 168 |
169 SSLConfig ssl_config; | 169 SSLConfig ssl_config; |
(...skipping 27 matching lines...) Expand all Loading... |
197 // Test that command-line settings for minimum and maximum SSL versions are | 197 // Test that command-line settings for minimum and maximum SSL versions are |
198 // respected and that they do not persist to the preferences files. | 198 // respected and that they do not persist to the preferences files. |
199 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { | 199 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { |
200 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 200 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
201 | 201 |
202 CommandLine command_line(CommandLine::NO_PROGRAM); | 202 CommandLine command_line(CommandLine::NO_PROGRAM); |
203 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1"); | 203 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1"); |
204 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3"); | 204 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3"); |
205 command_line.AppendSwitch(switches::kEnableUnrestrictedSSL3Fallback); | 205 command_line.AppendSwitch(switches::kEnableUnrestrictedSSL3Fallback); |
206 | 206 |
207 PrefServiceMockBuilder builder; | 207 PrefServiceMockFactory factory; |
208 builder.WithUserPrefs(local_state_store.get()); | 208 factory.set_user_prefs(local_state_store); |
209 builder.WithCommandLine(&command_line); | 209 factory.SetCommandLine(&command_line); |
210 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 210 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
211 scoped_ptr<PrefService> local_state(builder.Create(registry.get())); | 211 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
212 | 212 |
213 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 213 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
214 | 214 |
215 scoped_ptr<SSLConfigServiceManager> config_manager( | 215 scoped_ptr<SSLConfigServiceManager> config_manager( |
216 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 216 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); |
217 ASSERT_TRUE(config_manager.get()); | 217 ASSERT_TRUE(config_manager.get()); |
218 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 218 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
219 ASSERT_TRUE(config_service.get()); | 219 ASSERT_TRUE(config_service.get()); |
220 | 220 |
221 SSLConfig ssl_config; | 221 SSLConfig ssl_config; |
(...skipping 20 matching lines...) Expand all Loading... |
242 std::string version_max_str; | 242 std::string version_max_str; |
243 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, | 243 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, |
244 &version_min_str)); | 244 &version_min_str)); |
245 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, | 245 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, |
246 &version_max_str)); | 246 &version_max_str)); |
247 bool unrestricted_ssl3_fallback_enabled; | 247 bool unrestricted_ssl3_fallback_enabled; |
248 EXPECT_FALSE(local_state_store->GetBoolean( | 248 EXPECT_FALSE(local_state_store->GetBoolean( |
249 prefs::kEnableUnrestrictedSSL3Fallback, | 249 prefs::kEnableUnrestrictedSSL3Fallback, |
250 &unrestricted_ssl3_fallback_enabled)); | 250 &unrestricted_ssl3_fallback_enabled)); |
251 } | 251 } |
OLD | NEW |