mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[NTDLL_APITEST] Implement NtAdjustGroupsToken API tests
This commit is contained in:
parent
8e6fc7a5f5
commit
32db51fcff
3 changed files with 80 additions and 0 deletions
|
@ -10,6 +10,7 @@ list(APPEND SOURCE
|
|||
load_notifications.c
|
||||
locale.c
|
||||
NtAcceptConnectPort.c
|
||||
NtAdjustGroupsToken.c
|
||||
NtAdjustPrivilegesToken.c
|
||||
NtAllocateVirtualMemory.c
|
||||
NtApphelpCacheControl.c
|
||||
|
|
77
modules/rostests/apitests/ntdll/NtAdjustGroupsToken.c
Normal file
77
modules/rostests/apitests/ntdll/NtAdjustGroupsToken.c
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||
* PURPOSE: Tests for the NtAdjustGroupsToken API
|
||||
* COPYRIGHT: Copyright 2021 George Bișoc <george.bisoc@reactos.org>
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
static
|
||||
HANDLE
|
||||
GetProcessToken(
|
||||
_In_ DWORD Access)
|
||||
{
|
||||
BOOL Success;
|
||||
HANDLE Token;
|
||||
|
||||
Success = OpenProcessToken(GetCurrentProcess(), Access, &Token);
|
||||
if (!Success)
|
||||
{
|
||||
skip("Failed to open the process' token (error code: %lu)!\n", GetLastError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Token;
|
||||
}
|
||||
|
||||
START_TEST(NtAdjustGroupsToken)
|
||||
{
|
||||
HANDLE TokenHandle;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Get the token from current process but with incorrect rights */
|
||||
TokenHandle = GetProcessToken(TOKEN_DUPLICATE);
|
||||
|
||||
/* We give an invalid handle */
|
||||
Status = NtAdjustGroupsToken(NULL,
|
||||
TRUE,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_INVALID_HANDLE);
|
||||
|
||||
/* We're trying to adjust the token's groups with wrong rights */
|
||||
Status = NtAdjustGroupsToken(TokenHandle,
|
||||
TRUE,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_ACCESS_DENIED);
|
||||
|
||||
/* Close our handle and open a new one with right access right */
|
||||
CloseHandle(TokenHandle);
|
||||
TokenHandle = GetProcessToken(TOKEN_ADJUST_GROUPS);
|
||||
|
||||
/* We don't give a list of groups to be adjusted in token */
|
||||
Status = NtAdjustGroupsToken(TokenHandle,
|
||||
FALSE,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_INVALID_PARAMETER);
|
||||
|
||||
/* Reset the groups of an access token to default */
|
||||
Status = NtAdjustGroupsToken(TokenHandle,
|
||||
TRUE,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
CloseHandle(TokenHandle);
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
extern void func_LdrEnumResources(void);
|
||||
extern void func_load_notifications(void);
|
||||
extern void func_NtAcceptConnectPort(void);
|
||||
extern void func_NtAdjustGroupsToken(void);
|
||||
extern void func_NtAdjustPrivilegesToken(void);
|
||||
extern void func_NtAllocateVirtualMemory(void);
|
||||
extern void func_NtApphelpCacheControl(void);
|
||||
|
@ -92,6 +93,7 @@ const struct test winetest_testlist[] =
|
|||
{ "LdrEnumResources", func_LdrEnumResources },
|
||||
{ "load_notifications", func_load_notifications },
|
||||
{ "NtAcceptConnectPort", func_NtAcceptConnectPort },
|
||||
{ "NtAdjustGroupsToken", func_NtAdjustGroupsToken },
|
||||
{ "NtAdjustPrivilegesToken", func_NtAdjustPrivilegesToken },
|
||||
{ "NtAllocateVirtualMemory", func_NtAllocateVirtualMemory },
|
||||
{ "NtApphelpCacheControl", func_NtApphelpCacheControl },
|
||||
|
|
Loading…
Reference in a new issue