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

Side by Side Diff: components/policy/core/common/policy_loader_win_unittest.cc

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed another test. Created 5 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
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 "components/policy/core/common/policy_loader_win.h" 5 #include "components/policy/core/common/policy_loader_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <userenv.h> 8 #include <userenv.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 16 matching lines...) Expand all
27 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
28 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
29 #include "base/sys_byteorder.h" 29 #include "base/sys_byteorder.h"
30 #include "base/win/registry.h" 30 #include "base/win/registry.h"
31 #include "base/win/win_util.h" 31 #include "base/win/win_util.h"
32 #include "components/policy/core/common/async_policy_provider.h" 32 #include "components/policy/core/common/async_policy_provider.h"
33 #include "components/policy/core/common/configuration_policy_provider_test.h" 33 #include "components/policy/core/common/configuration_policy_provider_test.h"
34 #include "components/policy/core/common/external_data_fetcher.h" 34 #include "components/policy/core/common/external_data_fetcher.h"
35 #include "components/policy/core/common/policy_bundle.h" 35 #include "components/policy/core/common/policy_bundle.h"
36 #include "components/policy/core/common/policy_map.h" 36 #include "components/policy/core/common/policy_map.h"
37 #include "components/policy/core/common/policy_types.h"
37 #include "components/policy/core/common/preg_parser_win.h" 38 #include "components/policy/core/common/preg_parser_win.h"
38 #include "components/policy/core/common/schema_map.h" 39 #include "components/policy/core/common/schema_map.h"
39 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
40 41
41 using base::UTF8ToUTF16; 42 using base::UTF8ToUTF16;
42 using base::UTF16ToUTF8; 43 using base::UTF16ToUTF8;
43 using base::win::RegKey; 44 using base::win::RegKey;
44 45
45 namespace policy { 46 namespace policy {
46 47
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 ASSERT_HRESULT_SUCCEEDED(RegOverridePredefKey(HKEY_CURRENT_USER, 0)); 327 ASSERT_HRESULT_SUCCEEDED(RegOverridePredefKey(HKEY_CURRENT_USER, 0));
327 } 328 }
328 329
329 void ScopedGroupPolicyRegistrySandbox::DeleteKeys() { 330 void ScopedGroupPolicyRegistrySandbox::DeleteKeys() {
330 RegKey key(HKEY_CURRENT_USER, key_name_.c_str(), KEY_ALL_ACCESS); 331 RegKey key(HKEY_CURRENT_USER, key_name_.c_str(), KEY_ALL_ACCESS);
331 ASSERT_TRUE(key.Valid()); 332 ASSERT_TRUE(key.Valid());
332 key.DeleteKey(L""); 333 key.DeleteKey(L"");
333 } 334 }
334 335
335 RegistryTestHarness::RegistryTestHarness(HKEY hive, PolicyScope scope) 336 RegistryTestHarness::RegistryTestHarness(HKEY hive, PolicyScope scope)
336 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, scope), hive_(hive) {} 337 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, scope,
338 POLICY_SOURCE_PLATFORM),
339 hive_(hive) {
340 }
337 341
338 RegistryTestHarness::~RegistryTestHarness() {} 342 RegistryTestHarness::~RegistryTestHarness() {}
339 343
340 void RegistryTestHarness::SetUp() {} 344 void RegistryTestHarness::SetUp() {}
341 345
342 ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider( 346 ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider(
343 SchemaRegistry* registry, 347 SchemaRegistry* registry,
344 scoped_refptr<base::SequencedTaskRunner> task_runner) { 348 scoped_refptr<base::SequencedTaskRunner> task_runner) {
345 base::win::SetDomainStateForTesting(true); 349 base::win::SetDomainStateForTesting(true);
346 scoped_ptr<AsyncPolicyLoader> loader( 350 scoped_ptr<AsyncPolicyLoader> loader(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 PolicyProviderTestHarness* RegistryTestHarness::CreateHKCU() { 452 PolicyProviderTestHarness* RegistryTestHarness::CreateHKCU() {
449 return new RegistryTestHarness(HKEY_CURRENT_USER, POLICY_SCOPE_USER); 453 return new RegistryTestHarness(HKEY_CURRENT_USER, POLICY_SCOPE_USER);
450 } 454 }
451 455
452 // static 456 // static
453 PolicyProviderTestHarness* RegistryTestHarness::CreateHKLM() { 457 PolicyProviderTestHarness* RegistryTestHarness::CreateHKLM() {
454 return new RegistryTestHarness(HKEY_LOCAL_MACHINE, POLICY_SCOPE_MACHINE); 458 return new RegistryTestHarness(HKEY_LOCAL_MACHINE, POLICY_SCOPE_MACHINE);
455 } 459 }
456 460
457 PRegTestHarness::PRegTestHarness() 461 PRegTestHarness::PRegTestHarness()
458 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE) {} 462 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
463 POLICY_SOURCE_PLATFORM) {
464 }
459 465
460 PRegTestHarness::~PRegTestHarness() {} 466 PRegTestHarness::~PRegTestHarness() {}
461 467
462 void PRegTestHarness::SetUp() { 468 void PRegTestHarness::SetUp() {
463 base::win::SetDomainStateForTesting(false); 469 base::win::SetDomainStateForTesting(false);
464 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 470 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
465 preg_file_path_ = temp_dir_.path().Append(PolicyLoaderWin::kPRegFileName); 471 preg_file_path_ = temp_dir_.path().Append(PolicyLoaderWin::kPRegFileName);
466 ASSERT_TRUE(base::WriteFile(preg_file_path_, 472 ASSERT_TRUE(base::WriteFile(preg_file_path_,
467 preg_parser::kPRegFileHeader, 473 preg_parser::kPRegFileHeader,
468 arraysize(preg_parser::kPRegFileHeader))); 474 arraysize(preg_parser::kPRegFileHeader)));
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 hklm_key.WriteValue( 757 hklm_key.WriteValue(
752 UTF8ToUTF16(test_keys::kKeyString).c_str(), 758 UTF8ToUTF16(test_keys::kKeyString).c_str(),
753 UTF8ToUTF16("registry").c_str()); 759 UTF8ToUTF16("registry").c_str());
754 } 760 }
755 761
756 bool MatchesRegistrySentinel() { 762 bool MatchesRegistrySentinel() {
757 base::DictionaryValue expected_policy; 763 base::DictionaryValue expected_policy;
758 expected_policy.SetString(test_keys::kKeyString, "registry"); 764 expected_policy.SetString(test_keys::kKeyString, "registry");
759 PolicyBundle expected; 765 PolicyBundle expected;
760 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 766 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
761 .LoadFrom(&expected_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); 767 .LoadFrom(&expected_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
768 POLICY_SOURCE_PLATFORM);
762 return Matches(expected); 769 return Matches(expected);
763 } 770 }
764 771
765 bool MatchesTestBundle() { 772 bool MatchesTestBundle() {
766 base::DictionaryValue expected_policy; 773 base::DictionaryValue expected_policy;
767 expected_policy.SetBoolean(test_keys::kKeyBoolean, true); 774 expected_policy.SetBoolean(test_keys::kKeyBoolean, true);
768 expected_policy.SetString(test_keys::kKeyString, "GPO"); 775 expected_policy.SetString(test_keys::kKeyString, "GPO");
769 expected_policy.SetInteger(test_keys::kKeyInteger, 42); 776 expected_policy.SetInteger(test_keys::kKeyInteger, 42);
770 scoped_ptr<base::ListValue> list(new base::ListValue()); 777 scoped_ptr<base::ListValue> list(new base::ListValue());
771 list->AppendString("GPO 1"); 778 list->AppendString("GPO 1");
772 list->AppendString("GPO 2"); 779 list->AppendString("GPO 2");
773 expected_policy.Set(test_keys::kKeyStringList, list.release()); 780 expected_policy.Set(test_keys::kKeyStringList, list.release());
774 PolicyBundle expected; 781 PolicyBundle expected;
775 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 782 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
776 .LoadFrom(&expected_policy, POLICY_LEVEL_MANDATORY, 783 .LoadFrom(&expected_policy, POLICY_LEVEL_MANDATORY,
777 POLICY_SCOPE_MACHINE); 784 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM);
778 return Matches(expected); 785 return Matches(expected);
779 } 786 }
780 787
781 ScopedGroupPolicyRegistrySandbox registry_sandbox_; 788 ScopedGroupPolicyRegistrySandbox registry_sandbox_;
782 PGROUP_POLICY_OBJECT gpo_list_; 789 PGROUP_POLICY_OBJECT gpo_list_;
783 DWORD gpo_list_status_; 790 DWORD gpo_list_status_;
784 base::FilePath test_data_dir_; 791 base::FilePath test_data_dir_;
785 AppliedGPOListProvider* gpo_list_provider_; 792 AppliedGPOListProvider* gpo_list_provider_;
786 }; 793 };
787 794
788 const base::char16 PolicyLoaderWinTest::kTestPolicyKey[] = 795 const base::char16 PolicyLoaderWinTest::kTestPolicyKey[] =
789 L"SOFTWARE\\Policies\\Chromium"; 796 L"SOFTWARE\\Policies\\Chromium";
790 797
791 TEST_F(PolicyLoaderWinTest, HKLMOverHKCU) { 798 TEST_F(PolicyLoaderWinTest, HKLMOverHKCU) {
792 RegKey hklm_key(HKEY_LOCAL_MACHINE, kTestPolicyKey, KEY_ALL_ACCESS); 799 RegKey hklm_key(HKEY_LOCAL_MACHINE, kTestPolicyKey, KEY_ALL_ACCESS);
793 ASSERT_TRUE(hklm_key.Valid()); 800 ASSERT_TRUE(hklm_key.Valid());
794 hklm_key.WriteValue(UTF8ToUTF16(test_keys::kKeyString).c_str(), 801 hklm_key.WriteValue(UTF8ToUTF16(test_keys::kKeyString).c_str(),
795 UTF8ToUTF16("hklm").c_str()); 802 UTF8ToUTF16("hklm").c_str());
796 RegKey hkcu_key(HKEY_CURRENT_USER, kTestPolicyKey, KEY_ALL_ACCESS); 803 RegKey hkcu_key(HKEY_CURRENT_USER, kTestPolicyKey, KEY_ALL_ACCESS);
797 ASSERT_TRUE(hkcu_key.Valid()); 804 ASSERT_TRUE(hkcu_key.Valid());
798 hkcu_key.WriteValue(UTF8ToUTF16(test_keys::kKeyString).c_str(), 805 hkcu_key.WriteValue(UTF8ToUTF16(test_keys::kKeyString).c_str(),
799 UTF8ToUTF16("hkcu").c_str()); 806 UTF8ToUTF16("hkcu").c_str());
800 807
801 PolicyBundle expected; 808 PolicyBundle expected;
802 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 809 expected.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
803 .Set(test_keys::kKeyString, 810 .Set(test_keys::kKeyString,
804 POLICY_LEVEL_MANDATORY, 811 POLICY_LEVEL_MANDATORY,
805 POLICY_SCOPE_MACHINE, 812 POLICY_SCOPE_MACHINE,
813 POLICY_SOURCE_PLATFORM,
806 new base::StringValue("hklm"), 814 new base::StringValue("hklm"),
807 NULL); 815 NULL);
808 EXPECT_TRUE(Matches(expected)); 816 EXPECT_TRUE(Matches(expected));
809 } 817 }
810 818
811 TEST_F(PolicyLoaderWinTest, Merge3rdPartyPolicies) { 819 TEST_F(PolicyLoaderWinTest, Merge3rdPartyPolicies) {
812 // Policy for the same extension will be provided at the 4 level/scope 820 // Policy for the same extension will be provided at the 4 level/scope
813 // combinations, to verify that they overlap as expected. 821 // combinations, to verify that they overlap as expected.
814 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "merge"); 822 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "merge");
815 ASSERT_TRUE(RegisterSchema( 823 ASSERT_TRUE(RegisterSchema(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 policy.SetString("c", kUserRecommended); 858 policy.SetString("c", kUserRecommended);
851 policy.SetString("d", kUserRecommended); 859 policy.SetString("d", kUserRecommended);
852 EXPECT_TRUE(InstallValue(policy, HKEY_CURRENT_USER, 860 EXPECT_TRUE(InstallValue(policy, HKEY_CURRENT_USER,
853 kPathSuffix, kRecommended)); 861 kPathSuffix, kRecommended));
854 862
855 PolicyBundle expected; 863 PolicyBundle expected;
856 PolicyMap& expected_policy = expected.Get(ns); 864 PolicyMap& expected_policy = expected.Get(ns);
857 expected_policy.Set("a", 865 expected_policy.Set("a",
858 POLICY_LEVEL_MANDATORY, 866 POLICY_LEVEL_MANDATORY,
859 POLICY_SCOPE_MACHINE, 867 POLICY_SCOPE_MACHINE,
868 POLICY_SOURCE_PLATFORM,
860 new base::StringValue(kMachineMandatory), 869 new base::StringValue(kMachineMandatory),
861 NULL); 870 NULL);
862 expected_policy.Set("b", 871 expected_policy.Set("b",
863 POLICY_LEVEL_MANDATORY, 872 POLICY_LEVEL_MANDATORY,
864 POLICY_SCOPE_USER, 873 POLICY_SCOPE_USER,
874 POLICY_SOURCE_PLATFORM,
865 new base::StringValue(kUserMandatory), 875 new base::StringValue(kUserMandatory),
866 NULL); 876 NULL);
867 expected_policy.Set("c", 877 expected_policy.Set("c",
868 POLICY_LEVEL_RECOMMENDED, 878 POLICY_LEVEL_RECOMMENDED,
869 POLICY_SCOPE_MACHINE, 879 POLICY_SCOPE_MACHINE,
880 POLICY_SOURCE_PLATFORM,
870 new base::StringValue(kMachineRecommended), 881 new base::StringValue(kMachineRecommended),
871 NULL); 882 NULL);
872 expected_policy.Set("d", 883 expected_policy.Set("d",
873 POLICY_LEVEL_RECOMMENDED, 884 POLICY_LEVEL_RECOMMENDED,
874 POLICY_SCOPE_USER, 885 POLICY_SCOPE_USER,
886 POLICY_SOURCE_PLATFORM,
875 new base::StringValue(kUserRecommended), 887 new base::StringValue(kUserRecommended),
876 NULL); 888 NULL);
877 EXPECT_TRUE(Matches(expected)); 889 EXPECT_TRUE(Matches(expected));
878 } 890 }
879 891
880 TEST_F(PolicyLoaderWinTest, LoadStringEncodedValues) { 892 TEST_F(PolicyLoaderWinTest, LoadStringEncodedValues) {
881 // Create a dictionary with all the types that can be stored encoded in a 893 // Create a dictionary with all the types that can be stored encoded in a
882 // string. 894 // string.
883 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "string"); 895 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "string");
884 ASSERT_TRUE(RegisterSchema( 896 ASSERT_TRUE(RegisterSchema(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 encoded_policy.SetString("double", "456.78e9"); 935 encoded_policy.SetString("double", "456.78e9");
924 encoded_policy.SetString("list", encoded_list); 936 encoded_policy.SetString("list", encoded_list);
925 encoded_policy.SetString("dict", encoded_dict); 937 encoded_policy.SetString("dict", encoded_dict);
926 938
927 const base::string16 kPathSuffix = 939 const base::string16 kPathSuffix =
928 kTestPolicyKey + base::ASCIIToUTF16("\\3rdparty\\extensions\\string"); 940 kTestPolicyKey + base::ASCIIToUTF16("\\3rdparty\\extensions\\string");
929 EXPECT_TRUE( 941 EXPECT_TRUE(
930 InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory)); 942 InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
931 943
932 PolicyBundle expected; 944 PolicyBundle expected;
933 expected.Get(ns).LoadFrom(&policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); 945 expected.Get(ns).LoadFrom(&policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
946 POLICY_SOURCE_PLATFORM);
934 EXPECT_TRUE(Matches(expected)); 947 EXPECT_TRUE(Matches(expected));
935 } 948 }
936 949
937 TEST_F(PolicyLoaderWinTest, LoadIntegerEncodedValues) { 950 TEST_F(PolicyLoaderWinTest, LoadIntegerEncodedValues) {
938 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "int"); 951 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "int");
939 ASSERT_TRUE(RegisterSchema( 952 ASSERT_TRUE(RegisterSchema(
940 ns, 953 ns,
941 "{" 954 "{"
942 " \"type\": \"object\"," 955 " \"type\": \"object\","
943 " \"properties\": {" 956 " \"properties\": {"
(...skipping 11 matching lines...) Expand all
955 const base::string16 kPathSuffix = 968 const base::string16 kPathSuffix =
956 kTestPolicyKey + base::ASCIIToUTF16("\\3rdparty\\extensions\\int"); 969 kTestPolicyKey + base::ASCIIToUTF16("\\3rdparty\\extensions\\int");
957 EXPECT_TRUE( 970 EXPECT_TRUE(
958 InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory)); 971 InstallValue(encoded_policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
959 972
960 base::DictionaryValue policy; 973 base::DictionaryValue policy;
961 policy.SetBoolean("bool", true); 974 policy.SetBoolean("bool", true);
962 policy.SetInteger("int", 123); 975 policy.SetInteger("int", 123);
963 policy.SetDouble("double", 456.0); 976 policy.SetDouble("double", 456.0);
964 PolicyBundle expected; 977 PolicyBundle expected;
965 expected.Get(ns).LoadFrom(&policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); 978 expected.Get(ns).LoadFrom(&policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
979 POLICY_SOURCE_PLATFORM);
966 EXPECT_TRUE(Matches(expected)); 980 EXPECT_TRUE(Matches(expected));
967 } 981 }
968 982
969 TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) { 983 TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) {
970 // Build a schema for an "object" with a default schema for its properties. 984 // Build a schema for an "object" with a default schema for its properties.
971 // Note that the top-level object can't have "additionalProperties", so 985 // Note that the top-level object can't have "additionalProperties", so
972 // a "policy" property is used instead. 986 // a "policy" property is used instead.
973 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "test"); 987 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, "test");
974 ASSERT_TRUE(RegisterSchema( 988 ASSERT_TRUE(RegisterSchema(
975 ns, 989 ns,
(...skipping 29 matching lines...) Expand all
1005 InstallValue(all_policies, HKEY_CURRENT_USER, kPathSuffix, kMandatory)); 1019 InstallValue(all_policies, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
1006 1020
1007 base::DictionaryValue expected_policy; 1021 base::DictionaryValue expected_policy;
1008 expected_policy.SetInteger("special-int1", 123); 1022 expected_policy.SetInteger("special-int1", 123);
1009 expected_policy.SetInteger("special-int2", -456); 1023 expected_policy.SetInteger("special-int2", -456);
1010 expected_policy.SetDouble("double1", 789.0); 1024 expected_policy.SetDouble("double1", 789.0);
1011 expected_policy.SetDouble("double2", 123.456e7); 1025 expected_policy.SetDouble("double2", 123.456e7);
1012 base::DictionaryValue expected_policies; 1026 base::DictionaryValue expected_policies;
1013 expected_policies.Set("policy", expected_policy.DeepCopy()); 1027 expected_policies.Set("policy", expected_policy.DeepCopy());
1014 PolicyBundle expected; 1028 PolicyBundle expected;
1015 expected.Get(ns).LoadFrom( 1029 expected.Get(ns).LoadFrom(&expected_policies, POLICY_LEVEL_MANDATORY,
1016 &expected_policies, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); 1030 POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM);
1017 EXPECT_TRUE(Matches(expected)); 1031 EXPECT_TRUE(Matches(expected));
1018 } 1032 }
1019 1033
1020 TEST_F(PolicyLoaderWinTest, AppliedPolicyNotPresent) { 1034 TEST_F(PolicyLoaderWinTest, AppliedPolicyNotPresent) {
1021 InstallRegistrySentinel(); 1035 InstallRegistrySentinel();
1022 gpo_list_ = NULL; 1036 gpo_list_ = NULL;
1023 gpo_list_status_ = ERROR_SUCCESS; 1037 gpo_list_status_ = ERROR_SUCCESS;
1024 1038
1025 PolicyBundle empty; 1039 PolicyBundle empty;
1026 EXPECT_TRUE(Matches(empty)); 1040 EXPECT_TRUE(Matches(empty));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 POLICY_DOMAIN_EXTENSIONS, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 1185 POLICY_DOMAIN_EXTENSIONS, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
1172 const PolicyNamespace ns_b( 1186 const PolicyNamespace ns_b(
1173 POLICY_DOMAIN_EXTENSIONS, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); 1187 POLICY_DOMAIN_EXTENSIONS, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
1174 ASSERT_TRUE(RegisterSchema(ns_a, kTestSchema)); 1188 ASSERT_TRUE(RegisterSchema(ns_a, kTestSchema));
1175 ASSERT_TRUE(RegisterSchema(ns_b, kTestSchema)); 1189 ASSERT_TRUE(RegisterSchema(ns_b, kTestSchema));
1176 1190
1177 PolicyBundle expected; 1191 PolicyBundle expected;
1178 base::DictionaryValue expected_a; 1192 base::DictionaryValue expected_a;
1179 expected_a.SetInteger("policy 1", 3); 1193 expected_a.SetInteger("policy 1", 3);
1180 expected_a.SetInteger("policy 2", 3); 1194 expected_a.SetInteger("policy 2", 3);
1181 expected.Get(ns_a).LoadFrom( 1195 expected.Get(ns_a).LoadFrom(&expected_a, POLICY_LEVEL_MANDATORY,
1182 &expected_a, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE); 1196 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM);
1183 base::DictionaryValue expected_b; 1197 base::DictionaryValue expected_b;
1184 expected_b.SetInteger("policy 1", 2); 1198 expected_b.SetInteger("policy 1", 2);
1185 expected.Get(ns_b).LoadFrom( 1199 expected.Get(ns_b).LoadFrom(&expected_b, POLICY_LEVEL_MANDATORY,
1186 &expected_b, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE); 1200 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM);
1187 EXPECT_TRUE(Matches(expected)); 1201 EXPECT_TRUE(Matches(expected));
1188 } 1202 }
1189 1203
1190 TEST_F(PolicyLoaderWinTest, LBSSupport) { 1204 TEST_F(PolicyLoaderWinTest, LBSSupport) {
1191 const PolicyNamespace ns( 1205 const PolicyNamespace ns(
1192 POLICY_DOMAIN_EXTENSIONS, "heildphpnddilhkemkielfhnkaagiabh"); 1206 POLICY_DOMAIN_EXTENSIONS, "heildphpnddilhkemkielfhnkaagiabh");
1193 schema_registry_.RegisterComponent(ns, Schema()); 1207 schema_registry_.RegisterComponent(ns, Schema());
1194 1208
1195 const char kIncompleteSchema[] = 1209 const char kIncompleteSchema[] =
1196 "{" 1210 "{"
(...skipping 15 matching lines...) Expand all
1212 base::DictionaryValue root; 1226 base::DictionaryValue root;
1213 root.Set(base::UTF16ToUTF8(kMandatory), policy.DeepCopy()); 1227 root.Set(base::UTF16ToUTF8(kMandatory), policy.DeepCopy());
1214 root.SetString(kSchema, kIncompleteSchema); 1228 root.SetString(kSchema, kIncompleteSchema);
1215 EXPECT_TRUE(InstallValue(root, HKEY_LOCAL_MACHINE, 1229 EXPECT_TRUE(InstallValue(root, HKEY_LOCAL_MACHINE,
1216 kPathSuffix, base::ASCIIToUTF16(ns.component_id))); 1230 kPathSuffix, base::ASCIIToUTF16(ns.component_id)));
1217 1231
1218 PolicyBundle expected; 1232 PolicyBundle expected;
1219 PolicyMap& expected_policy = expected.Get(ns); 1233 PolicyMap& expected_policy = expected.Get(ns);
1220 expected_policy.Set("alternative_browser_path", 1234 expected_policy.Set("alternative_browser_path",
1221 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1235 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1236 POLICY_SOURCE_PLATFORM,
1222 new base::StringValue("c:\\legacy\\browser.exe"), NULL); 1237 new base::StringValue("c:\\legacy\\browser.exe"), NULL);
1223 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1238 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1224 list.DeepCopy(), NULL); 1239 POLICY_SOURCE_PLATFORM, list.DeepCopy(), nullptr);
1225 EXPECT_TRUE(Matches(expected)); 1240 EXPECT_TRUE(Matches(expected));
1226 } 1241 }
1227 1242
1228 } // namespace policy 1243 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_win.cc ('k') | components/policy/core/common/policy_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698