OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
6 #include <cctype> | 6 #include <cctype> |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <winioctl.h> | 9 #include <winioctl.h> |
10 | 10 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 TestRunner runner; | 273 TestRunner runner; |
274 EXPECT_TRUE(runner.AddRuleSys32(TargetPolicy::FILES_ALLOW_ANY, L"calc.exe")); | 274 EXPECT_TRUE(runner.AddRuleSys32(TargetPolicy::FILES_ALLOW_ANY, L"calc.exe")); |
275 | 275 |
276 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"File_CreateSys32 calc.exe")); | 276 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"File_CreateSys32 calc.exe")); |
277 | 277 |
278 runner.SetTestState(BEFORE_REVERT); | 278 runner.SetTestState(BEFORE_REVERT); |
279 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"File_CreateSys32 calc.exe")); | 279 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"File_CreateSys32 calc.exe")); |
280 } | 280 } |
281 | 281 |
282 TEST(FilePolicyTest, AllowNtCreateWithNativePath) { | 282 TEST(FilePolicyTest, AllowNtCreateWithNativePath) { |
283 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
284 return; | |
285 | 283 |
286 base::string16 calc = MakePathToSys(L"calc.exe", false); | 284 base::string16 calc = MakePathToSys(L"calc.exe", false); |
287 base::string16 nt_path; | 285 base::string16 nt_path; |
288 ASSERT_TRUE(GetNtPathFromWin32Path(calc, &nt_path)); | 286 ASSERT_TRUE(GetNtPathFromWin32Path(calc, &nt_path)); |
289 TestRunner runner; | 287 TestRunner runner; |
290 runner.AddFsRule(TargetPolicy::FILES_ALLOW_READONLY, nt_path.c_str()); | 288 runner.AddFsRule(TargetPolicy::FILES_ALLOW_READONLY, nt_path.c_str()); |
291 | 289 |
292 wchar_t buff[MAX_PATH]; | 290 wchar_t buff[MAX_PATH]; |
293 ::wsprintfW(buff, L"File_CreateSys32 %s", nt_path.c_str()); | 291 ::wsprintfW(buff, L"File_CreateSys32 %s", nt_path.c_str()); |
294 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(buff)); | 292 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(buff)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 327 |
330 // Verify that we really have write access to the file. | 328 // Verify that we really have write access to the file. |
331 runner.SetTestState(BEFORE_REVERT); | 329 runner.SetTestState(BEFORE_REVERT); |
332 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(command_write)); | 330 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(command_write)); |
333 | 331 |
334 DeleteFile(temp_file_name); | 332 DeleteFile(temp_file_name); |
335 } | 333 } |
336 | 334 |
337 // Tests support of "\\\\.\\DeviceName" kind of paths. | 335 // Tests support of "\\\\.\\DeviceName" kind of paths. |
338 TEST(FilePolicyTest, AllowImplicitDeviceName) { | 336 TEST(FilePolicyTest, AllowImplicitDeviceName) { |
339 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
340 return; | |
341 | 337 |
342 TestRunner runner; | 338 TestRunner runner; |
343 | 339 |
344 wchar_t temp_directory[MAX_PATH]; | 340 wchar_t temp_directory[MAX_PATH]; |
345 wchar_t temp_file_name[MAX_PATH]; | 341 wchar_t temp_file_name[MAX_PATH]; |
346 ASSERT_NE(::GetTempPath(MAX_PATH, temp_directory), 0u); | 342 ASSERT_NE(::GetTempPath(MAX_PATH, temp_directory), 0u); |
347 ASSERT_NE(::GetTempFileName(temp_directory, L"test", 0, temp_file_name), 0u); | 343 ASSERT_NE(::GetTempFileName(temp_directory, L"test", 0, temp_file_name), 0u); |
348 | 344 |
349 std::wstring path(temp_file_name); | 345 std::wstring path(temp_file_name); |
350 EXPECT_TRUE(ConvertToLongPath(&path)); | 346 EXPECT_TRUE(ConvertToLongPath(&path)); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 | 660 |
665 TEST(FilePolicyTest, CheckMissingNTPrefixEscape) { | 661 TEST(FilePolicyTest, CheckMissingNTPrefixEscape) { |
666 base::string16 name = L"C:\\NAME"; | 662 base::string16 name = L"C:\\NAME"; |
667 | 663 |
668 base::string16 result = FixNTPrefixForMatch(name); | 664 base::string16 result = FixNTPrefixForMatch(name); |
669 | 665 |
670 EXPECT_STREQ(result.c_str(), L"\\/?/?\\C:\\NAME"); | 666 EXPECT_STREQ(result.c_str(), L"\\/?/?\\C:\\NAME"); |
671 } | 667 } |
672 | 668 |
673 } // namespace sandbox | 669 } // namespace sandbox |
OLD | NEW |