| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/test/scoped_feature_list.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "components/prefs/testing_pref_service.h" | 15 #include "components/prefs/testing_pref_service.h" |
| 15 #include "components/ssl_config/ssl_config_prefs.h" | 16 #include "components/ssl_config/ssl_config_prefs.h" |
| 16 #include "components/ssl_config/ssl_config_service_manager.h" | 17 #include "components/ssl_config/ssl_config_service_manager.h" |
| 17 #include "components/ssl_config/ssl_config_switches.h" | 18 #include "components/ssl_config/ssl_config_switches.h" |
| 18 #include "net/ssl/ssl_config.h" | 19 #include "net/ssl/ssl_config.h" |
| 19 #include "net/ssl/ssl_config_service.h" | 20 #include "net/ssl/ssl_config_service.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 175 |
| 175 SSLConfig ssl_config; | 176 SSLConfig ssl_config; |
| 176 config_service->GetSSLConfig(&ssl_config); | 177 config_service->GetSSLConfig(&ssl_config); |
| 177 // The command-line option must not have been honored. | 178 // The command-line option must not have been honored. |
| 178 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); | 179 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); |
| 179 } | 180 } |
| 180 | 181 |
| 181 // Tests that DHE may be re-enabled via features. | 182 // Tests that DHE may be re-enabled via features. |
| 182 TEST_F(SSLConfigServiceManagerPrefTest, DHEFeature) { | 183 TEST_F(SSLConfigServiceManagerPrefTest, DHEFeature) { |
| 183 // Toggle the feature. | 184 // Toggle the feature. |
| 184 base::FeatureList::ClearInstanceForTesting(); | 185 base::test::ScopedFeatureList scoped_feature_list; |
| 185 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 186 scoped_feature_list.InitFromCommandLine("DHECiphers", std::string()); |
| 186 feature_list->InitializeFromCommandLine("DHECiphers", std::string()); | |
| 187 base::FeatureList::SetInstance(std::move(feature_list)); | |
| 188 | 187 |
| 189 TestingPrefServiceSimple local_state; | 188 TestingPrefServiceSimple local_state; |
| 190 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); | 189 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); |
| 191 | 190 |
| 192 std::unique_ptr<SSLConfigServiceManager> config_manager( | 191 std::unique_ptr<SSLConfigServiceManager> config_manager( |
| 193 SSLConfigServiceManager::CreateDefaultManager( | 192 SSLConfigServiceManager::CreateDefaultManager( |
| 194 &local_state, base::ThreadTaskRunnerHandle::Get())); | 193 &local_state, base::ThreadTaskRunnerHandle::Get())); |
| 195 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); | 194 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); |
| 196 ASSERT_TRUE(config_service.get()); | 195 ASSERT_TRUE(config_service.get()); |
| 197 | 196 |
| 198 // The feature should have switched the default version_fallback_min value. | 197 // The feature should have switched the default version_fallback_min value. |
| 199 SSLConfig ssl_config; | 198 SSLConfig ssl_config; |
| 200 config_service->GetSSLConfig(&ssl_config); | 199 config_service->GetSSLConfig(&ssl_config); |
| 201 EXPECT_TRUE(ssl_config.dhe_enabled); | 200 EXPECT_TRUE(ssl_config.dhe_enabled); |
| 202 } | 201 } |
| OLD | NEW |