Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #include "base/win/windows_version.h" |
michael@0 | 6 | #include "sandbox/win/src/app_container.h" |
michael@0 | 7 | #include "testing/gtest/include/gtest/gtest.h" |
michael@0 | 8 | |
michael@0 | 9 | namespace sandbox { |
michael@0 | 10 | |
michael@0 | 11 | // Tests the low level AppContainer interface. |
michael@0 | 12 | TEST(AppContainerTest, CreateAppContainer) { |
michael@0 | 13 | if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) |
michael@0 | 14 | return; |
michael@0 | 15 | |
michael@0 | 16 | const wchar_t kName[] = L"Test"; |
michael@0 | 17 | const wchar_t kValidSid[] = L"S-1-15-2-12345-234-567-890-123-456-789"; |
michael@0 | 18 | |
michael@0 | 19 | EXPECT_TRUE(LookupAppContainer(kValidSid).empty()); |
michael@0 | 20 | EXPECT_EQ(SBOX_ERROR_GENERIC, DeleteAppContainer(kValidSid)); |
michael@0 | 21 | |
michael@0 | 22 | EXPECT_EQ(SBOX_ALL_OK, CreateAppContainer(kValidSid, kName)); |
michael@0 | 23 | EXPECT_EQ(SBOX_ERROR_GENERIC, CreateAppContainer(kValidSid, kName)); |
michael@0 | 24 | EXPECT_EQ(kName, LookupAppContainer(kValidSid)); |
michael@0 | 25 | EXPECT_EQ(SBOX_ALL_OK, DeleteAppContainer(kValidSid)); |
michael@0 | 26 | |
michael@0 | 27 | EXPECT_TRUE(LookupAppContainer(kValidSid).empty()); |
michael@0 | 28 | EXPECT_EQ(SBOX_ERROR_GENERIC, DeleteAppContainer(kValidSid)); |
michael@0 | 29 | |
michael@0 | 30 | EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, |
michael@0 | 31 | CreateAppContainer(L"Foo", kName)); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | // Tests handling of security capabilities on the attribute list. |
michael@0 | 35 | TEST(AppContainerTest, SecurityCapabilities) { |
michael@0 | 36 | if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8) |
michael@0 | 37 | return; |
michael@0 | 38 | |
michael@0 | 39 | scoped_ptr<AppContainerAttributes> attributes(new AppContainerAttributes); |
michael@0 | 40 | std::vector<string16> capabilities; |
michael@0 | 41 | EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER, |
michael@0 | 42 | attributes->SetAppContainer(L"S-1-foo", capabilities)); |
michael@0 | 43 | |
michael@0 | 44 | EXPECT_EQ(SBOX_ALL_OK, |
michael@0 | 45 | attributes->SetAppContainer(L"S-1-15-2-12345-234", capabilities)); |
michael@0 | 46 | EXPECT_TRUE(attributes->HasAppContainer()); |
michael@0 | 47 | |
michael@0 | 48 | attributes.reset(new AppContainerAttributes); |
michael@0 | 49 | capabilities.push_back(L"S-1-15-3-12345678-87654321"); |
michael@0 | 50 | capabilities.push_back(L"S-1-15-3-1"); |
michael@0 | 51 | capabilities.push_back(L"S-1-15-3-2"); |
michael@0 | 52 | capabilities.push_back(L"S-1-15-3-3"); |
michael@0 | 53 | EXPECT_EQ(SBOX_ALL_OK, |
michael@0 | 54 | attributes->SetAppContainer(L"S-1-15-2-1-2", capabilities)); |
michael@0 | 55 | EXPECT_TRUE(attributes->HasAppContainer()); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | } // namespace sandbox |