OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <userenv.h> | 10 #include <userenv.h> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "base/strings/stringprintf.h" | 32 #include "base/strings/stringprintf.h" |
33 #include "base/strings/utf_string_conversions.h" | 33 #include "base/strings/utf_string_conversions.h" |
34 #include "base/sys_byteorder.h" | 34 #include "base/sys_byteorder.h" |
35 #include "base/win/registry.h" | 35 #include "base/win/registry.h" |
36 #include "base/win/win_util.h" | 36 #include "base/win/win_util.h" |
37 #include "components/policy/core/common/async_policy_provider.h" | 37 #include "components/policy/core/common/async_policy_provider.h" |
38 #include "components/policy/core/common/configuration_policy_provider_test.h" | 38 #include "components/policy/core/common/configuration_policy_provider_test.h" |
39 #include "components/policy/core/common/external_data_fetcher.h" | 39 #include "components/policy/core/common/external_data_fetcher.h" |
40 #include "components/policy/core/common/policy_bundle.h" | 40 #include "components/policy/core/common/policy_bundle.h" |
41 #include "components/policy/core/common/policy_map.h" | 41 #include "components/policy/core/common/policy_map.h" |
42 #include "components/policy/core/common/policy_test_utils.h" | |
43 #include "components/policy/core/common/policy_types.h" | 42 #include "components/policy/core/common/policy_types.h" |
44 #include "components/policy/core/common/preg_parser_win.h" | 43 #include "components/policy/core/common/preg_parser_win.h" |
45 #include "components/policy/core/common/schema_map.h" | 44 #include "components/policy/core/common/schema_map.h" |
46 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
47 | 46 |
48 using base::UTF8ToUTF16; | 47 using base::UTF8ToUTF16; |
49 using base::UTF16ToUTF8; | 48 using base::UTF16ToUTF8; |
50 using base::win::RegKey; | 49 using base::win::RegKey; |
51 | 50 |
52 namespace policy { | 51 namespace policy { |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 gpo->lpFileSysPath = const_cast<wchar_t*>(path.value().c_str()); | 745 gpo->lpFileSysPath = const_cast<wchar_t*>(path.value().c_str()); |
747 gpo->pNext = next; | 746 gpo->pNext = next; |
748 gpo->pPrev = prev; | 747 gpo->pPrev = prev; |
749 } | 748 } |
750 | 749 |
751 bool Matches(const PolicyBundle& expected) { | 750 bool Matches(const PolicyBundle& expected) { |
752 PolicyLoaderWin loader(loop_.task_runner(), kTestPolicyKey, | 751 PolicyLoaderWin loader(loop_.task_runner(), kTestPolicyKey, |
753 gpo_list_provider_); | 752 gpo_list_provider_); |
754 std::unique_ptr<PolicyBundle> loaded( | 753 std::unique_ptr<PolicyBundle> loaded( |
755 loader.InitialLoad(schema_registry_.schema_map())); | 754 loader.InitialLoad(schema_registry_.schema_map())); |
756 bool match = loaded->Equals(expected); | 755 return loaded->Equals(expected); |
757 if (!match) { | |
758 LOG(ERROR) << "EXPECTED: " << expected; | |
759 LOG(ERROR) << "ACTUAL: " << *loaded.get(); | |
760 } | |
761 return match; | |
762 } | 756 } |
763 | 757 |
764 void InstallRegistrySentinel() { | 758 void InstallRegistrySentinel() { |
765 RegKey hklm_key(HKEY_CURRENT_USER, kTestPolicyKey, KEY_ALL_ACCESS); | 759 RegKey hklm_key(HKEY_CURRENT_USER, kTestPolicyKey, KEY_ALL_ACCESS); |
766 ASSERT_TRUE(hklm_key.Valid()); | 760 ASSERT_TRUE(hklm_key.Valid()); |
767 hklm_key.WriteValue( | 761 hklm_key.WriteValue( |
768 UTF8ToUTF16(test_keys::kKeyString).c_str(), | 762 UTF8ToUTF16(test_keys::kKeyString).c_str(), |
769 UTF8ToUTF16("registry").c_str()); | 763 UTF8ToUTF16("registry").c_str()); |
770 } | 764 } |
771 | 765 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 expected.Get(ns_a).LoadFrom(&expected_a, POLICY_LEVEL_MANDATORY, | 1185 expected.Get(ns_a).LoadFrom(&expected_a, POLICY_LEVEL_MANDATORY, |
1192 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM); | 1186 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM); |
1193 base::DictionaryValue expected_b; | 1187 base::DictionaryValue expected_b; |
1194 expected_b.SetInteger("policy 1", 2); | 1188 expected_b.SetInteger("policy 1", 2); |
1195 expected.Get(ns_b).LoadFrom(&expected_b, POLICY_LEVEL_MANDATORY, | 1189 expected.Get(ns_b).LoadFrom(&expected_b, POLICY_LEVEL_MANDATORY, |
1196 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM); | 1190 POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM); |
1197 EXPECT_TRUE(Matches(expected)); | 1191 EXPECT_TRUE(Matches(expected)); |
1198 } | 1192 } |
1199 | 1193 |
1200 } // namespace policy | 1194 } // namespace policy |
OLD | NEW |