Rob Shearman : advapi32: Add tests for EqualSid.
Alexandre Julliard
julliard at winehq.org
Mon Nov 16 11:43:53 CST 2009
Module: wine
Branch: master
Commit: 3498a8817902842d05837422cc376670572e35ef
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3498a8817902842d05837422cc376670572e35ef
Author: Rob Shearman <robertshearman at gmail.com>
Date: Sun Nov 15 16:37:05 2009 +0000
advapi32: Add tests for EqualSid.
---
dlls/advapi32/tests/security.c | 69 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index b71d64f..df4b2e1 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -1228,10 +1228,18 @@ static void test_token_attr(void)
ok(ret, "OpenProcessToken failed with error %d\n", GetLastError());
/* groups */
+ SetLastError(0xdeadbeef);
ret = GetTokenInformation(Token, TokenGroups, NULL, 0, &Size);
+ ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
+ "GetTokenInformation(TokenGroups) %s with error %d\n",
+ ret ? "succeeded" : "failed", GetLastError());
Groups = HeapAlloc(GetProcessHeap(), 0, Size);
+ SetLastError(0xdeadbeef);
ret = GetTokenInformation(Token, TokenGroups, Groups, Size, &Size);
ok(ret, "GetTokenInformation(TokenGroups) failed with error %d\n", GetLastError());
+ ok(GetLastError() == 0xdeadbeef,
+ "GetTokenInformation shouldn't have set last error to %d\n",
+ GetLastError());
trace("TokenGroups:\n");
for (i = 0; i < Groups->GroupCount; i++)
{
@@ -3266,6 +3274,66 @@ todo_wine {
CloseHandle(process_token);
}
+static void test_EqualSid(void)
+{
+ PSID sid1, sid2;
+ BOOL ret;
+ SID_IDENTIFIER_AUTHORITY SIDAuthWorld = { SECURITY_WORLD_SID_AUTHORITY };
+ SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY };
+
+ SetLastError(0xdeadbeef);
+ ret = AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &sid1);
+ ok(ret, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
+ ok(GetLastError() == 0xdeadbeef,
+ "AllocateAndInitializeSid shouldn't have set last error to %d\n",
+ GetLastError());
+
+ ret = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID,
+ 0, 0, 0, 0, 0, 0, 0, &sid2);
+ ok(ret, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = EqualSid(sid1, sid2);
+ ok(!ret, "World and domain admins sids shouldn't have been equal\n");
+ todo_wine
+ ok(GetLastError() == ERROR_SUCCESS,
+ "EqualSid should have set last error to ERROR_SUCCESS instead of %d\n",
+ GetLastError());
+
+ SetLastError(0xdeadbeef);
+ sid2 = FreeSid(sid2);
+ ok(!sid2, "FreeSid should have returned NULL instead of %p\n", sid2);
+ ok(GetLastError() == 0xdeadbeef,
+ "FreeSid shouldn't have set last error to %d\n",
+ GetLastError());
+
+ ret = AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &sid2);
+ ok(ret, "AllocateAndInitializeSid failed with error %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = EqualSid(sid1, sid2);
+ ok(ret, "Same sids should have been equal\n");
+ todo_wine
+ ok(GetLastError() == ERROR_SUCCESS,
+ "EqualSid should have set last error to ERROR_SUCCESS instead of %d\n",
+ GetLastError());
+
+ ((SID *)sid2)->Revision = 2;
+ SetLastError(0xdeadbeef);
+ ret = EqualSid(sid1, sid2);
+ ok(!ret, "EqualSid with invalid sid should have returned FALSE\n");
+ todo_wine
+ ok(GetLastError() == ERROR_SUCCESS,
+ "EqualSid should have set last error to ERROR_SUCCESS instead of %d\n",
+ GetLastError());
+ ((SID *)sid2)->Revision = SID_REVISION;
+
+ FreeSid(sid1);
+ FreeSid(sid2);
+}
+
START_TEST(security)
{
init();
@@ -3297,4 +3365,5 @@ START_TEST(security)
test_GetSecurityInfo();
test_GetSidSubAuthority();
test_CheckTokenMembership();
+ test_EqualSid();
}
More information about the wine-cvs
mailing list