| 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 <memory> |
| 6 |
| 5 #include "base/win/windows_version.h" | 7 #include "base/win/windows_version.h" |
| 6 #include "sandbox/win/src/app_container.h" | 8 #include "sandbox/win/src/app_container.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 10 |
| 9 namespace sandbox { | 11 namespace sandbox { |
| 10 | 12 |
| 11 // Tests the low level AppContainer interface. | 13 // Tests the low level AppContainer interface. |
| 12 TEST(AppContainerTest, CreateAppContainer) { | 14 TEST(AppContainerTest, CreateAppContainer) { |
| 13 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) | 15 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) |
| 14 return; | 16 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 29 | 31 |
| 30 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, | 32 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, |
| 31 CreateAppContainer(L"Foo", kName)); | 33 CreateAppContainer(L"Foo", kName)); |
| 32 } | 34 } |
| 33 | 35 |
| 34 // Tests handling of security capabilities on the attribute list. | 36 // Tests handling of security capabilities on the attribute list. |
| 35 TEST(AppContainerTest, SecurityCapabilities) { | 37 TEST(AppContainerTest, SecurityCapabilities) { |
| 36 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) | 38 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) |
| 37 return; | 39 return; |
| 38 | 40 |
| 39 scoped_ptr<AppContainerAttributes> attributes(new AppContainerAttributes); | 41 std::unique_ptr<AppContainerAttributes> attributes( |
| 42 new AppContainerAttributes); |
| 40 std::vector<base::string16> capabilities; | 43 std::vector<base::string16> capabilities; |
| 41 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, | 44 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, |
| 42 attributes->SetAppContainer(L"S-1-foo", capabilities)); | 45 attributes->SetAppContainer(L"S-1-foo", capabilities)); |
| 43 | 46 |
| 44 EXPECT_EQ(SBOX_ALL_OK, | 47 EXPECT_EQ(SBOX_ALL_OK, |
| 45 attributes->SetAppContainer(L"S-1-15-2-12345-234", capabilities)); | 48 attributes->SetAppContainer(L"S-1-15-2-12345-234", capabilities)); |
| 46 EXPECT_TRUE(attributes->HasAppContainer()); | 49 EXPECT_TRUE(attributes->HasAppContainer()); |
| 47 | 50 |
| 48 attributes.reset(new AppContainerAttributes); | 51 attributes.reset(new AppContainerAttributes); |
| 49 capabilities.push_back(L"S-1-15-3-12345678-87654321"); | 52 capabilities.push_back(L"S-1-15-3-12345678-87654321"); |
| 50 capabilities.push_back(L"S-1-15-3-1"); | 53 capabilities.push_back(L"S-1-15-3-1"); |
| 51 capabilities.push_back(L"S-1-15-3-2"); | 54 capabilities.push_back(L"S-1-15-3-2"); |
| 52 capabilities.push_back(L"S-1-15-3-3"); | 55 capabilities.push_back(L"S-1-15-3-3"); |
| 53 EXPECT_EQ(SBOX_ALL_OK, | 56 EXPECT_EQ(SBOX_ALL_OK, |
| 54 attributes->SetAppContainer(L"S-1-15-2-1-2", capabilities)); | 57 attributes->SetAppContainer(L"S-1-15-2-1-2", capabilities)); |
| 55 EXPECT_TRUE(attributes->HasAppContainer()); | 58 EXPECT_TRUE(attributes->HasAppContainer()); |
| 56 } | 59 } |
| 57 | 60 |
| 58 } // namespace sandbox | 61 } // namespace sandbox |
| OLD | NEW |