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: components/ssl_config/ssl_config_service_manager_pref_unittest.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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
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"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMax, 156 EXPECT_FALSE(local_state_store->GetString(ssl_config::prefs::kSSLVersionMax,
157 &version_max_str)); 157 &version_max_str));
158 } 158 }
159 159
160 // Tests that "ssl3" is not treated as a valid minimum version. 160 // Tests that "ssl3" is not treated as a valid minimum version.
161 TEST_F(SSLConfigServiceManagerPrefTest, NoSSL3) { 161 TEST_F(SSLConfigServiceManagerPrefTest, NoSSL3) {
162 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 162 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
163 163
164 TestingPrefServiceSimple local_state; 164 TestingPrefServiceSimple local_state;
165 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMin, 165 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMin,
166 new base::StringValue("ssl3")); 166 new base::Value("ssl3"));
167 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); 167 SSLConfigServiceManager::RegisterPrefs(local_state.registry());
168 168
169 std::unique_ptr<SSLConfigServiceManager> config_manager( 169 std::unique_ptr<SSLConfigServiceManager> config_manager(
170 SSLConfigServiceManager::CreateDefaultManager( 170 SSLConfigServiceManager::CreateDefaultManager(
171 &local_state, base::ThreadTaskRunnerHandle::Get())); 171 &local_state, base::ThreadTaskRunnerHandle::Get()));
172 ASSERT_TRUE(config_manager.get()); 172 ASSERT_TRUE(config_manager.get());
173 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 173 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
174 ASSERT_TRUE(config_service.get()); 174 ASSERT_TRUE(config_service.get());
175 175
176 SSLConfig ssl_config; 176 SSLConfig ssl_config;
177 config_service->GetSSLConfig(&ssl_config); 177 config_service->GetSSLConfig(&ssl_config);
178 // The command-line option must not have been honored. 178 // The command-line option must not have been honored.
179 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min); 179 EXPECT_LE(net::SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_min);
180 } 180 }
181 181
182 // Tests that SSL max version correctly sets the maximum version. 182 // Tests that SSL max version correctly sets the maximum version.
183 TEST_F(SSLConfigServiceManagerPrefTest, SSLVersionMax) { 183 TEST_F(SSLConfigServiceManagerPrefTest, SSLVersionMax) {
184 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 184 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
185 185
186 TestingPrefServiceSimple local_state; 186 TestingPrefServiceSimple local_state;
187 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMax, 187 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMax,
188 new base::StringValue("tls1.3")); 188 new base::Value("tls1.3"));
189 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); 189 SSLConfigServiceManager::RegisterPrefs(local_state.registry());
190 190
191 std::unique_ptr<SSLConfigServiceManager> config_manager( 191 std::unique_ptr<SSLConfigServiceManager> config_manager(
192 SSLConfigServiceManager::CreateDefaultManager( 192 SSLConfigServiceManager::CreateDefaultManager(
193 &local_state, base::ThreadTaskRunnerHandle::Get())); 193 &local_state, base::ThreadTaskRunnerHandle::Get()));
194 ASSERT_TRUE(config_manager.get()); 194 ASSERT_TRUE(config_manager.get());
195 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 195 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
196 ASSERT_TRUE(config_service.get()); 196 ASSERT_TRUE(config_service.get());
197 197
198 SSLConfig ssl_config; 198 SSLConfig ssl_config;
199 config_service->GetSSLConfig(&ssl_config); 199 config_service->GetSSLConfig(&ssl_config);
200 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_3, ssl_config.version_max); 200 EXPECT_EQ(net::SSL_PROTOCOL_VERSION_TLS1_3, ssl_config.version_max);
201 } 201 }
202 202
203 // Tests that SSL max version can not be set below TLS 1.2. 203 // Tests that SSL max version can not be set below TLS 1.2.
204 TEST_F(SSLConfigServiceManagerPrefTest, NoTLS11Max) { 204 TEST_F(SSLConfigServiceManagerPrefTest, NoTLS11Max) {
205 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 205 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
206 206
207 TestingPrefServiceSimple local_state; 207 TestingPrefServiceSimple local_state;
208 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMax, 208 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMax,
209 new base::StringValue("tls1.1")); 209 new base::Value("tls1.1"));
210 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); 210 SSLConfigServiceManager::RegisterPrefs(local_state.registry());
211 211
212 std::unique_ptr<SSLConfigServiceManager> config_manager( 212 std::unique_ptr<SSLConfigServiceManager> config_manager(
213 SSLConfigServiceManager::CreateDefaultManager( 213 SSLConfigServiceManager::CreateDefaultManager(
214 &local_state, base::ThreadTaskRunnerHandle::Get())); 214 &local_state, base::ThreadTaskRunnerHandle::Get()));
215 ASSERT_TRUE(config_manager.get()); 215 ASSERT_TRUE(config_manager.get());
216 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 216 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
217 ASSERT_TRUE(config_service.get()); 217 ASSERT_TRUE(config_service.get());
218 218
219 SSLConfig ssl_config; 219 SSLConfig ssl_config;
(...skipping 25 matching lines...) Expand all
245 // Tests that the SSLVersionMax preference overwites the TLS 1.3 feature. 245 // Tests that the SSLVersionMax preference overwites the TLS 1.3 feature.
246 TEST_F(SSLConfigServiceManagerPrefTest, TLS13SSLVersionMax) { 246 TEST_F(SSLConfigServiceManagerPrefTest, TLS13SSLVersionMax) {
247 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore()); 247 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
248 248
249 // Toggle the feature. 249 // Toggle the feature.
250 base::test::ScopedFeatureList scoped_feature_list; 250 base::test::ScopedFeatureList scoped_feature_list;
251 scoped_feature_list.InitFromCommandLine("NegotiateTLS13", std::string()); 251 scoped_feature_list.InitFromCommandLine("NegotiateTLS13", std::string());
252 252
253 TestingPrefServiceSimple local_state; 253 TestingPrefServiceSimple local_state;
254 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMax, 254 local_state.SetUserPref(ssl_config::prefs::kSSLVersionMax,
255 new base::StringValue("tls1.2")); 255 new base::Value("tls1.2"));
256 SSLConfigServiceManager::RegisterPrefs(local_state.registry()); 256 SSLConfigServiceManager::RegisterPrefs(local_state.registry());
257 257
258 std::unique_ptr<SSLConfigServiceManager> config_manager( 258 std::unique_ptr<SSLConfigServiceManager> config_manager(
259 SSLConfigServiceManager::CreateDefaultManager( 259 SSLConfigServiceManager::CreateDefaultManager(
260 &local_state, base::ThreadTaskRunnerHandle::Get())); 260 &local_state, base::ThreadTaskRunnerHandle::Get()));
261 ASSERT_TRUE(config_manager.get()); 261 ASSERT_TRUE(config_manager.get());
262 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 262 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
263 ASSERT_TRUE(config_service.get()); 263 ASSERT_TRUE(config_service.get());
264 264
265 SSLConfig ssl_config; 265 SSLConfig ssl_config;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 local_state.SetUserPref(ssl_config::prefs::kCertEnableSha1LocalAnchors, 309 local_state.SetUserPref(ssl_config::prefs::kCertEnableSha1LocalAnchors,
310 new base::Value(false)); 310 new base::Value(false));
311 // Pump the message loop to notify the SSLConfigServiceManagerPref that the 311 // Pump the message loop to notify the SSLConfigServiceManagerPref that the
312 // preferences changed. 312 // preferences changed.
313 base::RunLoop().RunUntilIdle(); 313 base::RunLoop().RunUntilIdle();
314 314
315 SSLConfig config4; 315 SSLConfig config4;
316 config_service->GetSSLConfig(&config4); 316 config_service->GetSSLConfig(&config4);
317 EXPECT_FALSE(config4.sha1_local_anchors_enabled); 317 EXPECT_FALSE(config4.sha1_local_anchors_enabled);
318 } 318 }
OLDNEW
« no previous file with comments | « components/ssl_config/ssl_config_service_manager_pref.cc ('k') | components/sync/base/model_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698