| 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" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 SSLConfig config; | 140 SSLConfig config; |
| 141 config_service->GetSSLConfig(&config); | 141 config_service->GetSSLConfig(&config); |
| 142 | 142 |
| 143 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); | 143 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); |
| 144 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); | 144 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); |
| 145 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); | 145 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); |
| 146 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); | 146 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Test that without command-line settings for minimum and maximum SSL versions, | 149 // Test that without command-line settings for minimum and maximum SSL versions, |
| 150 // SSL 3.0 ~ default_version_max() are enabled. | 150 // SSL 3.0 ~ kDefaultSSLVersionMax are enabled. |
| 151 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { | 151 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { |
| 152 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 152 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
| 153 | 153 |
| 154 PrefServiceMockFactory factory; | 154 PrefServiceMockFactory factory; |
| 155 factory.set_user_prefs(local_state_store); | 155 factory.set_user_prefs(local_state_store); |
| 156 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 156 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
| 157 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); | 157 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
| 158 | 158 |
| 159 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 159 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
| 160 | 160 |
| 161 scoped_ptr<SSLConfigServiceManager> config_manager( | 161 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 162 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 162 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); |
| 163 ASSERT_TRUE(config_manager.get()); | 163 ASSERT_TRUE(config_manager.get()); |
| 164 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 164 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 165 ASSERT_TRUE(config_service.get()); | 165 ASSERT_TRUE(config_service.get()); |
| 166 | 166 |
| 167 SSLConfig ssl_config; | 167 SSLConfig ssl_config; |
| 168 config_service->GetSSLConfig(&ssl_config); | 168 config_service->GetSSLConfig(&ssl_config); |
| 169 // The default value in the absence of command-line options is that | 169 // The default value in the absence of command-line options is that |
| 170 // SSL 3.0 ~ default_version_max() are enabled. | 170 // SSL 3.0 ~ kDefaultSSLVersionMax are enabled. |
| 171 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_min); | 171 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_min); |
| 172 EXPECT_EQ(net::SSLConfigService::default_version_max(), | 172 EXPECT_EQ(net::kDefaultSSLVersionMax, ssl_config.version_max); |
| 173 ssl_config.version_max); | |
| 174 | 173 |
| 175 // The settings should not be added to the local_state. | 174 // The settings should not be added to the local_state. |
| 176 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMin)); | 175 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMin)); |
| 177 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMax)); | 176 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMax)); |
| 178 | 177 |
| 179 // Explicitly double-check the settings are not in the preference store. | 178 // Explicitly double-check the settings are not in the preference store. |
| 180 std::string version_min_str; | 179 std::string version_min_str; |
| 181 std::string version_max_str; | 180 std::string version_max_str; |
| 182 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, | 181 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, |
| 183 &version_min_str)); | 182 &version_min_str)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 local_state->FindPreference(prefs::kSSLVersionMax); | 222 local_state->FindPreference(prefs::kSSLVersionMax); |
| 224 EXPECT_FALSE(version_max_pref->IsUserModifiable()); | 223 EXPECT_FALSE(version_max_pref->IsUserModifiable()); |
| 225 | 224 |
| 226 std::string version_min_str; | 225 std::string version_min_str; |
| 227 std::string version_max_str; | 226 std::string version_max_str; |
| 228 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, | 227 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, |
| 229 &version_min_str)); | 228 &version_min_str)); |
| 230 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, | 229 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, |
| 231 &version_max_str)); | 230 &version_max_str)); |
| 232 } | 231 } |
| OLD | NEW |