Chromium Code Reviews| 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. |
|
Ryan Sleevi
2015/09/08 21:02:16
Why is this unit test still in //chrome/browser/ne
Abhishek
2015/09/10 13:32:53
I've tried removing the mentioned dependency, but
| |
| 4 | 4 |
| 5 #include "chrome/browser/net/ssl_config_service_manager.h" | 5 #include "components/ssl_config/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/thread_task_runner_handle.h" | |
| 12 #include "base/values.h" | 13 #include "base/values.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/pref_names.h" | |
| 16 #include "chrome/test/base/testing_pref_service_syncable.h" | |
| 17 #include "chrome/test/base/testing_profile.h" | |
| 18 #include "components/content_settings/core/browser/host_content_settings_map.h" | 15 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 19 #include "components/content_settings/core/common/content_settings.h" | 16 #include "components/content_settings/core/common/content_settings.h" |
| 20 #include "content/public/test/test_browser_thread.h" | 17 #include "components/pref_registry/testing_pref_service_syncable.h" |
| 18 #include "components/ssl_config/ssl_config_prefs.h" | |
| 19 #include "components/ssl_config/ssl_config_switches.h" | |
| 21 #include "net/socket/ssl_client_socket.h" | 20 #include "net/socket/ssl_client_socket.h" |
| 22 #include "net/ssl/ssl_config_service.h" | 21 #include "net/ssl/ssl_config_service.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 23 |
| 25 using base::ListValue; | 24 using base::ListValue; |
| 26 using base::Value; | 25 using base::Value; |
| 27 using content::BrowserThread; | |
| 28 using net::SSLConfig; | 26 using net::SSLConfig; |
| 29 using net::SSLConfigService; | 27 using net::SSLConfigService; |
| 28 using ssl_config::SSLConfigServiceManager; | |
| 30 | 29 |
| 31 class SSLConfigServiceManagerPrefTest : public testing::Test { | 30 class SSLConfigServiceManagerPrefTest : public testing::Test { |
| 32 public: | 31 public: |
| 33 SSLConfigServiceManagerPrefTest() | 32 SSLConfigServiceManagerPrefTest() {} |
| 34 : ui_thread_(BrowserThread::UI, &message_loop_), | |
| 35 io_thread_(BrowserThread::IO, &message_loop_) {} | |
| 36 | 33 |
| 37 protected: | 34 protected: |
| 38 base::MessageLoop message_loop_; | 35 base::MessageLoop message_loop_; |
| 39 content::TestBrowserThread ui_thread_; | |
| 40 content::TestBrowserThread io_thread_; | |
| 41 }; | 36 }; |
| 42 | 37 |
| 43 // Test channel id with no user prefs. | 38 // Test channel id with no user prefs. |
| 44 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithoutUserPrefs) { | 39 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithoutUserPrefs) { |
| 45 TestingPrefServiceSimple local_state; | 40 TestingPrefServiceSimple local_state; |
| 46 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); | 41 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); |
| 47 | 42 |
| 48 scoped_ptr<SSLConfigServiceManager> config_manager( | 43 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 49 SSLConfigServiceManager::CreateDefaultManager(&local_state)); | 44 SSLConfigServiceManager::CreateDefaultManager( |
| 45 &local_state, base::ThreadTaskRunnerHandle::Get())); | |
| 50 ASSERT_TRUE(config_manager.get()); | 46 ASSERT_TRUE(config_manager.get()); |
| 51 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 47 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 52 ASSERT_TRUE(config_service.get()); | 48 ASSERT_TRUE(config_service.get()); |
| 53 | 49 |
| 54 SSLConfig config; | 50 SSLConfig config; |
| 55 config_service->GetSSLConfig(&config); | 51 config_service->GetSSLConfig(&config); |
| 56 EXPECT_TRUE(config.channel_id_enabled); | 52 EXPECT_TRUE(config.channel_id_enabled); |
| 57 } | 53 } |
| 58 | 54 |
| 59 // Test that cipher suites can be disabled. "Good" refers to the fact that | 55 // Test that cipher suites can be disabled. "Good" refers to the fact that |
| 60 // every value is expected to be successfully parsed into a cipher suite. | 56 // every value is expected to be successfully parsed into a cipher suite. |
| 61 TEST_F(SSLConfigServiceManagerPrefTest, GoodDisabledCipherSuites) { | 57 TEST_F(SSLConfigServiceManagerPrefTest, GoodDisabledCipherSuites) { |
| 62 TestingPrefServiceSimple local_state; | 58 TestingPrefServiceSimple local_state; |
| 63 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); | 59 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); |
| 64 | 60 |
| 65 scoped_ptr<SSLConfigServiceManager> config_manager( | 61 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 66 SSLConfigServiceManager::CreateDefaultManager(&local_state)); | 62 SSLConfigServiceManager::CreateDefaultManager( |
| 63 &local_state, base::ThreadTaskRunnerHandle::Get())); | |
| 67 ASSERT_TRUE(config_manager.get()); | 64 ASSERT_TRUE(config_manager.get()); |
| 68 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 65 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 69 ASSERT_TRUE(config_service.get()); | 66 ASSERT_TRUE(config_service.get()); |
| 70 | 67 |
| 71 SSLConfig old_config; | 68 SSLConfig old_config; |
| 72 config_service->GetSSLConfig(&old_config); | 69 config_service->GetSSLConfig(&old_config); |
| 73 EXPECT_TRUE(old_config.disabled_cipher_suites.empty()); | 70 EXPECT_TRUE(old_config.disabled_cipher_suites.empty()); |
| 74 | 71 |
| 75 base::ListValue* list_value = new base::ListValue(); | 72 base::ListValue* list_value = new base::ListValue(); |
| 76 list_value->Append(new base::StringValue("0x0004")); | 73 list_value->Append(new base::StringValue("0x0004")); |
| 77 list_value->Append(new base::StringValue("0x0005")); | 74 list_value->Append(new base::StringValue("0x0005")); |
| 78 local_state.SetUserPref(prefs::kCipherSuiteBlacklist, list_value); | 75 local_state.SetUserPref(ssl_config::prefs::kCipherSuiteBlacklist, list_value); |
| 79 | 76 |
| 80 // Pump the message loop to notify the SSLConfigServiceManagerPref that the | 77 // Pump the message loop to notify the SSLConfigServiceManagerPref that the |
| 81 // preferences changed. | 78 // preferences changed. |
| 82 message_loop_.RunUntilIdle(); | 79 message_loop_.RunUntilIdle(); |
| 83 | 80 |
| 84 SSLConfig config; | 81 SSLConfig config; |
| 85 config_service->GetSSLConfig(&config); | 82 config_service->GetSSLConfig(&config); |
| 86 | 83 |
| 87 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); | 84 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); |
| 88 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); | 85 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); |
| 89 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); | 86 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); |
| 90 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); | 87 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); |
| 91 } | 88 } |
| 92 | 89 |
| 93 // Test that cipher suites can be disabled. "Bad" refers to the fact that | 90 // Test that cipher suites can be disabled. "Bad" refers to the fact that |
| 94 // there are one or more non-cipher suite strings in the preference. They | 91 // there are one or more non-cipher suite strings in the preference. They |
| 95 // should be ignored. | 92 // should be ignored. |
| 96 TEST_F(SSLConfigServiceManagerPrefTest, BadDisabledCipherSuites) { | 93 TEST_F(SSLConfigServiceManagerPrefTest, BadDisabledCipherSuites) { |
| 97 TestingPrefServiceSimple local_state; | 94 TestingPrefServiceSimple local_state; |
| 98 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); | 95 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); |
| 99 | 96 |
| 100 scoped_ptr<SSLConfigServiceManager> config_manager( | 97 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 101 SSLConfigServiceManager::CreateDefaultManager(&local_state)); | 98 SSLConfigServiceManager::CreateDefaultManager( |
| 99 &local_state, base::ThreadTaskRunnerHandle::Get())); | |
| 102 ASSERT_TRUE(config_manager.get()); | 100 ASSERT_TRUE(config_manager.get()); |
| 103 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 101 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 104 ASSERT_TRUE(config_service.get()); | 102 ASSERT_TRUE(config_service.get()); |
| 105 | 103 |
| 106 SSLConfig old_config; | 104 SSLConfig old_config; |
| 107 config_service->GetSSLConfig(&old_config); | 105 config_service->GetSSLConfig(&old_config); |
| 108 EXPECT_TRUE(old_config.disabled_cipher_suites.empty()); | 106 EXPECT_TRUE(old_config.disabled_cipher_suites.empty()); |
| 109 | 107 |
| 110 base::ListValue* list_value = new base::ListValue(); | 108 base::ListValue* list_value = new base::ListValue(); |
| 111 list_value->Append(new base::StringValue("0x0004")); | 109 list_value->Append(new base::StringValue("0x0004")); |
| 112 list_value->Append(new base::StringValue("TLS_NOT_WITH_A_CIPHER_SUITE")); | 110 list_value->Append(new base::StringValue("TLS_NOT_WITH_A_CIPHER_SUITE")); |
| 113 list_value->Append(new base::StringValue("0x0005")); | 111 list_value->Append(new base::StringValue("0x0005")); |
| 114 list_value->Append(new base::StringValue("0xBEEFY")); | 112 list_value->Append(new base::StringValue("0xBEEFY")); |
| 115 local_state.SetUserPref(prefs::kCipherSuiteBlacklist, list_value); | 113 local_state.SetUserPref(ssl_config::prefs::kCipherSuiteBlacklist, list_value); |
| 116 | 114 |
| 117 // Pump the message loop to notify the SSLConfigServiceManagerPref that the | 115 // Pump the message loop to notify the SSLConfigServiceManagerPref that the |
| 118 // preferences changed. | 116 // preferences changed. |
| 119 message_loop_.RunUntilIdle(); | 117 message_loop_.RunUntilIdle(); |
| 120 | 118 |
| 121 SSLConfig config; | 119 SSLConfig config; |
| 122 config_service->GetSSLConfig(&config); | 120 config_service->GetSSLConfig(&config); |
| 123 | 121 |
| 124 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); | 122 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); |
| 125 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); | 123 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); |
| 126 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); | 124 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); |
| 127 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); | 125 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); |
| 128 } | 126 } |
| 129 | 127 |
| 130 // Test that without command-line settings for minimum and maximum SSL versions, | 128 // Test that without command-line settings for minimum and maximum SSL versions, |
| 131 // TLS versions from 1.0 up to 1.1 or 1.2 are enabled. | 129 // TLS versions from 1.0 up to 1.1 or 1.2 are enabled. |
| 132 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { | 130 TEST_F(SSLConfigServiceManagerPrefTest, NoCommandLinePrefs) { |
| 133 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 131 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
| 134 | 132 |
| 135 PrefServiceMockFactory factory; | 133 PrefServiceMockFactory factory; |
| 136 factory.set_user_prefs(local_state_store); | 134 factory.set_user_prefs(local_state_store); |
| 137 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 135 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
| 138 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); | 136 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
| 139 | 137 |
| 140 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 138 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
| 141 | 139 |
| 142 scoped_ptr<SSLConfigServiceManager> config_manager( | 140 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 143 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 141 SSLConfigServiceManager::CreateDefaultManager( |
| 142 local_state.get(), base::ThreadTaskRunnerHandle::Get())); | |
| 144 ASSERT_TRUE(config_manager.get()); | 143 ASSERT_TRUE(config_manager.get()); |
| 145 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 144 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 146 ASSERT_TRUE(config_service.get()); | 145 ASSERT_TRUE(config_service.get()); |
| 147 | 146 |
| 148 SSLConfig ssl_config; | 147 SSLConfig ssl_config; |
| 149 config_service->GetSSLConfig(&ssl_config); | 148 config_service->GetSSLConfig(&ssl_config); |
| 150 // In the absence of command-line options, TLS versions from 1.0 up to 1.1 or | 149 // In the absence of command-line options, TLS versions from 1.0 up to 1.1 or |
| 151 // 1.2 (depending on the underlying library and cryptographic implementation) | 150 // 1.2 (depending on the underlying library and cryptographic implementation) |
| 152 // are enabled. | 151 // are enabled. |
| 153 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); | 152 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); |
| 154 EXPECT_EQ(net::SSLClientSocket::GetMaxSupportedSSLVersion(), | 153 EXPECT_EQ(net::SSLClientSocket::GetMaxSupportedSSLVersion(), |
| 155 ssl_config.version_max); | 154 ssl_config.version_max); |
| 156 | 155 |
| 157 // The settings should not be added to the local_state. | 156 // The settings should not be added to the local_state. |
| 158 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMin)); | 157 EXPECT_FALSE(local_state->HasPrefPath(ssl_config::prefs::kSSLVersionMin)); |
| 159 EXPECT_FALSE(local_state->HasPrefPath(prefs::kSSLVersionMax)); | 158 EXPECT_FALSE(local_state->HasPrefPath(ssl_config::prefs::kSSLVersionMax)); |
| 160 | 159 |
| 161 // Explicitly double-check the settings are not in the preference store. | 160 // Explicitly double-check the settings are not in the preference store. |
| 162 std::string version_min_str; | 161 std::string version_min_str; |
| 163 std::string version_max_str; | 162 std::string version_max_str; |
| 164 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, | 163 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMin, |
| 165 &version_min_str)); | 164 &version_min_str)); |
| 166 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, | 165 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMax, |
| 167 &version_max_str)); | 166 &version_max_str)); |
| 168 } | 167 } |
| 169 | 168 |
| 170 // Test that command-line settings for minimum and maximum SSL versions are | 169 // Test that command-line settings for minimum and maximum SSL versions are |
| 171 // respected and that they do not persist to the preferences files. | 170 // respected and that they do not persist to the preferences files. |
| 172 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { | 171 TEST_F(SSLConfigServiceManagerPrefTest, CommandLinePrefs) { |
| 173 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 172 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
| 174 | 173 |
| 175 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 174 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 176 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1"); | 175 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1"); |
| 177 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1"); | 176 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1"); |
| 178 | 177 |
| 179 PrefServiceMockFactory factory; | 178 PrefServiceMockFactory factory; |
| 180 factory.set_user_prefs(local_state_store); | 179 factory.set_user_prefs(local_state_store); |
| 181 factory.SetCommandLine(&command_line); | 180 factory.SetCommandLine(&command_line); |
| 182 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 181 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
| 183 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); | 182 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
| 184 | 183 |
| 185 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 184 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
| 186 | 185 |
| 187 scoped_ptr<SSLConfigServiceManager> config_manager( | 186 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 188 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 187 SSLConfigServiceManager::CreateDefaultManager( |
| 188 local_state.get(), base::ThreadTaskRunnerHandle::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_1, ssl_config.version_min); | 196 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_1, ssl_config.version_min); |
| 197 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, 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(ssl_config::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(ssl_config::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(ssl_config::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(ssl_config::prefs::kSSLVersionMax, |
| 213 &version_max_str)); | 213 &version_max_str)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Tests that "ssl3" is not treated as a valid minimum version. | 216 // Tests that "ssl3" is not treated as a valid minimum version. |
| 217 TEST_F(SSLConfigServiceManagerPrefTest, NoSSL3) { | 217 TEST_F(SSLConfigServiceManagerPrefTest, NoSSL3) { |
| 218 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 218 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
| 219 | 219 |
| 220 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 220 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 221 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "ssl3"); | 221 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "ssl3"); |
| 222 | 222 |
| 223 PrefServiceMockFactory factory; | 223 PrefServiceMockFactory factory; |
| 224 factory.set_user_prefs(local_state_store); | 224 factory.set_user_prefs(local_state_store); |
| 225 factory.SetCommandLine(&command_line); | 225 factory.SetCommandLine(&command_line); |
| 226 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 226 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
| 227 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); | 227 scoped_ptr<PrefService> local_state(factory.Create(registry.get())); |
| 228 | 228 |
| 229 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 229 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
| 230 | 230 |
| 231 scoped_ptr<SSLConfigServiceManager> config_manager( | 231 scoped_ptr<SSLConfigServiceManager> config_manager( |
| 232 SSLConfigServiceManager::CreateDefaultManager(local_state.get())); | 232 SSLConfigServiceManager::CreateDefaultManager( |
| 233 local_state.get(), base::ThreadTaskRunnerHandle::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 |