Louis Lenders : advapi32: Add a few tests for GetSidSubAuthority and SetLastError correctly.
Alexandre Julliard
julliard at winehq.org
Mon Jun 29 09:17:49 CDT 2009
Module: wine
Branch: master
Commit: 011c5b8fae7c53bc2a5be2ff4e5337f69b2f7afc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=011c5b8fae7c53bc2a5be2ff4e5337f69b2f7afc
Author: Louis Lenders <xerox_xerox2000 at yahoo.co.uk>
Date: Sat Jun 27 12:48:46 2009 +0200
advapi32: Add a few tests for GetSidSubAuthority and SetLastError correctly.
---
dlls/advapi32/security.c | 2 ++
dlls/advapi32/tests/security.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index 773a839..e1cbb1a 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -1073,6 +1073,7 @@ GetSidIdentifierAuthority( PSID pSid )
PDWORD WINAPI
GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
{
+ SetLastError(ERROR_SUCCESS);
return RtlSubAuthoritySid(pSid, nSubAuthority);
}
@@ -1085,6 +1086,7 @@ GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
PUCHAR WINAPI
GetSidSubAuthorityCount (PSID pSid)
{
+ SetLastError(ERROR_SUCCESS);
return RtlSubAuthorityCountSid(pSid);
}
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index af52a3a..de794de 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -92,6 +92,9 @@ typedef BOOL (WINAPI *fnSetFileSecurityA)(LPCSTR, SECURITY_INFORMATION,
static DWORD (WINAPI *pGetNamedSecurityInfoA)(LPSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION,
PSID*, PSID*, PACL*, PACL*,
PSECURITY_DESCRIPTOR*);
+static PDWORD (WINAPI *pGetSidSubAuthority)(PSID, DWORD);
+static PUCHAR (WINAPI *pGetSidSubAuthorityCount)(PSID);
+static BOOL (WINAPI *pIsValidSid)(PSID);
typedef DWORD (WINAPI *fnRtlAdjustPrivilege)(ULONG,BOOLEAN,BOOLEAN,PBOOLEAN);
typedef BOOL (WINAPI *fnCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*);
typedef BOOL (WINAPI *fnDuplicateTokenEx)(HANDLE,DWORD,LPSECURITY_ATTRIBUTES,
@@ -160,6 +163,9 @@ static void init(void)
pSetFileSecurityA = (fnSetFileSecurityA)GetProcAddress(hmod, "SetFileSecurityA" );
pCreateWellKnownSid = (fnCreateWellKnownSid)GetProcAddress( hmod, "CreateWellKnownSid" );
pGetNamedSecurityInfoA = (void *)GetProcAddress(hmod, "GetNamedSecurityInfoA");
+ pGetSidSubAuthority = (void *)GetProcAddress(hmod, "GetSidSubAuthority");
+ pGetSidSubAuthorityCount = (void *)GetProcAddress(hmod, "GetSidSubAuthorityCount");
+ pIsValidSid = (void *)GetProcAddress(hmod, "IsValidSid");
pMakeSelfRelativeSD = (void *)GetProcAddress(hmod, "MakeSelfRelativeSD");
pSetEntriesInAclW = (void *)GetProcAddress(hmod, "SetEntriesInAclW");
pSetSecurityDescriptorControl = (void *)GetProcAddress(hmod, "SetSecurityDescriptorControl");
@@ -3176,6 +3182,34 @@ static void test_GetSecurityInfo(void)
CloseHandle(obj);
}
+static void test_GetSidSubAuthority(void)
+{
+ PSID psid = NULL;
+
+ if (!pGetSidSubAuthority || !pConvertStringSidToSidA || !pIsValidSid || !pGetSidSubAuthorityCount)
+ {
+ win_skip("Some functions not available\n");
+ return;
+ }
+ /* Note: on windows passing in an invalid index like -1, lets GetSidSubAuthority return 0x05000000 but
+ still GetLastError returns ERROR_SUCCESS then. We don't test these unlikely cornercases here for now */
+ ok(pConvertStringSidToSidA("S-1-5-21-93476-23408-4576",&psid),"ConvertStringSidToSidA failed\n");
+ ok(pIsValidSid(psid),"Sid is not valid\n");
+ SetLastError(0xbebecaca);
+ ok(*pGetSidSubAuthorityCount(psid) == 4,"GetSidSubAuthorityCount gave %d expected 4\n",*pGetSidSubAuthorityCount(psid));
+ ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
+ SetLastError(0xbebecaca);
+ ok(*pGetSidSubAuthority(psid,0) == 21,"GetSidSubAuthority gave %d expected 21",*pGetSidSubAuthority(psid,0));
+ ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
+ SetLastError(0xbebecaca);
+ ok(*pGetSidSubAuthority(psid,1) == 93476,"GetSidSubAuthority gave %d expected 93476",*pGetSidSubAuthority(psid,1));
+ ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
+ SetLastError(0xbebecaca);
+ todo_wine ok(*pGetSidSubAuthority(psid,4) == 0,"GetSidSubAuthority gave %d,expected 0\n",*pGetSidSubAuthority(psid,4));
+ ok(GetLastError() == 0,"GetLastError returned %d instead of 0\n",GetLastError());
+ LocalFree(psid);
+}
+
START_TEST(security)
{
init();
@@ -3205,4 +3239,5 @@ START_TEST(security)
test_PrivateObjectSecurity();
test_acls();
test_GetSecurityInfo();
+ test_GetSidSubAuthority();
}
More information about the wine-cvs
mailing list