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

Side by Side Diff: chrome/browser/policy/policy_transformations_unittest.cc

Issue 113813003: Cleanup the policy code after the recent moves into the component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/policy/policy_transformations.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h"
9 #include "components/policy/core/common/policy_bundle.h"
10 #include "components/policy/core/common/policy_map.h"
11 #include "policy/policy_constants.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace policy {
15
16 TEST(PolicyTransformationsTest, FixDeprecatedPolicies) {
17 PolicyBundle policy_bundle;
18 PolicyMap& policy_map =
19 policy_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
20
21 // Individual proxy policy values in the Chrome namespace should be collected
22 // into a dictionary.
23 policy_map.Set(key::kProxyServerMode,
24 POLICY_LEVEL_MANDATORY,
25 POLICY_SCOPE_USER,
26 base::Value::CreateIntegerValue(3),
27 NULL);
28
29 // Both these policies should be ignored, since there's a higher priority
30 // policy available.
31 policy_map.Set(key::kProxyMode,
32 POLICY_LEVEL_RECOMMENDED,
33 POLICY_SCOPE_USER,
34 base::Value::CreateStringValue("pac_script"),
35 NULL);
36 policy_map.Set(key::kProxyPacUrl,
37 POLICY_LEVEL_RECOMMENDED,
38 POLICY_SCOPE_USER,
39 base::Value::CreateStringValue("http://example.com/wpad.dat"),
40 NULL);
41
42 // Add a value to a non-Chrome namespace.
43 policy_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, std::string()))
44 .Set(key::kProxyServerMode,
45 POLICY_LEVEL_MANDATORY,
46 POLICY_SCOPE_USER,
47 base::Value::CreateIntegerValue(3),
48 NULL);
49
50 PolicyBundle actual_bundle;
51 actual_bundle.CopyFrom(policy_bundle);
52 FixDeprecatedPolicies(&actual_bundle);
53
54 PolicyBundle expected_bundle;
55 // The resulting Chrome namespace map should have the collected policy.
56 PolicyMap& expected_map =
57 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
58 scoped_ptr<base::DictionaryValue> expected_value(new base::DictionaryValue);
59 expected_value->SetInteger(key::kProxyServerMode, 3);
60 expected_map.Set(key::kProxySettings,
61 POLICY_LEVEL_MANDATORY,
62 POLICY_SCOPE_USER,
63 expected_value.release(),
64 NULL);
65 // The resulting Extensions namespace map shouldn't have been modified.
66 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, std::string()))
67 .Set(key::kProxyServerMode,
68 POLICY_LEVEL_MANDATORY,
69 POLICY_SCOPE_USER,
70 base::Value::CreateIntegerValue(3),
71 NULL);
72
73 EXPECT_TRUE(expected_bundle.Equals(actual_bundle));
74 }
75
76 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_transformations.cc ('k') | chrome/browser/policy/profile_policy_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698