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

Side by Side Diff: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc

Issue 7828022: Add a method to the HostContentSettings map to return the |Value| of a content setting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unrelated changes from patchset. Created 9 years, 3 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
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 "chrome/browser/content_settings/content_settings_policy_provider.h" 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 12 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
12 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/testing_pref_service.h" 17 #include "chrome/test/base/testing_pref_service.h"
17 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
18 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 provider.ShutdownOnUIThread(); 249 provider.ShutdownOnUIThread();
249 } 250 }
250 251
251 TEST_F(PolicyProviderTest, AutoSelectCertificateList) { 252 TEST_F(PolicyProviderTest, AutoSelectCertificateList) {
252 TestingProfile profile; 253 TestingProfile profile;
253 TestingPrefService* prefs = profile.GetTestingPrefService(); 254 TestingPrefService* prefs = profile.GetTestingPrefService();
254 255
255 PolicyProvider provider(prefs, NULL); 256 PolicyProvider provider(prefs, NULL);
256 GURL google_url("https://mail.google.com"); 257 GURL google_url("https://mail.google.com");
257 // Tests the default setting for auto selecting certificates 258 // Tests the default setting for auto selecting certificates
258 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 259 EXPECT_EQ(NULL,
259 provider.GetContentSetting( 260 provider.GetContentSettingValue(
260 google_url, 261 google_url,
261 google_url, 262 google_url,
262 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 263 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
263 std::string())); 264 std::string()));
264 265
265 // Set the content settings pattern list for origins to auto select 266 // Set the content settings pattern list for origins to auto select
266 // certificates. 267 // certificates.
268 std::string pattern_str("\"pattern\":\"[*.]google.com\"");
269 std::string filter_str("\"filter\":{\"ISSUER\":{\"CN\":\"issuer name\"}}");
267 ListValue* value = new ListValue(); 270 ListValue* value = new ListValue();
268 value->Append(Value::CreateStringValue("[*.]google.com")); 271 value->Append(Value::CreateStringValue(
272 "{" + pattern_str + "," + filter_str + "}"));
269 prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls, 273 prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls,
270 value); 274 value);
271 GURL youtube_url("https://www.youtube.com"); 275 GURL youtube_url("https://www.youtube.com");
272 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 276 EXPECT_EQ(NULL,
273 provider.GetContentSetting( 277 provider.GetContentSettingValue(
274 youtube_url, 278 youtube_url,
275 youtube_url, 279 youtube_url,
276 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 280 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
277 std::string())); 281 std::string()));
278 EXPECT_EQ(CONTENT_SETTING_ALLOW, 282 scoped_ptr<Value> cert_filter(provider.GetContentSettingValue(
279 provider.GetContentSetting( 283 google_url,
280 google_url, 284 google_url,
281 google_url, 285 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
282 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 286 std::string()));
283 std::string()));
284 287
288 ASSERT_EQ(Value::TYPE_DICTIONARY, cert_filter->GetType());
289 DictionaryValue* dict_value =
290 static_cast<DictionaryValue*>(cert_filter.get());
291 std::string actual_common_name;
292 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name));
293 EXPECT_EQ("issuer name", actual_common_name);
285 provider.ShutdownOnUIThread(); 294 provider.ShutdownOnUIThread();
286 } 295 }
296
287 } // namespace content_settings 297 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698