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