advapi32/tests: Test string alias for common RID in sid strings.

This commit is contained in:
Detlef Riekenberg 2012-11-13 05:31:25 +01:00 committed by Alexandre Julliard
parent f7a6c4c323
commit ef603cbbd9
1 changed files with 58 additions and 62 deletions

View File

@ -129,6 +129,14 @@ static HMODULE hmod;
static int myARGC; static int myARGC;
static char** myARGV; static char** myARGV;
struct strsid_entry
{
const char *str;
DWORD flags;
};
#define STRSID_OK 0
#define STRSID_OPT 1
struct sidRef struct sidRef
{ {
SID_IDENTIFIER_AUTHORITY auth; SID_IDENTIFIER_AUTHORITY auth;
@ -173,29 +181,6 @@ static void init(void)
myARGC = winetest_get_mainargs( &myARGV ); myARGC = winetest_get_mainargs( &myARGV );
} }
static void test_str_sid(const char *str_sid)
{
PSID psid;
char *temp;
if (pConvertStringSidToSidA(str_sid, &psid))
{
if (pConvertSidToStringSidA(psid, &temp))
{
trace(" %s: %s\n", str_sid, temp);
LocalFree(temp);
}
LocalFree(psid);
}
else
{
if (GetLastError() != ERROR_INVALID_SID)
trace(" %s: couldn't be converted, returned %d\n", str_sid, GetLastError());
else
trace(" %s: couldn't be converted\n", str_sid);
}
}
static void test_sid(void) static void test_sid(void)
{ {
struct sidRef refs[] = { struct sidRef refs[] = {
@ -206,6 +191,18 @@ static void test_sid(void)
{ { {0x00,0x00,0x00,0x00,0x00,0x02} }, "S-1-2-1" }, { { {0x00,0x00,0x00,0x00,0x00,0x02} }, "S-1-2-1" },
{ { {0x00,0x00,0x00,0x00,0x00,0x0c} }, "S-1-12-1" }, { { {0x00,0x00,0x00,0x00,0x00,0x0c} }, "S-1-12-1" },
}; };
struct strsid_entry strsid_table[] = {
{"AO", STRSID_OK}, {"RU", STRSID_OK}, {"AN", STRSID_OK}, {"AU", STRSID_OK},
{"BA", STRSID_OK}, {"BG", STRSID_OK}, {"BO", STRSID_OK}, {"BU", STRSID_OK},
{"CA", STRSID_OPT}, {"CG", STRSID_OK}, {"CO", STRSID_OK}, {"DA", STRSID_OPT},
{"DC", STRSID_OPT}, {"DD", STRSID_OPT}, {"DG", STRSID_OPT}, {"DU", STRSID_OPT},
{"EA", STRSID_OPT}, {"ED", STRSID_OK}, {"WD", STRSID_OK}, {"PA", STRSID_OPT},
{"IU", STRSID_OK}, {"LA", STRSID_OK}, {"LG", STRSID_OK}, {"LS", STRSID_OK},
{"SY", STRSID_OK}, {"NU", STRSID_OK}, {"NO", STRSID_OK}, {"NS", STRSID_OK},
{"PO", STRSID_OK}, {"PS", STRSID_OK}, {"PU", STRSID_OK}, {"RS", STRSID_OPT},
{"RD", STRSID_OK}, {"RE", STRSID_OK}, {"RC", STRSID_OK}, {"SA", STRSID_OPT},
{"SO", STRSID_OK}, {"SU", STRSID_OK}};
const char noSubAuthStr[] = "S-1-5"; const char noSubAuthStr[] = "S-1-5";
unsigned int i; unsigned int i;
PSID psid = NULL; PSID psid = NULL;
@ -290,45 +287,44 @@ static void test_sid(void)
LocalFree( psid ); LocalFree( psid );
} }
trace("String SIDs:\n"); /* string constant format not supported before XP */
test_str_sid("AO"); r = pConvertStringSidToSidA(strsid_table[0].str, &psid);
test_str_sid("RU"); if(!r)
test_str_sid("AN"); {
test_str_sid("AU"); win_skip("String constant format not supported\n");
test_str_sid("BA"); return;
test_str_sid("BG"); }
test_str_sid("BO"); LocalFree(psid);
test_str_sid("BU");
test_str_sid("CA"); for(i = 0; i < sizeof(strsid_table) / sizeof(strsid_table[0]); i++)
test_str_sid("CG"); {
test_str_sid("CO"); char *temp;
test_str_sid("DA");
test_str_sid("DC"); SetLastError(0xdeadbeef);
test_str_sid("DD"); r = pConvertStringSidToSidA(strsid_table[i].str, &psid);
test_str_sid("DG");
test_str_sid("DU"); if (!(strsid_table[i].flags & STRSID_OPT))
test_str_sid("EA"); {
test_str_sid("ED"); ok(r, "%s: got %u\n", strsid_table[i].str, GetLastError());
test_str_sid("WD"); }
test_str_sid("PA");
test_str_sid("IU"); if (r)
test_str_sid("LA"); {
test_str_sid("LG"); if ((winetest_debug > 1) && (pConvertSidToStringSidA(psid, &temp)))
test_str_sid("LS"); {
test_str_sid("SY"); trace(" %s: %s\n", strsid_table[i].str, temp);
test_str_sid("NU"); LocalFree(temp);
test_str_sid("NO"); }
test_str_sid("NS"); LocalFree(psid);
test_str_sid("PO"); }
test_str_sid("PS"); else
test_str_sid("PU"); {
test_str_sid("RS"); if (GetLastError() != ERROR_INVALID_SID)
test_str_sid("RD"); trace(" %s: couldn't be converted, returned %d\n", strsid_table[i].str, GetLastError());
test_str_sid("RE"); else
test_str_sid("RC"); trace(" %s: couldn't be converted\n", strsid_table[i].str);
test_str_sid("SA"); }
test_str_sid("SO"); }
test_str_sid("SU");
} }
static void test_trustee(void) static void test_trustee(void)