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

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

Issue 1139013002: Completely remove SSLv3 support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/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"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, 166 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax,
167 &version_max_str)); 167 &version_max_str));
168 } 168 }
169 169
170 // Test that command-line settings for minimum and maximum SSL versions are 170 // Test that command-line settings for minimum and maximum SSL versions are
171 // respected and that they do not persist to the preferences files. 171 // respected and that they do not persist to the preferences files.
172 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { 172 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) {
173 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 173 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
174 174
175 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 175 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
176 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1"); 176 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1");
177 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "ssl3"); 177 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1");
178 178
179 PrefServiceMockFactory factory; 179 PrefServiceMockFactory factory;
180 factory.set_user_prefs(local_state_store); 180 factory.set_user_prefs(local_state_store);
181 factory.SetCommandLine(&command_line); 181 factory.SetCommandLine(&command_line);
182 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; 182 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
183 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); 183 scoped_ptr<PrefService> local_state(factory.Create(registry.get()));
184 184
185 SSLConfigServiceManager::RegisterPrefs(registry.get()); 185 SSLConfigServiceManager::RegisterPrefs(registry.get());
186 186
187 scoped_ptr<SSLConfigServiceManager> config_manager( 187 scoped_ptr<SSLConfigServiceManager> config_manager(
188 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); 188 SSLConfigServiceManager::CreateDefaultManager(local_state.get()));
189 ASSERT_TRUE(config_manager.get()); 189 ASSERT_TRUE(config_manager.get());
190 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 190 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
191 ASSERT_TRUE(config_service.get()); 191 ASSERT_TRUE(config_service.get());
192 192
193 SSLConfig ssl_config; 193 SSLConfig ssl_config;
194 config_service->GetSSLConfig(&ssl_config); 194 config_service->GetSSLConfig(&ssl_config);
195 // Command-line flags should be respected. 195 // Command-line flags should be respected.
196 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); 196 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_1, ssl_config.version_min);
197 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max); 197 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_max);
198 198
199 // Explicitly double-check the settings are not in the preference store. 199 // Explicitly double-check the settings are not in the preference store.
200 const PrefService::Preference* version_min_pref = 200 const PrefService::Preference* version_min_pref =
201 local_state->FindPreference(prefs::kSSLVersionMin); 201 local_state->FindPreference(prefs::kSSLVersionMin);
202 EXPECT_FALSE(version_min_pref->IsUserModifiable()); 202 EXPECT_FALSE(version_min_pref->IsUserModifiable());
203 203
204 const PrefService::Preference* version_max_pref = 204 const PrefService::Preference* version_max_pref =
205 local_state->FindPreference(prefs::kSSLVersionMax); 205 local_state->FindPreference(prefs::kSSLVersionMax);
206 EXPECT_FALSE(version_max_pref->IsUserModifiable()); 206 EXPECT_FALSE(version_max_pref->IsUserModifiable());
207 207
208 std::string version_min_str; 208 std::string version_min_str;
209 std::string version_max_str; 209 std::string version_max_str;
210 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, 210 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin,
211 &version_min_str)); 211 &version_min_str));
212 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, 212 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax,
213 &version_max_str)); 213 &version_max_str));
214 } 214 }
215
216 // Tests that "ssl3" is not treated as a valid minimum version.
217 TEST_F(SSLConfigServiceManagerPrefTest, NoSSL3) {
218 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
219
220 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
221 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "ssl3");
222
223 PrefServiceMockFactory factory;
224 factory.set_user_prefs(local_state_store);
225 factory.SetCommandLine(&command_line);
226 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
227 scoped_ptr<PrefService> local_state(factory.Create(registry.get()));
228
229 SSLConfigServiceManager::RegisterPrefs(registry.get());
230
231 scoped_ptr<SSLConfigServiceManager> config_manager(
232 SSLConfigServiceManager::CreateDefaultManager(local_state.get()));
233 ASSERT_TRUE(config_manager.get());
234 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
235 ASSERT_TRUE(config_service.get());
236
237 SSLConfig ssl_config;
238 config_service->GetSSLConfig(&ssl_config);
239 // The command-line option must not have been honored.
240 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min);
241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698