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

Side by Side Diff: chrome/browser/prefs/command_line_pref_store_ssl_manager_unittest.cc

Issue 1320533007: Componentize ssl_config_service_manager_pref.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve -Wnewline-eof mac_chromium bot failure Created 5 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/ssl_config/ssl_config_service_manager.h"
6
7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/prefs/testing_pref_store.h"
12 #include "base/thread_task_runner_handle.h"
13 #include "chrome/browser/prefs/command_line_pref_store.h"
14 #include "components/ssl_config/ssl_config_prefs.h"
15 #include "components/ssl_config/ssl_config_switches.h"
16 #include "components/syncable_prefs/pref_service_mock_factory.h"
17 #include "net/ssl/ssl_config.h"
18 #include "net/ssl/ssl_config_service.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20
21 using net::SSLConfig;
22 using net::SSLConfigService;
23 using ssl_config::SSLConfigServiceManager;
24
25 class CommandLinePrefStoreSSLManagerTest : public testing::Test {
26 public:
27 CommandLinePrefStoreSSLManagerTest() {}
28
29 protected:
30 base::MessageLoop message_loop_;
31 };
32
33 // Test that command-line settings for minimum and maximum SSL versions are
34 // respected and that they do not persist to the preferences files.
35 TEST_F(CommandLinePrefStoreSSLManagerTest, CommandLinePrefs) {
36 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
37
38 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
39 command_line.AppendSwitchASCII(switches::kSSLVersionMin, "tls1.1");
40 command_line.AppendSwitchASCII(switches::kSSLVersionMax, "tls1");
41
42 syncable_prefs::PrefServiceMockFactory factory;
43 factory.set_user_prefs(local_state_store);
44 factory.set_command_line_prefs(new CommandLinePrefStore(&command_line));
45 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
46 scoped_ptr<PrefService> local_state(factory.Create(registry.get()));
47
48 SSLConfigServiceManager::RegisterPrefs(registry.get());
49
50 scoped_ptr<SSLConfigServiceManager> config_manager(
51 SSLConfigServiceManager::CreateDefaultManager(
52 local_state.get(), base::ThreadTaskRunnerHandle::Get()));
53 ASSERT_TRUE(config_manager.get());
54 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
55 ASSERT_TRUE(config_service.get());
56
57 SSLConfig ssl_config;
58 config_service->GetSSLConfig(&ssl_config);
59 // Command-line flags should be respected.
60 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_1, ssl_config.version_min);
61 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_max);
62
63 // Explicitly double-check the settings are not in the preference store.
64 const PrefService::Preference* version_min_pref =
65 local_state->FindPreference(ssl_config::prefs::kSSLVersionMin);
66 EXPECT_FALSE(version_min_pref->IsUserModifiable());
67
68 const PrefService::Preference* version_max_pref =
69 local_state->FindPreference(ssl_config::prefs::kSSLVersionMax);
70 EXPECT_FALSE(version_max_pref->IsUserModifiable());
71
72 std::string version_min_str;
73 std::string version_max_str;
74 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMin,
75 &version_min_str));
76 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMax,
77 &version_max_str));
78 }
79
OLDNEW
« no previous file with comments | « chrome/browser/prefs/command_line_pref_store.cc ('k') | chrome/browser/prefs/command_line_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698