advapi32: Add tests for LookupAccountSid.

This commit is contained in:
James Hawkins 2006-07-05 19:53:52 -07:00 committed by Alexandre Julliard
parent 8fb90dea3c
commit ce58c3589c
2 changed files with 35 additions and 6 deletions

View File

@ -1485,15 +1485,15 @@ LookupAccountSidA(
domain,domainSize,domainSize?*domainSize:0,
name_use);
if (accountSize) *accountSize = strlen(ac)+1;
*accountSize = strlen(ac)+1;
if (account && (*accountSize > strlen(ac)))
strcpy(account, ac);
if (domainSize) *domainSize = strlen(dm)+1;
*domainSize = strlen(dm)+1;
if (domain && (*domainSize > strlen(dm)))
strcpy(domain,dm);
if (name_use) *name_use = SidTypeUser;
*name_use = SidTypeUser;
return TRUE;
}
@ -1527,15 +1527,15 @@ LookupAccountSidW(
domain,domainSize,domainSize?*domainSize:0,
name_use);
if (accountSize) *accountSize = strlenW(ac)+1;
*accountSize = strlenW(ac)+1;
if (account && (*accountSize > strlenW(ac)))
strcpyW(account, ac);
if (domainSize) *domainSize = strlenW(dm)+1;
*domainSize = strlenW(dm)+1;
if (domain && (*domainSize > strlenW(dm)))
strcpyW(domain,dm);
if (name_use) *name_use = SidTypeUser;
*name_use = SidTypeUser;
return TRUE;
}

View File

@ -772,6 +772,34 @@ static void test_token_attr(void)
}
}
static void test_LookupAccountSid(void)
{
SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
char account[MAX_PATH], domain[MAX_PATH];
DWORD acc_size, dom_size;
PSID pUsersSid = NULL;
SID_NAME_USE use;
BOOL ret;
/* native windows crashes if account size, domain size, or name use is NULL */
ret = AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_USERS, 0, 0, 0, 0, 0, 0, &pUsersSid);
ok(ret, "AllocateAndInitializeSid failed with error %ld\n", GetLastError());
/* try NULL account */
acc_size = MAX_PATH;
dom_size = MAX_PATH;
ret = LookupAccountSid(NULL, pUsersSid, NULL, &acc_size, domain, &dom_size, &use);
ok(ret, "Expected TRUE, got FALSE\n");
/* try NULL domain */
acc_size = MAX_PATH;
dom_size = MAX_PATH;
ret = LookupAccountSid(NULL, pUsersSid, account, &acc_size, NULL, &dom_size, &use);
ok(ret, "Expected TRUE, got FALSE\n");
}
START_TEST(security)
{
init();
@ -782,4 +810,5 @@ START_TEST(security)
test_FileSecurity();
test_AccessCheck();
test_token_attr();
test_LookupAccountSid();
}