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