| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <memory> | |
| 6 | |
| 7 #include "base/win/windows_version.h" | |
| 8 #include "sandbox/win/src/app_container.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace sandbox { | |
| 12 | |
| 13 // Tests the low level AppContainer interface. | |
| 14 TEST(AppContainerTest, CreateAppContainer) { | |
| 15 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) | |
| 16 return; | |
| 17 | |
| 18 const wchar_t kName[] = L"Test"; | |
| 19 const wchar_t kValidSid[] = L"S-1-15-2-12345-234-567-890-123-456-789"; | |
| 20 | |
| 21 EXPECT_TRUE(LookupAppContainer(kValidSid).empty()); | |
| 22 EXPECT_EQ(SBOX_ERROR_GENERIC, DeleteAppContainer(kValidSid)); | |
| 23 | |
| 24 EXPECT_EQ(SBOX_ALL_OK, CreateAppContainer(kValidSid, kName)); | |
| 25 EXPECT_EQ(SBOX_ERROR_GENERIC, CreateAppContainer(kValidSid, kName)); | |
| 26 EXPECT_EQ(kName, LookupAppContainer(kValidSid)); | |
| 27 EXPECT_EQ(SBOX_ALL_OK, DeleteAppContainer(kValidSid)); | |
| 28 | |
| 29 EXPECT_TRUE(LookupAppContainer(kValidSid).empty()); | |
| 30 EXPECT_EQ(SBOX_ERROR_GENERIC, DeleteAppContainer(kValidSid)); | |
| 31 | |
| 32 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, | |
| 33 CreateAppContainer(L"Foo", kName)); | |
| 34 } | |
| 35 | |
| 36 // Tests handling of security capabilities on the attribute list. | |
| 37 TEST(AppContainerTest, SecurityCapabilities) { | |
| 38 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) | |
| 39 return; | |
| 40 | |
| 41 std::unique_ptr<AppContainerAttributes> attributes( | |
| 42 new AppContainerAttributes); | |
| 43 std::vector<base::string16> capabilities; | |
| 44 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, | |
| 45 attributes->SetAppContainer(L"S-1-foo", capabilities)); | |
| 46 | |
| 47 EXPECT_EQ(SBOX_ALL_OK, | |
| 48 attributes->SetAppContainer(L"S-1-15-2-12345-234", capabilities)); | |
| 49 EXPECT_TRUE(attributes->HasAppContainer()); | |
| 50 | |
| 51 attributes.reset(new AppContainerAttributes); | |
| 52 capabilities.push_back(L"S-1-15-3-12345678-87654321"); | |
| 53 capabilities.push_back(L"S-1-15-3-1"); | |
| 54 capabilities.push_back(L"S-1-15-3-2"); | |
| 55 capabilities.push_back(L"S-1-15-3-3"); | |
| 56 EXPECT_EQ(SBOX_ALL_OK, | |
| 57 attributes->SetAppContainer(L"S-1-15-2-1-2", capabilities)); | |
| 58 EXPECT_TRUE(attributes->HasAppContainer()); | |
| 59 } | |
| 60 | |
| 61 } // namespace sandbox | |
| OLD | NEW |