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

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

Issue 7462008: Add a preference and command-line option to disable SSL/TLS cipher suites (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase before commit Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/command_line_pref_store.cc ('k') | chrome/chrome_tests.gypi » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <gtest/gtest.h> 5 #include <gtest/gtest.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/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 16 matching lines...) Expand all
27 27
28 void VerifyProxyMode(ProxyPrefs::ProxyMode expected_mode) { 28 void VerifyProxyMode(ProxyPrefs::ProxyMode expected_mode) {
29 const Value* value = NULL; 29 const Value* value = NULL;
30 ASSERT_EQ(PrefStore::READ_OK, GetValue(prefs::kProxy, &value)); 30 ASSERT_EQ(PrefStore::READ_OK, GetValue(prefs::kProxy, &value));
31 ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType()); 31 ASSERT_EQ(Value::TYPE_DICTIONARY, value->GetType());
32 ProxyConfigDictionary dict(static_cast<const DictionaryValue*>(value)); 32 ProxyConfigDictionary dict(static_cast<const DictionaryValue*>(value));
33 ProxyPrefs::ProxyMode actual_mode; 33 ProxyPrefs::ProxyMode actual_mode;
34 ASSERT_TRUE(dict.GetMode(&actual_mode)); 34 ASSERT_TRUE(dict.GetMode(&actual_mode));
35 EXPECT_EQ(expected_mode, actual_mode); 35 EXPECT_EQ(expected_mode, actual_mode);
36 } 36 }
37
38 void VerifySSLCipherSuites(const char* const* ciphers,
39 size_t cipher_count) {
40 const Value* value = NULL;
41 ASSERT_EQ(PrefStore::READ_OK,
42 GetValue(prefs::kCipherSuiteBlacklist, &value));
43 ASSERT_EQ(Value::TYPE_LIST, value->GetType());
44 const ListValue* list_value = static_cast<const ListValue*>(value);
45 ASSERT_EQ(cipher_count, list_value->GetSize());
46
47 std::string cipher_string;
48 for (ListValue::const_iterator it = list_value->begin();
49 it != list_value->end(); ++it, ++ciphers) {
50 ASSERT_TRUE((*it)->GetAsString(&cipher_string));
51 EXPECT_EQ(*ciphers, cipher_string);
52 }
53 }
37 }; 54 };
38 55
39 const char unknown_bool[] = "unknown_switch"; 56 const char unknown_bool[] = "unknown_switch";
40 const char unknown_string[] = "unknown_other_switch"; 57 const char unknown_string[] = "unknown_other_switch";
41 58
42 } // namespace 59 } // namespace
43 60
44 // Tests a simple string pref on the command line. 61 // Tests a simple string pref on the command line.
45 TEST(CommandLinePrefStoreTest, SimpleStringPref) { 62 TEST(CommandLinePrefStoreTest, SimpleStringPref) {
46 CommandLine cl(CommandLine::NO_PROGRAM); 63 CommandLine cl(CommandLine::NO_PROGRAM);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 scoped_refptr<TestCommandLinePrefStore> store2 = 169 scoped_refptr<TestCommandLinePrefStore> store2 =
153 new TestCommandLinePrefStore(&cl2); 170 new TestCommandLinePrefStore(&cl2);
154 store2->VerifyProxyMode(ProxyPrefs::MODE_PAC_SCRIPT); 171 store2->VerifyProxyMode(ProxyPrefs::MODE_PAC_SCRIPT);
155 172
156 CommandLine cl3(CommandLine::NO_PROGRAM); 173 CommandLine cl3(CommandLine::NO_PROGRAM);
157 cl3.AppendSwitchASCII(switches::kProxyServer, ""); 174 cl3.AppendSwitchASCII(switches::kProxyServer, "");
158 scoped_refptr<TestCommandLinePrefStore> store3 = 175 scoped_refptr<TestCommandLinePrefStore> store3 =
159 new TestCommandLinePrefStore(&cl3); 176 new TestCommandLinePrefStore(&cl3);
160 store3->VerifyProxyMode(ProxyPrefs::MODE_DIRECT); 177 store3->VerifyProxyMode(ProxyPrefs::MODE_DIRECT);
161 } 178 }
179
180 TEST(CommandLinePrefStoreTest, DisableSSLCipherSuites) {
181 CommandLine cl1(CommandLine::NO_PROGRAM);
182 cl1.AppendSwitchASCII(switches::kCipherSuiteBlacklist,
183 "0x0004,0x0005");
184 scoped_refptr<TestCommandLinePrefStore> store1 =
185 new TestCommandLinePrefStore(&cl1);
186 const char* const expected_ciphers1[] = {
187 "0x0004",
188 "0x0005",
189 };
190 store1->VerifySSLCipherSuites(expected_ciphers1,
191 arraysize(expected_ciphers1));
192
193 CommandLine cl2(CommandLine::NO_PROGRAM);
194 cl2.AppendSwitchASCII(switches::kCipherSuiteBlacklist,
195 "0x0004, WHITESPACE_IGNORED TEST , 0x0005");
196 scoped_refptr<TestCommandLinePrefStore> store2 =
197 new TestCommandLinePrefStore(&cl2);
198 const char* const expected_ciphers2[] = {
199 "0x0004",
200 "WHITESPACE_IGNORED TEST",
201 "0x0005",
202 };
203 store2->VerifySSLCipherSuites(expected_ciphers2,
204 arraysize(expected_ciphers2));
205
206 CommandLine cl3(CommandLine::NO_PROGRAM);
207 cl3.AppendSwitchASCII(switches::kCipherSuiteBlacklist,
208 "0x0004;MOAR;0x0005");
209 scoped_refptr<TestCommandLinePrefStore> store3 =
210 new TestCommandLinePrefStore(&cl3);
211 const char* const expected_ciphers3[] = {
212 "0x0004;MOAR;0x0005"
213 };
214 store3->VerifySSLCipherSuites(expected_ciphers3,
215 arraysize(expected_ciphers3));
216 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/command_line_pref_store.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698