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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 | Annotate | Revision Log
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/testing_pref_store.h" 10 #include "base/prefs/testing_pref_store.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return config.channel_id_enabled; 53 return config.channel_id_enabled;
54 } 54 }
55 55
56 MessageLoop message_loop_; 56 MessageLoop message_loop_;
57 content::TestBrowserThread ui_thread_; 57 content::TestBrowserThread ui_thread_;
58 content::TestBrowserThread io_thread_; 58 content::TestBrowserThread io_thread_;
59 }; 59 };
60 60
61 // Test channel id with no user prefs. 61 // Test channel id with no user prefs.
62 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithoutUserPrefs) { 62 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithoutUserPrefs) {
63 TestingPrefService local_state; 63 TestingPrefServiceSimple local_state;
64 SSLConfigServiceManager::RegisterPrefs(&local_state); 64 SSLConfigServiceManager::RegisterPrefs(&local_state);
65 local_state.SetUserPref(prefs::kEnableOriginBoundCerts, 65 local_state.SetUserPref(prefs::kEnableOriginBoundCerts,
66 Value::CreateBooleanValue(false)); 66 Value::CreateBooleanValue(false));
67 67
68 scoped_ptr<SSLConfigServiceManager> config_manager( 68 scoped_ptr<SSLConfigServiceManager> config_manager(
69 SSLConfigServiceManager::CreateDefaultManager(&local_state, NULL)); 69 SSLConfigServiceManager::CreateDefaultManager(&local_state, NULL));
70 ASSERT_TRUE(config_manager.get()); 70 ASSERT_TRUE(config_manager.get());
71 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 71 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
72 ASSERT_TRUE(config_service.get()); 72 ASSERT_TRUE(config_service.get());
73 73
74 SSLConfig config; 74 SSLConfig config;
75 config_service->GetSSLConfig(&config); 75 config_service->GetSSLConfig(&config);
76 EXPECT_FALSE(config.channel_id_enabled); 76 EXPECT_FALSE(config.channel_id_enabled);
77 77
78 local_state.SetUserPref(prefs::kEnableOriginBoundCerts, 78 local_state.SetUserPref(prefs::kEnableOriginBoundCerts,
79 Value::CreateBooleanValue(true)); 79 Value::CreateBooleanValue(true));
80 // Pump the message loop to notify the SSLConfigServiceManagerPref that the 80 // Pump the message loop to notify the SSLConfigServiceManagerPref that the
81 // preferences changed. 81 // preferences changed.
82 message_loop_.RunUntilIdle(); 82 message_loop_.RunUntilIdle();
83 config_service->GetSSLConfig(&config); 83 config_service->GetSSLConfig(&config);
84 EXPECT_TRUE(config.channel_id_enabled); 84 EXPECT_TRUE(config.channel_id_enabled);
85 } 85 }
86 86
87 // Test channel id with user prefs. 87 // Test channel id with user prefs.
88 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithUserPrefs) { 88 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithUserPrefs) {
89 TestingPrefService local_state; 89 TestingPrefServiceSimple local_state;
90 SSLConfigServiceManager::RegisterPrefs(&local_state); 90 SSLConfigServiceManager::RegisterPrefs(&local_state);
91 local_state.SetUserPref(prefs::kEnableOriginBoundCerts, 91 local_state.SetUserPref(prefs::kEnableOriginBoundCerts,
92 Value::CreateBooleanValue(false)); 92 Value::CreateBooleanValue(false));
93 93
94 TestingProfile testing_profile; 94 TestingProfile testing_profile;
95 TestingPrefService* user_prefs = testing_profile.GetTestingPrefService(); 95 TestingPrefServiceSyncable* user_prefs =
96 testing_profile.GetTestingPrefService();
96 SetCookiePref(&testing_profile, CONTENT_SETTING_BLOCK); 97 SetCookiePref(&testing_profile, CONTENT_SETTING_BLOCK);
97 user_prefs->SetUserPref(prefs::kBlockThirdPartyCookies, 98 user_prefs->SetUserPref(prefs::kBlockThirdPartyCookies,
98 Value::CreateBooleanValue(true)); 99 Value::CreateBooleanValue(true));
99 100
100 scoped_ptr<SSLConfigServiceManager> config_manager( 101 scoped_ptr<SSLConfigServiceManager> config_manager(
101 SSLConfigServiceManager::CreateDefaultManager(&local_state, user_prefs)); 102 SSLConfigServiceManager::CreateDefaultManager(&local_state, user_prefs));
102 ASSERT_TRUE(config_manager.get()); 103 ASSERT_TRUE(config_manager.get());
103 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 104 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
104 ASSERT_TRUE(config_service.get()); 105 ASSERT_TRUE(config_service.get());
105 106
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 // channelid=true, cookies=allow, 3rdpartycookies=allow 145 // channelid=true, cookies=allow, 3rdpartycookies=allow
145 user_prefs->SetUserPref(prefs::kBlockThirdPartyCookies, 146 user_prefs->SetUserPref(prefs::kBlockThirdPartyCookies,
146 Value::CreateBooleanValue(false)); 147 Value::CreateBooleanValue(false));
147 EXPECT_TRUE(IsChannelIdEnabled(config_service)); 148 EXPECT_TRUE(IsChannelIdEnabled(config_service));
148 } 149 }
149 150
150 // Test that cipher suites can be disabled. "Good" refers to the fact that 151 // Test that cipher suites can be disabled. "Good" refers to the fact that
151 // every value is expected to be successfully parsed into a cipher suite. 152 // every value is expected to be successfully parsed into a cipher suite.
152 TEST_F(SSLConfigServiceManagerPrefTest, GoodDisabledCipherSuites) { 153 TEST_F(SSLConfigServiceManagerPrefTest, GoodDisabledCipherSuites) {
153 TestingPrefService local_state; 154 TestingPrefServiceSimple local_state;
154 SSLConfigServiceManager::RegisterPrefs(&local_state); 155 SSLConfigServiceManager::RegisterPrefs(&local_state);
155 156
156 scoped_ptr<SSLConfigServiceManager> config_manager( 157 scoped_ptr<SSLConfigServiceManager> config_manager(
157 SSLConfigServiceManager::CreateDefaultManager(&local_state, NULL)); 158 SSLConfigServiceManager::CreateDefaultManager(&local_state, NULL));
158 ASSERT_TRUE(config_manager.get()); 159 ASSERT_TRUE(config_manager.get());
159 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 160 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
160 ASSERT_TRUE(config_service.get()); 161 ASSERT_TRUE(config_service.get());
161 162
162 SSLConfig old_config; 163 SSLConfig old_config;
163 config_service->GetSSLConfig(&old_config); 164 config_service->GetSSLConfig(&old_config);
(...skipping 14 matching lines...) Expand all
178 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); 179 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites);
179 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); 180 ASSERT_EQ(2u, config.disabled_cipher_suites.size());
180 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); 181 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]);
181 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); 182 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]);
182 } 183 }
183 184
184 // Test that cipher suites can be disabled. "Bad" refers to the fact that 185 // Test that cipher suites can be disabled. "Bad" refers to the fact that
185 // there are one or more non-cipher suite strings in the preference. They 186 // there are one or more non-cipher suite strings in the preference. They
186 // should be ignored. 187 // should be ignored.
187 TEST_F(SSLConfigServiceManagerPrefTest, BadDisabledCipherSuites) { 188 TEST_F(SSLConfigServiceManagerPrefTest, BadDisabledCipherSuites) {
188 TestingPrefService local_state; 189 TestingPrefServiceSimple local_state;
189 SSLConfigServiceManager::RegisterPrefs(&local_state); 190 SSLConfigServiceManager::RegisterPrefs(&local_state);
190 191
191 scoped_ptr<SSLConfigServiceManager> config_manager( 192 scoped_ptr<SSLConfigServiceManager> config_manager(
192 SSLConfigServiceManager::CreateDefaultManager(&local_state, NULL)); 193 SSLConfigServiceManager::CreateDefaultManager(&local_state, NULL));
193 ASSERT_TRUE(config_manager.get()); 194 ASSERT_TRUE(config_manager.get());
194 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 195 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
195 ASSERT_TRUE(config_service.get()); 196 ASSERT_TRUE(config_service.get());
196 197
197 SSLConfig old_config; 198 SSLConfig old_config;
198 config_service->GetSSLConfig(&old_config); 199 config_service->GetSSLConfig(&old_config);
(...skipping 19 matching lines...) Expand all
218 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); 219 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]);
219 } 220 }
220 221
221 // Test that without command-line settings for minimum and maximum SSL 222 // Test that without command-line settings for minimum and maximum SSL
222 // versions, SSL 3.0 ~ default_version_max() are enabled. 223 // versions, SSL 3.0 ~ default_version_max() are enabled.
223 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { 224 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) {
224 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 225 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
225 226
226 PrefServiceMockBuilder builder; 227 PrefServiceMockBuilder builder;
227 builder.WithUserPrefs(local_state_store.get()); 228 builder.WithUserPrefs(local_state_store.get());
228 scoped_ptr<PrefService> local_state(builder.Create()); 229 scoped_ptr<PrefServiceSimple> local_state(builder.CreateSimple());
229 230
230 SSLConfigServiceManager::RegisterPrefs(local_state.get()); 231 SSLConfigServiceManager::RegisterPrefs(local_state.get());
231 232
232 scoped_ptr<SSLConfigServiceManager> config_manager( 233 scoped_ptr<SSLConfigServiceManager> config_manager(
233 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL)); 234 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL));
234 ASSERT_TRUE(config_manager.get()); 235 ASSERT_TRUE(config_manager.get());
235 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 236 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
236 ASSERT_TRUE(config_service.get()); 237 ASSERT_TRUE(config_service.get());
237 238
238 SSLConfig ssl_config; 239 SSLConfig ssl_config;
(...skipping 22 matching lines...) Expand all
261 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { 262 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) {
262 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 263 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
263 264
264 CommandLine command_line(CommandLine::NO_PROGRAM); 265 CommandLine command_line(CommandLine::NO_PROGRAM);
265 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1"); 266 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1");
266 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3"); 267 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3");
267 268
268 PrefServiceMockBuilder builder; 269 PrefServiceMockBuilder builder;
269 builder.WithUserPrefs(local_state_store.get()); 270 builder.WithUserPrefs(local_state_store.get());
270 builder.WithCommandLine(&command_line); 271 builder.WithCommandLine(&command_line);
271 scoped_ptr<PrefService> local_state(builder.Create()); 272 scoped_ptr<PrefServiceSimple> local_state(builder.CreateSimple());
272 273
273 SSLConfigServiceManager::RegisterPrefs(local_state.get()); 274 SSLConfigServiceManager::RegisterPrefs(local_state.get());
274 275
275 scoped_ptr<SSLConfigServiceManager> config_manager( 276 scoped_ptr<SSLConfigServiceManager> config_manager(
276 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL)); 277 SSLConfigServiceManager::CreateDefaultManager(local_state.get(), NULL));
277 ASSERT_TRUE(config_manager.get()); 278 ASSERT_TRUE(config_manager.get());
278 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 279 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
279 ASSERT_TRUE(config_service.get()); 280 ASSERT_TRUE(config_service.get());
280 281
281 SSLConfig ssl_config; 282 SSLConfig ssl_config;
(...skipping 11 matching lines...) Expand all
293 local_state->FindPreference(prefs::kSSLVersionMax); 294 local_state->FindPreference(prefs::kSSLVersionMax);
294 EXPECT_FALSE(version_max_pref->IsUserModifiable()); 295 EXPECT_FALSE(version_max_pref->IsUserModifiable());
295 296
296 std::string version_min_str; 297 std::string version_min_str;
297 std::string version_max_str; 298 std::string version_max_str;
298 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, 299 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin,
299 &version_min_str)); 300 &version_min_str));
300 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, 301 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax,
301 &version_max_str)); 302 &version_max_str));
302 } 303 }
OLDNEW
« no previous file with comments | « chrome/browser/net/ssl_config_service_manager_pref.cc ('k') | chrome/browser/notifications/desktop_notifications_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698