OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 <shlobj.h> | 5 #include <shlobj.h> |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "sandbox/src/registry_policy.h" | 8 #include "sandbox/src/registry_policy.h" |
9 #include "sandbox/src/sandbox.h" | 9 #include "sandbox/src/sandbox.h" |
10 #include "sandbox/src/sandbox_policy.h" | 10 #include "sandbox/src/sandbox_policy.h" |
11 #include "sandbox/src/sandbox_factory.h" | 11 #include "sandbox/src/sandbox_factory.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 TargetPolicy::REG_ALLOW_ANY, | 95 TargetPolicy::REG_ALLOW_ANY, |
96 L"HKEY_LOCAL_MACHINE\\Software\\Microsoft")); | 96 L"HKEY_LOCAL_MACHINE\\Software\\Microsoft")); |
97 | 97 |
98 // Tests read access on key allowed for read-write. | 98 // Tests read access on key allowed for read-write. |
99 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( | 99 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( |
100 L"Reg_OpenKey create read HKEY_LOCAL_MACHINE software\\microsoft")); | 100 L"Reg_OpenKey create read HKEY_LOCAL_MACHINE software\\microsoft")); |
101 | 101 |
102 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( | 102 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( |
103 L"Reg_OpenKey open read HKEY_LOCAL_MACHINE software\\microsoft")); | 103 L"Reg_OpenKey open read HKEY_LOCAL_MACHINE software\\microsoft")); |
104 | 104 |
105 // Tests write access on key allowed for read-write. | 105 if (::IsUserAnAdmin()) { |
106 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( | 106 // Tests write access on key allowed for read-write. |
107 L"Reg_OpenKey create write HKEY_LOCAL_MACHINE software\\microsoft")); | 107 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( |
| 108 L"Reg_OpenKey create write HKEY_LOCAL_MACHINE software\\microsoft")); |
108 | 109 |
109 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( | 110 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( |
110 L"Reg_OpenKey open write HKEY_LOCAL_MACHINE software\\microsoft")); | 111 L"Reg_OpenKey open write HKEY_LOCAL_MACHINE software\\microsoft")); |
| 112 } |
111 | 113 |
112 // Tests subdirectory access on keys where we don't have subdirectory acess. | 114 // Tests subdirectory access on keys where we don't have subdirectory acess. |
113 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Reg_OpenKey create read " | 115 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Reg_OpenKey create read " |
114 L"HKEY_LOCAL_MACHINE software\\microsoft\\Windows")); | 116 L"HKEY_LOCAL_MACHINE software\\microsoft\\Windows")); |
115 | 117 |
116 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Reg_OpenKey open read " | 118 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Reg_OpenKey open read " |
117 L"HKEY_LOCAL_MACHINE software\\microsoft\\windows")); | 119 L"HKEY_LOCAL_MACHINE software\\microsoft\\windows")); |
118 | 120 |
119 // Tests to see if we can create keys where we dont have subdirectory access. | 121 // Tests to see if we can create keys where we dont have subdirectory access. |
120 // This is denied. | 122 // This is denied. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 280 |
279 // Tests maximum allowed access where we only have read-only access. | 281 // Tests maximum allowed access where we only have read-only access. |
280 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( | 282 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( |
281 L"Reg_OpenKey create maximum_allowed HKEY_CURRENT_USER software")); | 283 L"Reg_OpenKey create maximum_allowed HKEY_CURRENT_USER software")); |
282 | 284 |
283 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( | 285 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest( |
284 L"Reg_OpenKey open maximum_allowed HKEY_CURRENT_USER software")); | 286 L"Reg_OpenKey open maximum_allowed HKEY_CURRENT_USER software")); |
285 } | 287 } |
286 | 288 |
287 } // namespace sandbox | 289 } // namespace sandbox |
OLD | NEW |