advapi32/tests: Make some tests table driven.

This commit is contained in:
Paul Vriens 2009-10-13 13:34:34 +02:00 committed by Alexandre Julliard
parent 33d91a861a
commit 69568dac91
1 changed files with 43 additions and 86 deletions

View File

@ -2659,6 +2659,36 @@ static void test_ConvertStringSecurityDescriptor(void)
BOOL ret; BOOL ret;
PSECURITY_DESCRIPTOR pSD; PSECURITY_DESCRIPTOR pSD;
static const WCHAR Blank[] = { 0 }; static const WCHAR Blank[] = { 0 };
int i;
static const struct
{
const char *sidstring;
DWORD revision;
BOOL ret;
DWORD GLE;
} cssd[] =
{
{ "D:(A;;GA;;;WD)", 0xdeadbeef, FALSE, ERROR_UNKNOWN_REVISION },
/* test ACE string type */
{ "D:(A;;GA;;;WD)", SDDL_REVISION_1, TRUE },
{ "D:(D;;GA;;;WD)", SDDL_REVISION_1, TRUE },
{ "ERROR:(D;;GA;;;WD)", SDDL_REVISION_1, FALSE, ERROR_INVALID_PARAMETER },
/* test ACE string access rights */
{ "D:(A;;GA;;;WD)", SDDL_REVISION_1, TRUE },
{ "D:(A;;GRGWGX;;;WD)", SDDL_REVISION_1, TRUE },
{ "D:(A;;RCSDWDWO;;;WD)", SDDL_REVISION_1, TRUE },
{ "D:(A;;RPWPCCDCLCSWLODTCR;;;WD)", SDDL_REVISION_1, TRUE },
{ "D:(A;;FAFRFWFX;;;WD)", SDDL_REVISION_1, TRUE },
{ "D:(A;;KAKRKWKX;;;WD)", SDDL_REVISION_1, TRUE },
{ "D:(A;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, TRUE },
{ "S:(AU;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, TRUE },
/* test ACE string access right error case */
{ "D:(A;;ROB;;;WD)", SDDL_REVISION_1, FALSE, ERROR_INVALID_ACL },
/* test behaviour with empty strings */
{ "", SDDL_REVISION_1, TRUE },
/* test ACE string SID */
{ "D:(D;;GA;;;S-1-0-0)", SDDL_REVISION_1, TRUE }
};
if (!pConvertStringSecurityDescriptorToSecurityDescriptorA) if (!pConvertStringSecurityDescriptorToSecurityDescriptorA)
{ {
@ -2666,82 +2696,20 @@ static void test_ConvertStringSecurityDescriptor(void)
return; return;
} }
SetLastError(0xdeadbeef); for (i = 0; i < sizeof(cssd)/sizeof(cssd[0]); i++)
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA( {
"D:(A;;GA;;;WD)", 0xdeadbeef, &pSD, NULL); DWORD GLE;
ok(!ret && GetLastError() == ERROR_UNKNOWN_REVISION,
"ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_UNKNOWN_REVISION instead of %d\n",
GetLastError());
/* test ACE string type */ SetLastError(0xdeadbeef);
SetLastError(0xdeadbeef); ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA( cssd[i].sidstring, cssd[i].revision, &pSD, NULL);
"D:(A;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL); GLE = GetLastError();
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError()); ok(ret == cssd[i].ret, "(%02d) Expected %s (%d)\n", i, cssd[i].ret ? "success" : "failure", GLE);
LocalFree(pSD); if (!cssd[i].ret)
ok(GLE == cssd[i].GLE, "(%02d) Expected %d, got %d\n", i, cssd[i].GLE, GLE);
SetLastError(0xdeadbeef); if (ret)
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA( LocalFree(pSD);
"D:(D;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL); }
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"ERROR:(D;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER,
"ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_PARAMETER instead of %d\n",
GetLastError());
/* test ACE string access rights */
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;GA;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;GRGWGX;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;RCSDWDWO;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;RPWPCCDCLCSWLODTCR;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;FAFRFWFX;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;KAKRKWKX;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"S:(AU;;0xFFFFFFFF;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
/* test ACE string access right error case */
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(A;;ROB;;;WD)", SDDL_REVISION_1, &pSD, NULL);
ok(!ret && GetLastError() == ERROR_INVALID_ACL,
"ConvertStringSecurityDescriptorToSecurityDescriptor should have failed with ERROR_INVALID_ACL instead of %d\n",
GetLastError());
/* test behaviour with NULL parameters */ /* test behaviour with NULL parameters */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -2774,23 +2742,12 @@ static void test_ConvertStringSecurityDescriptor(void)
GetLastError()); GetLastError());
/* test behaviour with empty strings */ /* test behaviour with empty strings */
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorW( ret = pConvertStringSecurityDescriptorToSecurityDescriptorW(
Blank, SDDL_REVISION_1, &pSD, NULL); Blank, SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError()); ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
/* test ACE string SID */ /* test ACE string SID */
SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(D;;GA;;;S-1-0-0)", SDDL_REVISION_1, &pSD, NULL);
ok(ret, "ConvertStringSecurityDescriptorToSecurityDescriptor failed with error %d\n", GetLastError());
LocalFree(pSD);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pConvertStringSecurityDescriptorToSecurityDescriptorA( ret = pConvertStringSecurityDescriptorToSecurityDescriptorA(
"D:(D;;GA;;;Nonexistent account)", SDDL_REVISION_1, &pSD, NULL); "D:(D;;GA;;;Nonexistent account)", SDDL_REVISION_1, &pSD, NULL);