aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/test/DUtilUnitTest
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-09-02 16:12:42 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-09-03 15:29:26 -0500
commit237bdc6a97c0dd455da99c16e6b3b7cac4c79e86 (patch)
tree1f2c789a7aa752e068fac8a4ca08815d13bf527a /src/libs/dutil/test/DUtilUnitTest
parent7728e34e48a4fdb710ecc92dd8dca833bff3993f (diff)
downloadwix-237bdc6a97c0dd455da99c16e6b3b7cac4c79e86.tar.gz
wix-237bdc6a97c0dd455da99c16e6b3b7cac4c79e86.tar.bz2
wix-237bdc6a97c0dd455da99c16e6b3b7cac4c79e86.zip
Add WixCanRestart and make wixstdba elevate for restart when required.
Fixes 5499
Diffstat (limited to 'src/libs/dutil/test/DUtilUnitTest')
-rw-r--r--src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp
index 297d90f4..8672ed38 100644
--- a/src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp
+++ b/src/libs/dutil/test/DUtilUnitTest/ProcUtilTest.cpp
@@ -6,6 +6,7 @@ using namespace System;
6using namespace System::Security::Principal; 6using namespace System::Security::Principal;
7using namespace Xunit; 7using namespace Xunit;
8using namespace WixBuildTools::TestSupport; 8using namespace WixBuildTools::TestSupport;
9using namespace WixBuildTools::TestSupport::XunitExtensions;
9 10
10namespace DutilTests 11namespace DutilTests
11{ 12{
@@ -13,7 +14,7 @@ namespace DutilTests
13 { 14 {
14 public: 15 public:
15 [Fact] 16 [Fact]
16 void ProcTokenUserTest() 17 void ProcGetTokenInformationTest()
17 { 18 {
18 HRESULT hr = S_OK; 19 HRESULT hr = S_OK;
19 TOKEN_USER* pTokenUser = NULL; 20 TOKEN_USER* pTokenUser = NULL;
@@ -21,7 +22,7 @@ namespace DutilTests
21 22
22 try 23 try
23 { 24 {
24 hr = ProcTokenUser(::GetCurrentProcess(), &pTokenUser); 25 hr = ProcGetTokenInformation(::GetCurrentProcess(), TokenUser, reinterpret_cast<LPVOID*>(&pTokenUser));
25 NativeAssert::Succeeded(hr, "Failed to get TokenUser for current process."); 26 NativeAssert::Succeeded(hr, "Failed to get TokenUser for current process.");
26 27
27 if (!::ConvertSidToStringSidW(pTokenUser->User.Sid, &sczSid)) 28 if (!::ConvertSidToStringSidW(pTokenUser->User.Sid, &sczSid))
@@ -38,5 +39,28 @@ namespace DutilTests
38 ReleaseStr(sczSid); 39 ReleaseStr(sczSid);
39 } 40 }
40 } 41 }
42
43 [SkippableFact]
44 void ProcHasPrivilegeTest()
45 {
46 HRESULT hr = S_OK;
47 BOOL fHasPrivilege = FALSE;
48
49 hr = ProcHasPrivilege(::GetCurrentProcess(), SE_CREATE_TOKEN_NAME, &fHasPrivilege);
50 NativeAssert::Succeeded(hr, "Failed to check privilege for current process.");
51
52 if (fHasPrivilege)
53 {
54 WixAssert::Skip("Didn't expect process to have SE_CREATE_TOKEN_NAME privilege");
55 }
56
57 hr = ProcHasPrivilege(::GetCurrentProcess(), SE_INC_WORKING_SET_NAME, &fHasPrivilege);
58 NativeAssert::Succeeded(hr, "Failed to check privilege for current process.");
59
60 if (!fHasPrivilege)
61 {
62 WixAssert::Skip("Expected process to have SE_INC_WORKING_SET_NAME privilege");
63 }
64 }
41 }; 65 };
42} 66}