| Index: chrome/installer/setup/setup_util_unittest.cc
|
| diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc
|
| index e3e705ce27b21f901775bcec389cd60af206e752..b3400b58a735722e1bef4fe613d13dff01f60e44 100644
|
| --- a/chrome/installer/setup/setup_util_unittest.cc
|
| +++ b/chrome/installer/setup/setup_util_unittest.cc
|
| @@ -38,59 +38,6 @@
|
| #include "chrome/installer/util/util_constants.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -namespace {
|
| -
|
| -// The privilege tested in ScopeTokenPrivilege tests below.
|
| -// Use SE_RESTORE_NAME as it is one of the many privileges that is available,
|
| -// but not enabled by default on processes running at high integrity.
|
| -static const wchar_t kTestedPrivilege[] = SE_RESTORE_NAME;
|
| -
|
| -// Returns true if the current process' token has privilege |privilege_name|
|
| -// enabled.
|
| -bool CurrentProcessHasPrivilege(const wchar_t* privilege_name) {
|
| - HANDLE temp_handle;
|
| - if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY,
|
| - &temp_handle)) {
|
| - ADD_FAILURE();
|
| - return false;
|
| - }
|
| -
|
| - base::win::ScopedHandle token(temp_handle);
|
| -
|
| - // First get the size of the buffer needed for |privileges| below.
|
| - DWORD size;
|
| - EXPECT_FALSE(::GetTokenInformation(token.Get(), TokenPrivileges, NULL, 0,
|
| - &size));
|
| -
|
| - std::unique_ptr<BYTE[]> privileges_bytes(new BYTE[size]);
|
| - TOKEN_PRIVILEGES* privileges =
|
| - reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get());
|
| -
|
| - if (!::GetTokenInformation(token.Get(), TokenPrivileges, privileges, size,
|
| - &size)) {
|
| - ADD_FAILURE();
|
| - return false;
|
| - }
|
| -
|
| - // There is no point getting a buffer to store more than |privilege_name|\0 as
|
| - // anything longer will obviously not be equal to |privilege_name|.
|
| - const DWORD desired_size = static_cast<DWORD>(wcslen(privilege_name));
|
| - const DWORD buffer_size = desired_size + 1;
|
| - std::unique_ptr<wchar_t[]> name_buffer(new wchar_t[buffer_size]);
|
| - for (int i = privileges->PrivilegeCount - 1; i >= 0 ; --i) {
|
| - LUID_AND_ATTRIBUTES& luid_and_att = privileges->Privileges[i];
|
| - DWORD size = buffer_size;
|
| - ::LookupPrivilegeName(NULL, &luid_and_att.Luid, name_buffer.get(), &size);
|
| - if (size == desired_size &&
|
| - wcscmp(name_buffer.get(), privilege_name) == 0) {
|
| - return luid_and_att.Attributes == SE_PRIVILEGE_ENABLED;
|
| - }
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| // Test that we are parsing Chrome version correctly.
|
| TEST(SetupUtilTest, GetMaxVersionFromArchiveDirTest) {
|
| // Create a version dir
|
| @@ -144,52 +91,6 @@ TEST(SetupUtilTest, DeleteFileFromTempProcess) {
|
| EXPECT_FALSE(base::PathExists(test_file)) << test_file.value();
|
| }
|
|
|
| -// Note: This test is only valid when run at high integrity (i.e. it will fail
|
| -// at medium integrity).
|
| -TEST(SetupUtilTest, ScopedTokenPrivilegeBasic) {
|
| - ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| -
|
| - if (!::IsUserAnAdmin()) {
|
| - LOG(WARNING) << "Skipping SetupUtilTest.ScopedTokenPrivilegeBasic due to "
|
| - "not running as admin.";
|
| - return;
|
| - }
|
| -
|
| - {
|
| - installer::ScopedTokenPrivilege test_scoped_privilege(kTestedPrivilege);
|
| - ASSERT_TRUE(test_scoped_privilege.is_enabled());
|
| - ASSERT_TRUE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| - }
|
| -
|
| - ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| -}
|
| -
|
| -// Note: This test is only valid when run at high integrity (i.e. it will fail
|
| -// at medium integrity).
|
| -TEST(SetupUtilTest, ScopedTokenPrivilegeAlreadyEnabled) {
|
| - ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| -
|
| - if (!::IsUserAnAdmin()) {
|
| - LOG(WARNING) << "Skipping SetupUtilTest.ScopedTokenPrivilegeAlreadyEnabled "
|
| - "due to not running as admin.";
|
| - return;
|
| - }
|
| -
|
| - {
|
| - installer::ScopedTokenPrivilege test_scoped_privilege(kTestedPrivilege);
|
| - ASSERT_TRUE(test_scoped_privilege.is_enabled());
|
| - ASSERT_TRUE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| - {
|
| - installer::ScopedTokenPrivilege dup_scoped_privilege(kTestedPrivilege);
|
| - ASSERT_TRUE(dup_scoped_privilege.is_enabled());
|
| - ASSERT_TRUE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| - }
|
| - ASSERT_TRUE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| - }
|
| -
|
| - ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege));
|
| -}
|
| -
|
| TEST(SetupUtilTest, GuidToSquid) {
|
| ASSERT_EQ(installer::GuidToSquid(L"EDA620E3-AA98-3846-B81E-3493CB2E0E02"),
|
| L"3E026ADE89AA64838BE14339BCE2E020");
|
|
|