OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "chrome/browser/prefs/chrome_command_line_pref_store.h" | 8 #include "chrome/browser/prefs/chrome_command_line_pref_store.h" |
9 #include "components/prefs/pref_registry_simple.h" | 9 #include "components/prefs/pref_registry_simple.h" |
10 #include "components/prefs/pref_service.h" | 10 #include "components/prefs/pref_service.h" |
11 #include "components/prefs/testing_pref_store.h" | 11 #include "components/prefs/testing_pref_store.h" |
12 #include "components/ssl_config/ssl_config_prefs.h" | 12 #include "components/ssl_config/ssl_config_prefs.h" |
13 #include "components/ssl_config/ssl_config_service_manager.h" | 13 #include "components/ssl_config/ssl_config_service_manager.h" |
14 #include "components/ssl_config/ssl_config_switches.h" | 14 #include "components/ssl_config/ssl_config_switches.h" |
15 #include "components/syncable_prefs/pref_service_mock_factory.h" | 15 #include "components/sync_preferences/pref_service_mock_factory.h" |
16 #include "net/ssl/ssl_config.h" | 16 #include "net/ssl/ssl_config.h" |
17 #include "net/ssl/ssl_config_service.h" | 17 #include "net/ssl/ssl_config_service.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 using net::SSLConfig; | 20 using net::SSLConfig; |
21 using net::SSLConfigService; | 21 using net::SSLConfigService; |
22 using ssl_config::SSLConfigServiceManager; | 22 using ssl_config::SSLConfigServiceManager; |
23 | 23 |
24 class CommandLinePrefStoreSSLManagerTest : public testing::Test { | 24 class CommandLinePrefStoreSSLManagerTest : public testing::Test { |
25 public: | 25 public: |
26 CommandLinePrefStoreSSLManagerTest() {} | 26 CommandLinePrefStoreSSLManagerTest() {} |
27 | 27 |
28 protected: | 28 protected: |
29 base::MessageLoop message_loop_; | 29 base::MessageLoop message_loop_; |
30 }; | 30 }; |
31 | 31 |
32 // Test that command-line settings for minimum and maximum SSL versions are | 32 // Test that command-line settings for minimum and maximum SSL versions are |
33 // respected and that they do not persist to the preferences files. | 33 // respected and that they do not persist to the preferences files. |
34 TEST_F(CommandLinePrefStoreSSLManagerTest, CommandLinePrefs) { | 34 TEST_F(CommandLinePrefStoreSSLManagerTest, CommandLinePrefs) { |
35 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); | 35 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); |
36 | 36 |
37 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 37 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
38 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1"); | 38 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1"); |
39 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1"); | 39 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1"); |
40 | 40 |
41 syncable_prefs::PrefServiceMockFactory factory; | 41 sync_preferences::PrefServiceMockFactory factory; |
42 factory.set_user_prefs(local_state_store); | 42 factory.set_user_prefs(local_state_store); |
43 factory.set_command_line_prefs(new ChromeCommandLinePrefStore(&command_line)); | 43 factory.set_command_line_prefs(new ChromeCommandLinePrefStore(&command_line)); |
44 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 44 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
45 std::unique_ptr<PrefService> local_state(factory.Create(registry.get())); | 45 std::unique_ptr<PrefService> local_state(factory.Create(registry.get())); |
46 | 46 |
47 SSLConfigServiceManager::RegisterPrefs(registry.get()); | 47 SSLConfigServiceManager::RegisterPrefs(registry.get()); |
48 | 48 |
49 std::unique_ptr<SSLConfigServiceManager> config_manager( | 49 std::unique_ptr<SSLConfigServiceManager> config_manager( |
50 SSLConfigServiceManager::CreateDefaultManager( | 50 SSLConfigServiceManager::CreateDefaultManager( |
51 local_state.get(), base::ThreadTaskRunnerHandle::Get())); | 51 local_state.get(), base::ThreadTaskRunnerHandle::Get())); |
(...skipping 17 matching lines...) Expand all Loading... |
69 EXPECT_FALSE(version_max_pref->IsUserModifiable()); | 69 EXPECT_FALSE(version_max_pref->IsUserModifiable()); |
70 | 70 |
71 std::string version_min_str; | 71 std::string version_min_str; |
72 std::string version_max_str; | 72 std::string version_max_str; |
73 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMin, | 73 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMin, |
74 &version_min_str)); | 74 &version_min_str)); |
75 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMax, | 75 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMax, |
76 &version_max_str)); | 76 &version_max_str)); |
77 } | 77 } |
78 | 78 |
OLD | NEW |