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 "chrome/browser/net/ssl_config_service_manager.h" | 5 #include "chrome/browser/net/ssl_config_service_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/prefs/testing_pref_store.h" | 10 #include "base/prefs/testing_pref_store.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 class SSLConfigServiceManagerPrefTest : public testing::Test { | 40 class SSLConfigServiceManagerPrefTest : public testing::Test { |
41 public: | 41 public: |
42 SSLConfigServiceManagerPrefTest() | 42 SSLConfigServiceManagerPrefTest() |
43 : ui_thread_(BrowserThread::UI, &message_loop_), | 43 : ui_thread_(BrowserThread::UI, &message_loop_), |
44 io_thread_(BrowserThread::IO, &message_loop_) {} | 44 io_thread_(BrowserThread::IO, &message_loop_) {} |
45 | 45 |
46 protected: | 46 protected: |
47 bool IsChannelIdEnabled(SSLConfigService* config_service) { | 47 bool IsChannelIdEnabled(SSLConfigService* config_service) { |
48 // Pump the message loop to notify the SSLConfigServiceManagerPref that the | 48 // Pump the message loop to notify the SSLConfigServiceManagerPref that the |
49 // preferences changed. | 49 // preferences changed. |
50 message_loop_.RunAllPending(); | 50 message_loop_.RunUntilIdle(); |
51 SSLConfig config; | 51 SSLConfig config; |
52 config_service->GetSSLConfig(&config); | 52 config_service->GetSSLConfig(&config); |
53 return config.channel_id_enabled; | 53 return config.channel_id_enabled; |
54 } | 54 } |
55 | 55 |
56 MessageLoop message_loop_; | 56 MessageLoop message_loop_; |
57 content::TestBrowserThread ui_thread_; | 57 content::TestBrowserThread ui_thread_; |
58 content::TestBrowserThread io_thread_; | 58 content::TestBrowserThread io_thread_; |
59 }; | 59 }; |
60 | 60 |
(...skipping 11 matching lines...) Expand all Loading... |
72 ASSERT_TRUE(config_service.get()); | 72 ASSERT_TRUE(config_service.get()); |
73 | 73 |
74 SSLConfig config; | 74 SSLConfig config; |
75 config_service->GetSSLConfig(&config); | 75 config_service->GetSSLConfig(&config); |
76 EXPECT_FALSE(config.channel_id_enabled); | 76 EXPECT_FALSE(config.channel_id_enabled); |
77 | 77 |
78 local_state.SetUserPref(prefs::kEnableOriginBoundCerts, | 78 local_state.SetUserPref(prefs::kEnableOriginBoundCerts, |
79 Value::CreateBooleanValue(true)); | 79 Value::CreateBooleanValue(true)); |
80 // Pump the message loop to notify the SSLConfigServiceManagerPref that the | 80 // Pump the message loop to notify the SSLConfigServiceManagerPref that the |
81 // preferences changed. | 81 // preferences changed. |
82 message_loop_.RunAllPending(); | 82 message_loop_.RunUntilIdle(); |
83 config_service->GetSSLConfig(&config); | 83 config_service->GetSSLConfig(&config); |
84 EXPECT_TRUE(config.channel_id_enabled); | 84 EXPECT_TRUE(config.channel_id_enabled); |
85 } | 85 } |
86 | 86 |
87 // Test channel id with user prefs. | 87 // Test channel id with user prefs. |
88 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithUserPrefs) { | 88 TEST_F(SSLConfigServiceManagerPrefTest, ChannelIDWithUserPrefs) { |
89 TestingPrefService local_state; | 89 TestingPrefService local_state; |
90 SSLConfigServiceManager::RegisterPrefs(&local_state); | 90 SSLConfigServiceManager::RegisterPrefs(&local_state); |
91 local_state.SetUserPref(prefs::kEnableOriginBoundCerts, | 91 local_state.SetUserPref(prefs::kEnableOriginBoundCerts, |
92 Value::CreateBooleanValue(false)); | 92 Value::CreateBooleanValue(false)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 config_service->GetSSLConfig(&old_config); | 163 config_service->GetSSLConfig(&old_config); |
164 EXPECT_TRUE(old_config.disabled_cipher_suites.empty()); | 164 EXPECT_TRUE(old_config.disabled_cipher_suites.empty()); |
165 | 165 |
166 ListValue* list_value = new ListValue(); | 166 ListValue* list_value = new ListValue(); |
167 list_value->Append(Value::CreateStringValue("0x0004")); | 167 list_value->Append(Value::CreateStringValue("0x0004")); |
168 list_value->Append(Value::CreateStringValue("0x0005")); | 168 list_value->Append(Value::CreateStringValue("0x0005")); |
169 local_state.SetUserPref(prefs::kCipherSuiteBlacklist, list_value); | 169 local_state.SetUserPref(prefs::kCipherSuiteBlacklist, list_value); |
170 | 170 |
171 // Pump the message loop to notify the SSLConfigServiceManagerPref that the | 171 // Pump the message loop to notify the SSLConfigServiceManagerPref that the |
172 // preferences changed. | 172 // preferences changed. |
173 message_loop_.RunAllPending(); | 173 message_loop_.RunUntilIdle(); |
174 | 174 |
175 SSLConfig config; | 175 SSLConfig config; |
176 config_service->GetSSLConfig(&config); | 176 config_service->GetSSLConfig(&config); |
177 | 177 |
178 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); | 178 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); |
179 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); | 179 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); |
180 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); | 180 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); |
181 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); | 181 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); |
182 } | 182 } |
183 | 183 |
(...skipping 16 matching lines...) Expand all Loading... |
200 | 200 |
201 ListValue* list_value = new ListValue(); | 201 ListValue* list_value = new ListValue(); |
202 list_value->Append(Value::CreateStringValue("0x0004")); | 202 list_value->Append(Value::CreateStringValue("0x0004")); |
203 list_value->Append(Value::CreateStringValue("TLS_NOT_WITH_A_CIPHER_SUITE")); | 203 list_value->Append(Value::CreateStringValue("TLS_NOT_WITH_A_CIPHER_SUITE")); |
204 list_value->Append(Value::CreateStringValue("0x0005")); | 204 list_value->Append(Value::CreateStringValue("0x0005")); |
205 list_value->Append(Value::CreateStringValue("0xBEEFY")); | 205 list_value->Append(Value::CreateStringValue("0xBEEFY")); |
206 local_state.SetUserPref(prefs::kCipherSuiteBlacklist, list_value); | 206 local_state.SetUserPref(prefs::kCipherSuiteBlacklist, list_value); |
207 | 207 |
208 // Pump the message loop to notify the SSLConfigServiceManagerPref that the | 208 // Pump the message loop to notify the SSLConfigServiceManagerPref that the |
209 // preferences changed. | 209 // preferences changed. |
210 message_loop_.RunAllPending(); | 210 message_loop_.RunUntilIdle(); |
211 | 211 |
212 SSLConfig config; | 212 SSLConfig config; |
213 config_service->GetSSLConfig(&config); | 213 config_service->GetSSLConfig(&config); |
214 | 214 |
215 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); | 215 EXPECT_NE(old_config.disabled_cipher_suites, config.disabled_cipher_suites); |
216 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); | 216 ASSERT_EQ(2u, config.disabled_cipher_suites.size()); |
217 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); | 217 EXPECT_EQ(0x0004, config.disabled_cipher_suites[0]); |
218 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); | 218 EXPECT_EQ(0x0005, config.disabled_cipher_suites[1]); |
219 } | 219 } |
220 | 220 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 local_state->FindPreference(prefs::kSSLVersionMax); | 293 local_state->FindPreference(prefs::kSSLVersionMax); |
294 EXPECT_FALSE(version_max_pref->IsUserModifiable()); | 294 EXPECT_FALSE(version_max_pref->IsUserModifiable()); |
295 | 295 |
296 std::string version_min_str; | 296 std::string version_min_str; |
297 std::string version_max_str; | 297 std::string version_max_str; |
298 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, | 298 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMin, |
299 &version_min_str)); | 299 &version_min_str)); |
300 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, | 300 EXPECT_FALSE(local_state_store->GetString(prefs::kSSLVersionMax, |
301 &version_max_str)); | 301 &version_max_str)); |
302 } | 302 } |
OLD | NEW |