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

Side by Side Diff: components/ssl_config/ssl_config_service_manager_pref_unittest.cc

Issue 2613533004: Only disable SHA-1 for local trust anchors if there's a PrefService (Closed)
Patch Set: Expand test Created 3 years, 11 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
« no previous file with comments | « components/ssl_config/ssl_config_service_manager_pref.cc ('k') | net/ssl/ssl_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 SSLConfigServiceManager::CreateDefaultManager( 192 SSLConfigServiceManager::CreateDefaultManager(
193 &local_state, base::ThreadTaskRunnerHandle::Get())); 193 &local_state, base::ThreadTaskRunnerHandle::Get()));
194 scoped_refptr<SSLConfigService> config_service(config_manager->Get()); 194 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
195 ASSERT_TRUE(config_service.get()); 195 ASSERT_TRUE(config_service.get());
196 196
197 // The feature should have switched the default version_fallback_min value. 197 // The feature should have switched the default version_fallback_min value.
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
203 // Tests that SHA-1 signatures for local trust anchors can be enabled.
204 TEST_F(SSLConfigServiceManagerPrefTest, SHA1ForLocalAnchors) {
205 scoped_refptr<TestingPrefStore> local_state_store(new TestingPrefStore());
206
207 TestingPrefServiceSimple local_state;
208 SSLConfigServiceManager::RegisterPrefs(local_state.registry());
209
210 std::unique_ptr<SSLConfigServiceManager> config_manager(
211 SSLConfigServiceManager::CreateDefaultManager(
212 &local_state, base::ThreadTaskRunnerHandle::Get()));
213 ASSERT_TRUE(config_manager);
214 scoped_refptr<SSLConfigService> config_service(config_manager->Get());
215 ASSERT_TRUE(config_service);
216
217 // By default, SHA-1 local trust anchors should be enabled when not
218 // using any pref service.
219 SSLConfig config1;
220 EXPECT_TRUE(config1.sha1_local_anchors_enabled);
221
222 // Using a pref service without any preference set should result in
223 // SHA-1 local trust anchors being disabled.
224 SSLConfig config2;
225 config_service->GetSSLConfig(&config2);
226 EXPECT_FALSE(config2.sha1_local_anchors_enabled);
227
228 // Enabling the local preference should result in SHA-1 local trust anchors
229 // being enabled.
230 local_state.SetUserPref(ssl_config::prefs::kCertEnableSha1LocalAnchors,
231 new base::FundamentalValue(true));
232 // Pump the message loop to notify the SSLConfigServiceManagerPref that the
233 // preferences changed.
234 base::RunLoop().RunUntilIdle();
235
236 SSLConfig config3;
237 config_service->GetSSLConfig(&config3);
238 EXPECT_TRUE(config3.sha1_local_anchors_enabled);
239
240 // Disabling the local preference should result in SHA-1 local trust
241 // anchors being disabled.
242 local_state.SetUserPref(ssl_config::prefs::kCertEnableSha1LocalAnchors,
243 new base::FundamentalValue(false));
244 // Pump the message loop to notify the SSLConfigServiceManagerPref that the
245 // preferences changed.
246 base::RunLoop().RunUntilIdle();
247
248 SSLConfig config4;
249 config_service->GetSSLConfig(&config4);
250 EXPECT_FALSE(config4.sha1_local_anchors_enabled);
251 }
OLDNEW
« no previous file with comments | « components/ssl_config/ssl_config_service_manager_pref.cc ('k') | net/ssl/ssl_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698