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

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

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