Author: jgardou
Date: Mon Oct 13 18:49:09 2014
New Revision: 64736
URL:
http://svn.reactos.org/svn/reactos?rev=64736&view=rev
Log:
[ADVAPI32_APITESTS]
- Add a few tests for DuplicateTokenEx
Added:
trunk/rostests/apitests/advapi32/DuplicateTokenEx.c (with props)
Modified:
trunk/rostests/apitests/advapi32/CMakeLists.txt
trunk/rostests/apitests/advapi32/testlist.c
Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLi…
==============================================================================
--- trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/CMakeLists.txt [iso-8859-1] Mon Oct 13 18:49:09 2014
@@ -1,6 +1,7 @@
list(APPEND SOURCE
CreateService.c
+ DuplicateTokenEx.c
HKEY_CLASSES_ROOT.c
LockDatabase.c
QueryServiceConfig2.c
Added: trunk/rostests/apitests/advapi32/DuplicateTokenEx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/Duplica…
==============================================================================
--- trunk/rostests/apitests/advapi32/DuplicateTokenEx.c (added)
+++ trunk/rostests/apitests/advapi32/DuplicateTokenEx.c [iso-8859-1] Mon Oct 13 18:49:09
2014
@@ -0,0 +1,63 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for DupicateTokenEx
+ * PROGRAMMER: Jérôme Gardou <jerome.gardou(a)reactos.org>
+ */
+
+#include <apitest.h>
+#include <winbase.h>
+#include <rtlfuncs.h>
+
+#define ok_luid_equal(Luid, Expected)
\
+ ok(RtlEqualLuid((Luid), (Expected)), "Got wrong LUID %08lx%08lx, expected
(%08lx%08lx).\n", \
+ (Luid)->HighPart, (Luid)->LowPart, (Expected)->HighPart,
(Expected)->LowPart)
+#define ok_luid_notequal(Luid, Comparand)
\
+ ok(!RtlEqualLuid((Luid), (Comparand)), "LUID is %08lx%08lx and should not
be.\n", \
+ (Luid)->HighPart, (Luid)->LowPart)
+
+START_TEST(DuplicateTokenEx)
+{
+ HANDLE ProcessToken, TokenDup;
+ TOKEN_STATISTICS ProcessTokenStats, TokenDupStats;
+ BOOL Result;
+ DWORD ReturnLength;
+
+ /* Get the current process token */
+ Result = OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_QUERY,
&ProcessToken);
+ ok(Result, "OpenProcessToken failed. GLE: %lu.\n", GetLastError());
+ /* And its statistics */
+ Result = GetTokenInformation(ProcessToken,
+ TokenStatistics,
+ &ProcessTokenStats,
+ sizeof(ProcessTokenStats),
+ &ReturnLength);
+ ok(Result, "GetTokenInformation failed. GLE: %lu.\n", GetLastError());
+ ok_size_t(ReturnLength, sizeof(ProcessTokenStats));
+
+ /* Duplicate it as primary token with the same access rights. */
+ Result = DuplicateTokenEx(ProcessToken, 0, NULL, SecurityImpersonation, TokenPrimary,
&TokenDup);
+ ok(Result, "DuplicateTokenEx failed. GLE: %lu.\n", GetLastError());
+ /* Get the stats */
+ Result = GetTokenInformation(TokenDup,
+ TokenStatistics,
+ &TokenDupStats,
+ sizeof(ProcessTokenStats),
+ &ReturnLength);
+ ok(Result, "GetTokenInformation failed. GLE: %lu.\n", GetLastError());
+ ok_size_t(ReturnLength, sizeof(ProcessTokenStats));
+ /* And test them */
+ ok_luid_notequal(&TokenDupStats.TokenId, &ProcessTokenStats.TokenId);
+ ok_luid_equal(&TokenDupStats.AuthenticationId,
&ProcessTokenStats.AuthenticationId);
+ ok(TokenDupStats.TokenType == TokenPrimary, "Duplicate token type is
%d.\n", TokenDupStats.TokenType);
+ ok(TokenDupStats.ImpersonationLevel == SecurityImpersonation,
+ "Duplicate token impersonation level is %d.\n",
TokenDupStats.ImpersonationLevel);
+ ok_dec(TokenDupStats.DynamicCharged, ProcessTokenStats.DynamicCharged);
+ ok_dec(TokenDupStats.DynamicAvailable, ProcessTokenStats.DynamicAvailable);
+ ok_dec(TokenDupStats.GroupCount, ProcessTokenStats.GroupCount);
+ ok_dec(TokenDupStats.PrivilegeCount, ProcessTokenStats.PrivilegeCount);
+ ok_luid_equal(&TokenDupStats.ModifiedId, &ProcessTokenStats.ModifiedId);
+
+ CloseHandle(ProcessToken);
+ CloseHandle(TokenDup);
+}
Propchange: trunk/rostests/apitests/advapi32/DuplicateTokenEx.c
------------------------------------------------------------------------------
charset = UTF-8
Propchange: trunk/rostests/apitests/advapi32/DuplicateTokenEx.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/rostests/apitests/advapi32/DuplicateTokenEx.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: trunk/rostests/apitests/advapi32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlis…
==============================================================================
--- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Mon Oct 13 18:49:09 2014
@@ -4,6 +4,7 @@
#include <apitest.h>
extern void func_CreateService(void);
+extern void func_DuplicateTokenEx(void);
extern void func_HKEY_CLASSES_ROOT(void);
extern void func_LockDatabase(void);
extern void func_QueryServiceConfig2(void);
@@ -14,6 +15,7 @@
const struct test winetest_testlist[] =
{
{ "CreateService", func_CreateService },
+ { "DuplicateTokenEx", func_DuplicateTokenEx },
{ "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT },
{ "LockDatabase" , func_LockDatabase },
{ "QueryServiceConfig2", func_QueryServiceConfig2 },