advapi32/tests

Andreas Rosenberg andreas.rosenberg at apis.de
Thu Apr 9 04:29:26 CDT 2009


Added a test to verify result of LookupAccountSid
-------------- next part --------------
From fd79730c9a080772f663d7d6419b90cec79ea728 Mon Sep 17 00:00:00 2001
From: Andreas.Rosenberg <andreas.rosenberg at apis.de>
Date: Thu, 9 Apr 2009 11:26:51 +0200
Subject: advapi32/tests

  Added a test to verify result of LookupAccountSid
---
 dlls/advapi32/tests/security.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 544b217..ac848bb 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -1410,8 +1410,8 @@ static void test_CreateWellKnownSid(void)
 static void test_LookupAccountSid(void)
 {
     SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
-    CHAR accountA[MAX_PATH], domainA[MAX_PATH];
-    DWORD acc_sizeA, dom_sizeA;
+    CHAR accountA[MAX_PATH], domainA[MAX_PATH], usernameA[MAX_PATH];
+    DWORD acc_sizeA, dom_sizeA, user_sizeA;
     DWORD real_acc_sizeA, real_dom_sizeA;
     WCHAR accountW[MAX_PATH], domainW[MAX_PATH];
     DWORD acc_sizeW, dom_sizeW;
@@ -1419,10 +1419,12 @@ static void test_LookupAccountSid(void)
     PSID pUsersSid = NULL;
     SID_NAME_USE use;
     BOOL ret;
-    DWORD size;
+    DWORD size,cbti = 0;
     MAX_SID  max_sid;
     CHAR *str_sidA;
     int i;
+    HANDLE hToken;
+    PTOKEN_USER ptiUser = NULL;
 
     /* native windows crashes if account size, domain size, or name use is NULL */
 
@@ -1581,6 +1583,26 @@ static void test_LookupAccountSid(void)
 
     FreeSid(pUsersSid);
 
+    /* Test LookupAccountSid with Sid retrieved from token information.
+     This assumes this process is running under the account of the current user.*/
+    ret = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &hToken);
+    ret = GetTokenInformation(hToken, TokenUser, NULL, 0, &cbti);
+    ptiUser = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), 0, cbti);
+    if (GetTokenInformation(hToken, TokenUser, ptiUser, cbti, &cbti))
+    {
+        acc_sizeA = dom_sizeA = MAX_PATH;
+        ret = LookupAccountSidA(NULL, ptiUser->User.Sid, accountA, &acc_sizeA, domainA, &dom_sizeA, &use);
+        ok(ret, "LookupAccountSidA() Expected TRUE, got FALSE\n");
+        user_sizeA = MAX_PATH;
+        ret = GetUserNameA(usernameA , &user_sizeA);
+        ok(ret, "GetUserNameA() Expected TRUE, got FALSE\n");
+        todo_wine
+        {
+            ok(lstrcmpA(usernameA, accountA) == 0, "LookupAccountSidA() Expected account name: %s got: %s\n", usernameA, accountA );
+        }
+    }
+    HeapFree(GetProcessHeap(), 0, ptiUser);
+
     if (pCreateWellKnownSid && pConvertSidToStringSidA)
     {
         trace("Well Known SIDs:\n");
-- 
1.5.2.4



More information about the wine-patches mailing list