Windows 1709 changed the algorithm to be far more restrictive. Treat those results as correct and older versions as broken.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/netapi32/tests/access.c | 378 +++++++++++------------------------ 1 file changed, 112 insertions(+), 266 deletions(-)
diff --git a/dlls/netapi32/tests/access.c b/dlls/netapi32/tests/access.c index a284b65401d..81f9df8fda4 100644 --- a/dlls/netapi32/tests/access.c +++ b/dlls/netapi32/tests/access.c @@ -356,129 +356,43 @@ static void run_localgroupgetinfo_tests(void)
static void test_DavGetHTTPFromUNCPath(void) { - static const WCHAR path[] = - {0}; - static const WCHAR path2[] = - {'c',':','\',0}; - static const WCHAR path3[] = - {'\','\','.','\','c',':',0}; - static const WCHAR path4[] = - {'\','\','.','\','c',':','\',0}; - static const WCHAR path5[] = - {'\','\','.','\','c',':','\','n','o','s','u','c','h','p','a','t','h',0}; - static const WCHAR path6[] = - {'\','\','n','o','s','u','c','h','s','e','r','v','e','r','\','c',':','\',0}; - static const WCHAR path7[] = - {'\','.','\','c',':',0}; - static const WCHAR path8[] = - {'\','\','.','\','c',':','\','\',0}; - static const WCHAR path9[] = - {'\','\','.','@','S','S','L','\','c',':',0}; - static const WCHAR path10[] = - {'\','\','.','@','s','s','l','\','c',':',0}; - static const WCHAR path11[] = - {'\','\','.','@','t','l','s','\','c',':',0}; - static const WCHAR path12[] = - {'\','\','.','@','S','S','L','@','4','4','3','\','c',':',0}; - static const WCHAR path13[] = - {'\','\','.','@','S','S','L','@','8','0','\','c',':',0}; - static const WCHAR path14[] = - {'\','\','.','@','8','0','\','c',':',0}; - static const WCHAR path15[] = - {'\','\','.','@','8','0','8','0','\','c',':',0}; - static const WCHAR path16[] = - {'\','\','\','c',':',0}; - static const WCHAR path17[] = - {'\','\',0}; - static const WCHAR path18[] = - {'/','/','.','/','c',':',0}; - static const WCHAR path19[] = - {'\','\','.','\','c',':','/',0}; - static const WCHAR path20[] = - {'\','\','.','\','c',':','\','\','\',0}; - static const WCHAR path21[] = - {'\','\','.','\','\','c',':',0}; - static const WCHAR path22[] = - {'\','\','.','\','c',':','d','i','r',0}; - static const WCHAR path23[] = - {'\','\','.',0}; - static const WCHAR path24[] = - {'\','\','.','\','d','i','r',0}; - static const WCHAR path25[] = - {'\','\','.','\','\',0}; - static const WCHAR path26[] = - {'\','\','.','\','c',':','d','i','r','/',0}; - static const WCHAR path27[] = - {'\','\','.','/','c',':',0}; - static const WCHAR path28[] = - {'\','\','.','@','8','0','@','S','S','L','\','c',':',0}; - static const WCHAR result[] = - {'h','t','t','p',':','/','/','.','/','c',':',0}; - static const WCHAR result2[] = - {'h','t','t','p',':','/','/','.','/','c',':','/','n','o','s','u','c','h','p','a','t','h',0}; - static const WCHAR result3[] = - {'h','t','t','p',':','/','/','n','o','s','u','c','h','s','e','r','v','e','r','/','c',':',0}; - static const WCHAR result4[] = - {'h','t','t','p',':','/','/','.','/','c',':','/',0}; - static const WCHAR result5[] = - {'h','t','t','p','s',':','/','/','.','/','c',':',0}; - static const WCHAR result6[] = - {'h','t','t','p','s',':','/','/','.',':','8','0','/','c',':',0}; - static const WCHAR result7[] = - {'h','t','t','p',':','/','/','.',':','8','0','8','0','/','c',':',0}; - static const WCHAR result8[] = - {'h','t','t','p',':','/','/','/','c',':',0}; - static const WCHAR result9[] = - {'h','t','t','p',':','/','/','.','/','c',':','/','/',0}; - static const WCHAR result10[] = - {'h','t','t','p',':','/','/','.','/','/','c',':',0}; - static const WCHAR result11[] = - {'h','t','t','p',':','/','/','.','/','c',':','d','i','r',0}; - static const WCHAR result12[] = - {'h','t','t','p',':','/','/','.',0}; - static const WCHAR result13[] = - {'h','t','t','p',':','/','/','.','/','d','i','r',0}; - static const WCHAR result14[] = - {'h','t','t','p',':','/','/','.','/',0}; static const struct { const WCHAR *path; - DWORD size; - DWORD ret; + DWORD ret; const WCHAR *ret_path; - DWORD ret_size; - int todo; + DWORD broken_ret; /* < Win10 1709 */ + BOOL todo; } tests[] = { - { path, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path2, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path3, MAX_PATH, ERROR_SUCCESS, result, 12 }, - { path4, MAX_PATH, ERROR_SUCCESS, result, 12 }, - { path5, MAX_PATH, ERROR_SUCCESS, result2, 23 }, - { path6, MAX_PATH, ERROR_SUCCESS, result3, 23 }, - { path7, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path8, MAX_PATH, ERROR_SUCCESS, result4, 13 }, - { path9, MAX_PATH, ERROR_SUCCESS, result5, 13 }, - { path10, MAX_PATH, ERROR_SUCCESS, result5, 13 }, - { path11, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path12, MAX_PATH, ERROR_SUCCESS, result5, 13 }, - { path13, MAX_PATH, ERROR_SUCCESS, result6, 16 }, - { path14, MAX_PATH, ERROR_SUCCESS, result, 12 }, - { path15, MAX_PATH, ERROR_SUCCESS, result7, 17 }, - { path16, MAX_PATH, ERROR_SUCCESS, result8, 11 }, - { path17, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path18, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path19, MAX_PATH, ERROR_SUCCESS, result, 12 }, - { path20, MAX_PATH, ERROR_SUCCESS, result9, 14 }, - { path21, MAX_PATH, ERROR_SUCCESS, result10, 13 }, - { path22, MAX_PATH, ERROR_SUCCESS, result11, 15 }, - { path23, MAX_PATH, ERROR_SUCCESS, result12, 9 }, - { path24, MAX_PATH, ERROR_SUCCESS, result13, 13 }, - { path25, MAX_PATH, ERROR_SUCCESS, result14, 10, 1 }, - { path26, MAX_PATH, ERROR_SUCCESS, result11, 15 }, - { path27, MAX_PATH, ERROR_SUCCESS, result, 12 }, - { path28, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, + {L"", ERROR_BAD_NET_NAME, NULL, ERROR_INVALID_PARAMETER, TRUE}, + {L"c:\", ERROR_BAD_NET_NAME, NULL, ERROR_INVALID_PARAMETER, TRUE}, + {L"\\", ERROR_BAD_NET_NAME, NULL, ERROR_INVALID_PARAMETER, TRUE}, + {L"\a\b", ERROR_BAD_NET_NAME, NULL, ERROR_INVALID_PARAMETER, TRUE}, + {L"\\a", ERROR_SUCCESS, L"http://a%22%7D, + {L"\\a\", ERROR_SUCCESS, L"http://a%22%7D, + {L"\\a\b", ERROR_SUCCESS, L"http://a/b%22%7D, + {L"\\a\b\", ERROR_SUCCESS, L"http://a/b%22%7D, + {L"\\a\b\c", ERROR_SUCCESS, L"http://a/b/c%22%7D, + {L"\\a@SSL\b", ERROR_SUCCESS, L"https://a/b%22%7D, + {L"\\a@ssl\b", ERROR_SUCCESS, L"https://a/b%22%7D, + {L"\\a@tls\b", ERROR_INVALID_PARAMETER}, + {L"\\a@SSL@443\b", ERROR_SUCCESS, L"https://a/b%22%7D, + {L"\\a@SSL@80\b", ERROR_SUCCESS, L"https://a:80/b%22%7D, + {L"\\a@80@SSL\b", ERROR_INVALID_PARAMETER}, + {L"\\a@80\b", ERROR_SUCCESS, L"http://a/b%22%7D, + {L"\\a@8080\b", ERROR_SUCCESS, L"http://a:8080/b%22%7D, + {L"\\a\b/", ERROR_SUCCESS, L"http://a/b%22%7D, + {L"\\a/b", ERROR_SUCCESS, L"http://a/b%22%7D, + {L"\\a.\b", ERROR_SUCCESS, L"http://a./b%22%7D, + {L"\\.a\b", ERROR_SUCCESS, L"http://.a/b%22%7D, + {L"//a/b", ERROR_SUCCESS, L"http://a/b", ERROR_INVALID_PARAMETER, TRUE}, + {L"\\a\\", ERROR_BAD_NET_NAME, NULL, ERROR_SUCCESS, TRUE}, + {L"\\\a\", ERROR_BAD_NET_NAME, NULL, ERROR_SUCCESS, TRUE}, + {L"\\a\b\\", ERROR_BAD_NET_NAME, NULL, ERROR_SUCCESS, TRUE}, + {L"\\.\a", ERROR_BAD_NET_NAME, NULL, ERROR_SUCCESS, TRUE}, + {L"\\a\b:", ERROR_BAD_NET_NAME, NULL, ERROR_SUCCESS, TRUE}, }; WCHAR buf[MAX_PATH]; DWORD i, ret, size; @@ -489,162 +403,89 @@ static void test_DavGetHTTPFromUNCPath(void) return; }
- if (0) { /* crash */ - ret = pDavGetHTTPFromUNCPath( NULL, NULL, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - } + if (0) /* crashes on Windows */ + { + ret = pDavGetHTTPFromUNCPath(NULL, NULL, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
- ret = pDavGetHTTPFromUNCPath( path, buf, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + size = 0; + ret = pDavGetHTTPFromUNCPath(L"", buf, &size); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
- size = 0; - ret = pDavGetHTTPFromUNCPath( path, NULL, &size ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + ret = pDavGetHTTPFromUNCPath(L"\\a\b", buf, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret); + }
- if (0) { /* crash */ - buf[0] = 0; - size = 0; - ret = pDavGetHTTPFromUNCPath( path, buf, &size ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + ret = pDavGetHTTPFromUNCPath(L"", buf, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
- ret = pDavGetHTTPFromUNCPath( path3, buf, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - } + size = 0; + ret = pDavGetHTTPFromUNCPath(L"", NULL, &size); + ok(ret == ERROR_INVALID_PARAMETER || ret == ERROR_BAD_NET_NAME /* Win10 1709+ */, "got %u\n", ret);
size = 0; - ret = pDavGetHTTPFromUNCPath( path3, NULL, &size ); - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); + ret = pDavGetHTTPFromUNCPath(L"\\a\b", NULL, &size); + ok(ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret);
buf[0] = 0; size = 0; - ret = pDavGetHTTPFromUNCPath( path3, buf, &size ); - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); - ok( size == 12, "got %u\n", size ); + ret = pDavGetHTTPFromUNCPath(L"\\a\b", buf, &size); + ok(ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret); + ok(size == 11, "got %u\n", size);
for (i = 0; i < ARRAY_SIZE(tests); i++) { buf[0] = 0; - size = tests[i].size; + size = ARRAY_SIZE(buf); ret = pDavGetHTTPFromUNCPath( tests[i].path, buf, &size ); - if (tests[i].todo) + todo_wine_if (tests[i].todo) + ok(ret == tests[i].ret || broken(ret == tests[i].broken_ret), + "%u: expected %u got %u\n", i, tests[i].ret, ret); + if (!ret) { - ok( ret == tests[i].ret, "%u: expected %u got %u\n", i, tests[i].ret, ret ); - todo_wine { if (tests[i].ret_path) - { - ok( !lstrcmpW( buf, tests[i].ret_path ), "%u: expected %s got %s\n", - i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf) ); - } - ok( size == tests[i].ret_size, "%u: expected %u got %u\n", i, tests[i].ret_size, size ); - } + ok(!wcscmp(buf, tests[i].ret_path), "%u: expected %s got %s\n", + i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf)); + ok(size == wcslen(buf) + 1, "%u: expected %u got %u\n", i, wcslen(buf) + 1, size); } else - { - ok( ret == tests[i].ret, "%u: expected %u got %u\n", i, tests[i].ret, ret ); - if (tests[i].ret_path) - { - ok( !lstrcmpW( buf, tests[i].ret_path ), "%u: expected %s got %s\n", - i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf) ); - } - ok( size == tests[i].ret_size, "%u: expected %u got %u\n", i, tests[i].ret_size, size ); - } + ok(size == ARRAY_SIZE(buf), "%u: wrong size %u\n", i, size); } }
+ static void test_DavGetUNCFromHTTPPath(void) { - static const WCHAR path[] = - {0}; - static const WCHAR path2[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h',0}; - static const WCHAR path3[] = - {'h','t','t','p','s',':','/','/','h','o','s','t','/','p','a','t','h',0}; - static const WCHAR path4[] = - {'\','\','s','e','r','v','e','r',0}; - static const WCHAR path5[] = - {'\','\','s','e','r','v','e','r','\','p','a','t','h',0}; - static const WCHAR path6[] = - {'\','\','h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h',0}; - static const WCHAR path7[] = - {'h','t','t','p',':','/','/',0}; - static const WCHAR path8[] = - {'h','t','t','p',':',0}; - static const WCHAR path9[] = - {'h','t','t','p',0}; - static const WCHAR path10[] = - {'h','t','t','p',':','s','e','r','v','e','r',0}; - static const WCHAR path11[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','8','0',0}; - static const WCHAR path12[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','8','1',0}; - static const WCHAR path13[] = - {'h','t','t','p','s',':','/','/','s','e','r','v','e','r',':','8','0',0}; - static const WCHAR path14[] = - {'H','T','T','P',':','/','/','s','e','r','v','e','r','/','p','a','t','h',0}; - static const WCHAR path15[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','6','5','5','3','7',0}; - static const WCHAR path16[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h','/',0}; - static const WCHAR path17[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h','/','/',0}; - static const WCHAR path18[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','/','p','a','t','h',0}; - static const WCHAR path19[] = - {'h','t','t','p',':','/','/','s','e','r','v','e','r',0}; - static const WCHAR path20[] = - {'h','t','t','p','s',':','/','/','s','e','r','v','e','r',':','4','4','3',0}; - static const WCHAR path21[] = - {'h','t','t','p','s',':','/','/','s','e','r','v','e','r',':','8','0',0}; - static const WCHAR result[] = - {'\','\','s','e','r','v','e','r','\','D','a','v','W','W','W','R','o','o','t','\','p','a','t','h',0}; - static const WCHAR result2[] = - {'\','\','h','o','s','t','@','S','S','L','\','D','a','v','W','W','W','R','o','o','t','\', - 'p','a','t','h',0}; - static const WCHAR result3[] = - {'\','\','s','e','r','v','e','r','\','D','a','v','W','W','W','R','o','o','t',0}; - static const WCHAR result4[] = - {'\','\','s','e','r','v','e','r','@','8','1','\','D','a','v','W','W','W','R','o','o','t',0}; - static const WCHAR result5[] = - {'\','\','s','e','r','v','e','r','@','S','S','L','@','8','0','\','D','a','v','W','W','W','R','o','o','t',0}; - static const WCHAR result6[] = - {'\','\','s','e','r','v','e','r','@','6','5','5','3','7','\','D','a','v','W','W','W','R','o','o','t',0}; - static const WCHAR result7[] = - {'\','\','s','e','r','v','e','r','@','\','D','a','v','W','W','W','R','o','o','t','\','p','a','t','h',0}; - static const WCHAR result8[] = - {'\','\','s','e','r','v','e','r','@','S','S','L','\','D','a','v','W','W','W','R','o','o','t',0}; - static const WCHAR result9[] = - {'\','\','s','e','r','v','e','r','@','S','S','L','@','8','0','\','D','a','v','W','W','W','R','o','o','t',0}; static const struct { const WCHAR *path; - DWORD size; - DWORD ret; + DWORD ret; const WCHAR *ret_path; - DWORD ret_size; + DWORD broken_ret; /* < Win10 1709 */ + BOOL todo; } tests[] = { - { path, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path2, MAX_PATH, ERROR_SUCCESS, result, 25 }, - { path3, MAX_PATH, ERROR_SUCCESS, result2, 27 }, - { path4, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path5, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path6, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path7, MAX_PATH, ERROR_BAD_NET_NAME, NULL, MAX_PATH }, - { path8, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path9, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path10, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, - { path11, MAX_PATH, ERROR_SUCCESS, result3, 20 }, - { path12, MAX_PATH, ERROR_SUCCESS, result4, 23 }, - { path13, MAX_PATH, ERROR_SUCCESS, result5, 27 }, - { path14, MAX_PATH, ERROR_SUCCESS, result, 25 }, - { path15, MAX_PATH, ERROR_SUCCESS, result6, 26 }, - { path16, MAX_PATH, ERROR_SUCCESS, result, 25 }, - { path17, MAX_PATH, ERROR_BAD_NET_NAME, NULL, MAX_PATH }, - { path18, MAX_PATH, ERROR_SUCCESS, result7, 26 }, - { path19, MAX_PATH, ERROR_SUCCESS, result3, 20 }, - { path20, MAX_PATH, ERROR_SUCCESS, result8, 24 }, - { path21, MAX_PATH, ERROR_SUCCESS, result9, 27 }, + {L"", ERROR_INVALID_PARAMETER}, + {L"http://server/path", ERROR_SUCCESS, L"\\server\DavWWWRoot\path"}, + {L"https://host/path", ERROR_SUCCESS, L"\\host@SSL\DavWWWRoot\path"}, + {L"\\server", ERROR_INVALID_PARAMETER}, + {L"\\server\path", ERROR_INVALID_PARAMETER}, + {L"\\http://server/path", ERROR_INVALID_PARAMETER}, + {L"http://", ERROR_BAD_NETPATH, NULL, ERROR_BAD_NET_NAME, TRUE}, + {L"http:", ERROR_BAD_NET_NAME, NULL, ERROR_INVALID_PARAMETER, TRUE}, + {L"http", ERROR_INVALID_PARAMETER}, + {L"http:server", ERROR_BAD_NET_NAME, NULL, ERROR_INVALID_PARAMETER, TRUE}, + {L"http://server:80", ERROR_SUCCESS, L"\\server\DavWWWRoot"}, + {L"http://server:81", ERROR_SUCCESS, L"\\server@81\DavWWWRoot"}, + {L"https://server:80", ERROR_SUCCESS, L"\\server@SSL@80\DavWWWRoot"}, + {L"HTTP://server/path", ERROR_SUCCESS, L"\\server\DavWWWRoot\path"}, + {L"http://server:65537", ERROR_BAD_NETPATH, NULL, ERROR_SUCCESS, TRUE}, + {L"http://server/path/", ERROR_SUCCESS, L"\\server\DavWWWRoot\path"}, + {L"http://server/path//", ERROR_SUCCESS, L"\\server\DavWWWRoot\path", ERROR_BAD_NET_NAME, TRUE}, + {L"http://server:/path", ERROR_BAD_NETPATH, NULL, ERROR_SUCCESS, TRUE}, + {L"http://server", ERROR_SUCCESS, L"\\server\DavWWWRoot"}, + {L"https://server:443", ERROR_SUCCESS, L"\\server@SSL\DavWWWRoot"}, }; WCHAR buf[MAX_PATH]; DWORD i, ret, size; @@ -655,52 +496,57 @@ static void test_DavGetUNCFromHTTPPath(void) return; }
- if (0) { /* crash */ - ret = pDavGetUNCFromHTTPPath( NULL, NULL, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + if (0) /* crashes on Windows */ + { + ret = pDavGetUNCFromHTTPPath(NULL, NULL, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret); + + ret = pDavGetUNCFromHTTPPath(L"http://server/path", buf, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret); } - ret = pDavGetUNCFromHTTPPath( path, buf, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + + ret = pDavGetUNCFromHTTPPath(L"", buf, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
size = 0; - ret = pDavGetUNCFromHTTPPath( path, NULL, &size ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + ret = pDavGetUNCFromHTTPPath(L"", NULL, &size); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
buf[0] = 0; size = 0; - ret = pDavGetUNCFromHTTPPath( path, buf, &size ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); + ret = pDavGetUNCFromHTTPPath(L"", buf, &size); + ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
- if (0) { /* crash */ - ret = pDavGetUNCFromHTTPPath( path2, buf, NULL ); - ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret ); - } size = 0; - ret = pDavGetUNCFromHTTPPath( path2, NULL, &size ); + ret = pDavGetUNCFromHTTPPath(L"http://server/path", NULL, &size); ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
buf[0] = 0; size = 0; - ret = pDavGetUNCFromHTTPPath( path2, buf, &size ); - ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret ); - ok( size == 25, "got %u\n", size ); + ret = pDavGetUNCFromHTTPPath(L"http://server/path", buf, &size); + ok(ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret); + ok(size == 25, "got %u\n", size);
for (i = 0; i < ARRAY_SIZE(tests); i++) { buf[0] = 0; - size = tests[i].size; + size = ARRAY_SIZE(buf); ret = pDavGetUNCFromHTTPPath( tests[i].path, buf, &size ); - ok( ret == tests[i].ret, "%u: expected %u got %u\n", i, tests[i].ret, ret ); - if (tests[i].ret_path) + todo_wine_if (tests[i].todo) + ok(ret == tests[i].ret || broken(ret == tests[i].broken_ret), + "%u: expected %u got %u\n", i, tests[i].ret, ret); + if (!ret) { - ok( !lstrcmpW( buf, tests[i].ret_path ), "%u: expected %s got %s\n", - i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf) ); + if (tests[i].ret_path) + ok(!wcscmp(buf, tests[i].ret_path), "%u: expected %s got %s\n", + i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf)); + ok(size == wcslen(buf) + 1, "%u: expected %u got %u\n", i, wcslen(buf) + 1, size); } - ok( size == tests[i].ret_size, "%u: expected %u got %u\n", i, tests[i].ret_size, size ); + else + ok(size == ARRAY_SIZE(buf), "%u: wrong size %u\n", i, size); } }
- START_TEST(access) { HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/netapi32/tests/access.c | 79 ++++++++++++++---------------------- dlls/netapi32/tests/wksta.c | 27 ++++++------ 2 files changed, 44 insertions(+), 62 deletions(-)
diff --git a/dlls/netapi32/tests/access.c b/dlls/netapi32/tests/access.c index 81f9df8fda4..bae56103e6d 100644 --- a/dlls/netapi32/tests/access.c +++ b/dlls/netapi32/tests/access.c @@ -32,29 +32,13 @@ static WCHAR user_name[UNLEN + 1]; static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
-static const WCHAR sNonexistentUser[] = {'N','o','n','e','x','i','s','t','e','n','t',' ', - 'U','s','e','r',0}; -static WCHAR sTooLongName[] = {'T','h','i','s',' ','i','s',' ','a',' ','b','a','d', - ' ','u','s','e','r','n','a','m','e',0}; -static WCHAR sTooLongPassword[] = {'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h', - 'a', 0}; - -static WCHAR sTestUserName[] = {'t', 'e', 's', 't', 'u', 's', 'e', 'r', 0}; -static WCHAR sTestUserOldPass[] = {'O', 'l', 'd', 'P', 'a', 's', 's', 'W', '0', 'r', 'd', 'S', 'e', 't', '!', '~', 0}; -static const WCHAR sBadNetPath[] = {'\','\','B','a',' ',' ','p','a','t','h',0}; -static const WCHAR sInvalidName[] = {'\',0}; -static const WCHAR sInvalidName2[] = {'\','\',0}; -static const WCHAR sEmptyStr[] = { 0 }; +static WCHAR sTooLongName[] = L"This is a bad username"; +static WCHAR sTooLongPassword[] = L"abcdefghabcdefghabcdefghabcdefghabcdefgh" + "abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh" + "abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh" + "abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgha"; + +static WCHAR sTestUserOldPass[] = L"OldPassW0rdSet!~";
static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID); static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD); @@ -93,7 +77,7 @@ static NET_API_STATUS create_test_user(void) { USER_INFO_1 usri;
- usri.usri1_name = sTestUserName; + usri.usri1_name = (WCHAR *)L"testuser"; usri.usri1_password = sTestUserOldPass; usri.usri1_priv = USER_PRIV_USER; usri.usri1_home_dir = NULL; @@ -106,7 +90,7 @@ static NET_API_STATUS create_test_user(void)
static NET_API_STATUS delete_test_user(void) { - return pNetUserDel(NULL, sTestUserName); + return pNetUserDel(NULL, L"testuser"); }
static void run_usergetinfo_tests(void) @@ -123,24 +107,23 @@ static void run_usergetinfo_tests(void) }
/* Level 0 */ - rc=pNetUserGetInfo(NULL, sTestUserName, 0, (LPBYTE *)&ui0); + rc = pNetUserGetInfo(NULL, L"testuser", 0, (LPBYTE *)&ui0); ok(rc == NERR_Success, "NetUserGetInfo level 0 failed: 0x%08x.\n", rc); - ok(!lstrcmpW(sTestUserName, ui0->usri0_name),"Username mismatch for level 0.\n"); + ok(!wcscmp(L"testuser", ui0->usri0_name), "Got level 0 name %s.\n", debugstr_w(ui0->usri0_name)); pNetApiBufferSize(ui0, &dwSize); - ok(dwSize >= (sizeof(USER_INFO_0) + - (lstrlenW(ui0->usri0_name) + 1) * sizeof(WCHAR)), + ok(dwSize >= (sizeof(USER_INFO_0) + (wcslen(ui0->usri0_name) + 1) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
/* Level 10 */ - rc=pNetUserGetInfo(NULL, sTestUserName, 10, (LPBYTE *)&ui10); + rc = pNetUserGetInfo(NULL, L"testuser", 10, (LPBYTE *)&ui10); ok(rc == NERR_Success, "NetUserGetInfo level 10 failed: 0x%08x.\n", rc); - ok(!lstrcmpW(sTestUserName, ui10->usri10_name), "Username mismatch for level 10.\n"); + ok(!wcscmp(L"testuser", ui10->usri10_name), "Got level 10 name %s.\n", debugstr_w(ui10->usri10_name)); pNetApiBufferSize(ui10, &dwSize); ok(dwSize >= (sizeof(USER_INFO_10) + - (lstrlenW(ui10->usri10_name) + 1 + - lstrlenW(ui10->usri10_comment) + 1 + - lstrlenW(ui10->usri10_usr_comment) + 1 + - lstrlenW(ui10->usri10_full_name) + 1) * sizeof(WCHAR)), + (wcslen(ui10->usri10_name) + 1 + + wcslen(ui10->usri10_comment) + 1 + + wcslen(ui10->usri10_usr_comment) + 1 + + wcslen(ui10->usri10_full_name) + 1) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
pNetApiBufferFree(ui0); @@ -152,13 +135,13 @@ static void run_usergetinfo_tests(void) pNetApiBufferFree(ui0);
/* errors handling */ - rc=pNetUserGetInfo(NULL, sTestUserName, 10000, (LPBYTE *)&ui0); + rc = pNetUserGetInfo(NULL, L"testuser", 10000, (LPBYTE *)&ui0); ok(rc == ERROR_INVALID_LEVEL,"Invalid Level: rc=%d\n",rc); - rc=pNetUserGetInfo(NULL, sNonexistentUser, 0, (LPBYTE *)&ui0); + rc = pNetUserGetInfo(NULL, L"Nonexistent User", 0, (LPBYTE *)&ui0); ok(rc == NERR_UserNotFound,"Invalid User Name: rc=%d\n",rc); todo_wine { /* FIXME - Currently Wine can't verify whether the network path is good or bad */ - rc=pNetUserGetInfo(sBadNetPath, sTestUserName, 0, (LPBYTE *)&ui0); + rc = pNetUserGetInfo(L"\\Ba path", L"testuser", 0, (LPBYTE *)&ui0); ok(rc == ERROR_BAD_NETPATH || rc == ERROR_NETWORK_UNREACHABLE || rc == RPC_S_SERVER_UNAVAILABLE || @@ -166,12 +149,12 @@ static void run_usergetinfo_tests(void) rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */ "Bad Network Path: rc=%d\n",rc); } - rc=pNetUserGetInfo(sEmptyStr, sTestUserName, 0, (LPBYTE *)&ui0); + rc = pNetUserGetInfo(L"", L"testuser", 0, (LPBYTE *)&ui0); ok(rc == ERROR_BAD_NETPATH || rc == NERR_Success, "Bad Network Path: rc=%d\n",rc); - rc=pNetUserGetInfo(sInvalidName, sTestUserName, 0, (LPBYTE *)&ui0); + rc = pNetUserGetInfo(L"\", L"testuser", 0, (LPBYTE *)&ui0); ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc); - rc=pNetUserGetInfo(sInvalidName2, sTestUserName, 0, (LPBYTE *)&ui0); + rc = pNetUserGetInfo(L"\\", L"testuser", 0, (LPBYTE *)&ui0); ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
if(delete_test_user() != NERR_Success) @@ -269,7 +252,7 @@ static void run_userhandling_tests(void) broken(ret == NERR_PasswordTooShort), /* NT4 */ "Adding user with too long username returned 0x%08x\n", ret);
- usri.usri1_name = sTestUserName; + usri.usri1_name = (WCHAR *)L"testuser"; usri.usri1_password = sTooLongPassword;
ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL); @@ -286,7 +269,7 @@ static void run_userhandling_tests(void) ok(ret == NERR_BadUsername || ret == NERR_PasswordTooShort, "Adding user with too long username/password returned 0x%08x\n", ret);
- usri.usri1_name = sTestUserName; + usri.usri1_name = (WCHAR *)L"testuser"; usri.usri1_password = sTestUserOldPass;
ret = pNetUserAdd(NULL, 5, (LPBYTE)&usri, NULL); @@ -318,23 +301,22 @@ static void run_userhandling_tests(void) * So let's not test NetUserChangePassword for now. */
- ret = pNetUserDel(NULL, sTestUserName); + ret = pNetUserDel(NULL, L"testuser"); ok(ret == NERR_Success, "Deleting the user failed.\n");
- ret = pNetUserDel(NULL, sTestUserName); + ret = pNetUserDel(NULL, L"testuser"); ok(ret == NERR_UserNotFound, "Deleting a nonexistent user returned 0x%08x\n",ret); }
static void run_localgroupgetinfo_tests(void) { NET_API_STATUS status; - static const WCHAR admins[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r','s',0}; PLOCALGROUP_INFO_1 lgi = NULL; PLOCALGROUP_MEMBERS_INFO_3 buffer = NULL; DWORD entries_read = 0, total_entries =0; int i;
- status = pNetLocalGroupGetInfo(NULL, admins, 1, (LPBYTE *)&lgi); + status = pNetLocalGroupGetInfo(NULL, L"Administrators", 1, (BYTE **)&lgi); ok(status == NERR_Success || broken(status == NERR_GroupNotFound), "NetLocalGroupGetInfo unexpectedly returned %d\n", status); if (status != NERR_Success) return; @@ -344,7 +326,8 @@ static void run_localgroupgetinfo_tests(void)
pNetApiBufferFree(lgi);
- status = pNetLocalGroupGetMembers(NULL, admins, 3, (LPBYTE *)&buffer, MAX_PREFERRED_LENGTH, &entries_read, &total_entries, NULL); + status = pNetLocalGroupGetMembers(NULL, L"Administrators", 3, (BYTE **)&buffer, + MAX_PREFERRED_LENGTH, &entries_read, &total_entries, NULL); ok(status == NERR_Success, "NetLocalGroupGetMembers unexpectedly returned %d\n", status); ok(entries_read > 0 && total_entries > 0, "Amount of entries is unexpectedly 0\n");
diff --git a/dlls/netapi32/tests/wksta.c b/dlls/netapi32/tests/wksta.c index ba4a7f9aa09..709ed776950 100644 --- a/dlls/netapi32/tests/wksta.c +++ b/dlls/netapi32/tests/wksta.c @@ -69,7 +69,7 @@ static void run_get_comp_name_tests(void) LPWSTR ws = NULL;
ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved\n"); - ok(!lstrcmpW(computer_name, ws), "This is really computer name\n"); + ok(!wcscmp(computer_name, ws), "Expected %s, got %s.\n", debugstr_w(computer_name), debugstr_w(ws)); pNetApiBufferFree(ws); }
@@ -98,33 +98,32 @@ static void run_wkstausergetinfo_tests(void) return; }
- ok(!lstrcmpW(user_name, ui0->wkui0_username), "This is really user name\n"); + ok(!wcscmp(user_name, ui0->wkui0_username), "Expected username %s, got %s.\n", + debugstr_w(user_name), debugstr_w(ui0->wkui0_username)); pNetApiBufferSize(ui0, &dwSize); - ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) + - lstrlenW(ui0->wkui0_username) * sizeof(WCHAR)), + ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) + wcslen(ui0->wkui0_username) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
/* Level 1 */ ok(pNetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success, "NetWkstaUserGetInfo is successful\n"); - ok(lstrcmpW(ui1->wkui1_username, ui0->wkui0_username) == 0, - "the same name as returned for level 0\n"); + ok(!wcscmp(user_name, ui1->wkui1_username), "Expected username %s, got %s.\n", + debugstr_w(user_name), debugstr_w(ui1->wkui1_username)); pNetApiBufferSize(ui1, &dwSize); ok(dwSize >= (sizeof(WKSTA_USER_INFO_1) + - (lstrlenW(ui1->wkui1_username) + - lstrlenW(ui1->wkui1_logon_domain) + - lstrlenW(ui1->wkui1_oth_domains) + - lstrlenW(ui1->wkui1_logon_server)) * sizeof(WCHAR)), + (wcslen(ui1->wkui1_username) + + wcslen(ui1->wkui1_logon_domain) + + wcslen(ui1->wkui1_oth_domains) + + wcslen(ui1->wkui1_logon_server)) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
/* Level 1101 */ ok(pNetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success, "NetWkstaUserGetInfo is successful\n"); - ok(lstrcmpW(ui1101->wkui1101_oth_domains, ui1->wkui1_oth_domains) == 0, - "the same oth_domains as returned for level 1\n"); + ok(!wcscmp(ui1101->wkui1101_oth_domains, ui1->wkui1_oth_domains), "Expected %s, got %s.\n", + debugstr_w(ui1->wkui1_oth_domains), debugstr_w(ui1101->wkui1101_oth_domains)); pNetApiBufferSize(ui1101, &dwSize); - ok(dwSize >= (sizeof(WKSTA_USER_INFO_1101) + - lstrlenW(ui1101->wkui1101_oth_domains) * sizeof(WCHAR)), + ok(dwSize >= (sizeof(WKSTA_USER_INFO_1101) + wcslen(ui1101->wkui1101_oth_domains) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
pNetApiBufferFree(ui0);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/netapi32/tests/Makefile.in | 2 +- dlls/netapi32/tests/access.c | 155 ++++++++++---------------------- dlls/netapi32/tests/apibuf.c | 50 ++++------- dlls/netapi32/tests/ds.c | 39 +++----- dlls/netapi32/tests/wksta.c | 128 ++++++++------------------ 5 files changed, 117 insertions(+), 257 deletions(-)
diff --git a/dlls/netapi32/tests/Makefile.in b/dlls/netapi32/tests/Makefile.in index 2b87bce0acc..3ca81e6e2bc 100644 --- a/dlls/netapi32/tests/Makefile.in +++ b/dlls/netapi32/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = netapi32.dll -IMPORTS = advapi32 +IMPORTS = advapi32 netapi32
C_SRCS = \ access.c \ diff --git a/dlls/netapi32/tests/access.c b/dlls/netapi32/tests/access.c index bae56103e6d..d2cef225f09 100644 --- a/dlls/netapi32/tests/access.c +++ b/dlls/netapi32/tests/access.c @@ -40,39 +40,9 @@ static WCHAR sTooLongPassword[] = L"abcdefghabcdefghabcdefghabcdefghabcdefgh"
static WCHAR sTestUserOldPass[] = L"OldPassW0rdSet!~";
-static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID); -static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD); -static NET_API_STATUS (WINAPI *pNetQueryDisplayInformation)(LPWSTR,DWORD,DWORD,DWORD,DWORD,LPDWORD,PVOID*); -static NET_API_STATUS (WINAPI *pNetUserGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*); -static NET_API_STATUS (WINAPI *pNetUserModalsGet)(LPCWSTR,DWORD,LPBYTE*); -static NET_API_STATUS (WINAPI *pNetUserAdd)(LPCWSTR,DWORD,LPBYTE,LPDWORD); -static NET_API_STATUS (WINAPI *pNetUserDel)(LPCWSTR,LPCWSTR); -static NET_API_STATUS (WINAPI *pNetLocalGroupGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*); -static NET_API_STATUS (WINAPI *pNetLocalGroupGetMembers)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*,DWORD,LPDWORD,LPDWORD,PDWORD_PTR); static DWORD (WINAPI *pDavGetHTTPFromUNCPath)(LPCWSTR,LPWSTR,LPDWORD); static DWORD (WINAPI *pDavGetUNCFromHTTPPath)(LPCWSTR,LPWSTR,LPDWORD);
-static BOOL init_access_tests(void) -{ - DWORD dwSize; - BOOL rc; - - user_name[0] = 0; - dwSize = ARRAY_SIZE(user_name); - rc=GetUserNameW(user_name, &dwSize); - if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) - { - win_skip("GetUserNameW is not available.\n"); - return FALSE; - } - ok(rc, "User Name Retrieved\n"); - - computer_name[0] = 0; - dwSize = ARRAY_SIZE(computer_name); - ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved\n"); - return TRUE; -} - static NET_API_STATUS create_test_user(void) { USER_INFO_1 usri; @@ -85,12 +55,12 @@ static NET_API_STATUS create_test_user(void) usri.usri1_flags = UF_SCRIPT; usri.usri1_script_path = NULL;
- return pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL); + return NetUserAdd(NULL, 1, (BYTE *)&usri, NULL); }
static NET_API_STATUS delete_test_user(void) { - return pNetUserDel(NULL, L"testuser"); + return NetUserDel(NULL, L"testuser"); }
static void run_usergetinfo_tests(void) @@ -107,18 +77,18 @@ static void run_usergetinfo_tests(void) }
/* Level 0 */ - rc = pNetUserGetInfo(NULL, L"testuser", 0, (LPBYTE *)&ui0); + rc = NetUserGetInfo(NULL, L"testuser", 0, (BYTE **)&ui0); ok(rc == NERR_Success, "NetUserGetInfo level 0 failed: 0x%08x.\n", rc); ok(!wcscmp(L"testuser", ui0->usri0_name), "Got level 0 name %s.\n", debugstr_w(ui0->usri0_name)); - pNetApiBufferSize(ui0, &dwSize); + NetApiBufferSize(ui0, &dwSize); ok(dwSize >= (sizeof(USER_INFO_0) + (wcslen(ui0->usri0_name) + 1) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
/* Level 10 */ - rc = pNetUserGetInfo(NULL, L"testuser", 10, (LPBYTE *)&ui10); + rc = NetUserGetInfo(NULL, L"testuser", 10, (BYTE **)&ui10); ok(rc == NERR_Success, "NetUserGetInfo level 10 failed: 0x%08x.\n", rc); ok(!wcscmp(L"testuser", ui10->usri10_name), "Got level 10 name %s.\n", debugstr_w(ui10->usri10_name)); - pNetApiBufferSize(ui10, &dwSize); + NetApiBufferSize(ui10, &dwSize); ok(dwSize >= (sizeof(USER_INFO_10) + (wcslen(ui10->usri10_name) + 1 + wcslen(ui10->usri10_comment) + 1 + @@ -126,22 +96,22 @@ static void run_usergetinfo_tests(void) wcslen(ui10->usri10_full_name) + 1) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
- pNetApiBufferFree(ui0); - pNetApiBufferFree(ui10); + NetApiBufferFree(ui0); + NetApiBufferFree(ui10);
/* NetUserGetInfo should always work for the current user. */ - rc=pNetUserGetInfo(NULL, user_name, 0, (LPBYTE*)&ui0); + rc = NetUserGetInfo(NULL, user_name, 0, (BYTE **)&ui0); ok(rc == NERR_Success, "NetUsetGetInfo for current user failed: 0x%08x.\n", rc); - pNetApiBufferFree(ui0); + NetApiBufferFree(ui0);
/* errors handling */ - rc = pNetUserGetInfo(NULL, L"testuser", 10000, (LPBYTE *)&ui0); + rc = NetUserGetInfo(NULL, L"testuser", 10000, (BYTE **)&ui0); ok(rc == ERROR_INVALID_LEVEL,"Invalid Level: rc=%d\n",rc); - rc = pNetUserGetInfo(NULL, L"Nonexistent User", 0, (LPBYTE *)&ui0); + rc = NetUserGetInfo(NULL, L"Nonexistent User", 0, (BYTE **)&ui0); ok(rc == NERR_UserNotFound,"Invalid User Name: rc=%d\n",rc); todo_wine { /* FIXME - Currently Wine can't verify whether the network path is good or bad */ - rc = pNetUserGetInfo(L"\\Ba path", L"testuser", 0, (LPBYTE *)&ui0); + rc = NetUserGetInfo(L"\\Ba path", L"testuser", 0, (BYTE **)&ui0); ok(rc == ERROR_BAD_NETPATH || rc == ERROR_NETWORK_UNREACHABLE || rc == RPC_S_SERVER_UNAVAILABLE || @@ -149,12 +119,12 @@ static void run_usergetinfo_tests(void) rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */ "Bad Network Path: rc=%d\n",rc); } - rc = pNetUserGetInfo(L"", L"testuser", 0, (LPBYTE *)&ui0); + rc = NetUserGetInfo(L"", L"testuser", 0, (BYTE **)&ui0); ok(rc == ERROR_BAD_NETPATH || rc == NERR_Success, "Bad Network Path: rc=%d\n",rc); - rc = pNetUserGetInfo(L"\", L"testuser", 0, (LPBYTE *)&ui0); + rc = NetUserGetInfo(L"\", L"testuser", 0, (BYTE **)&ui0); ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc); - rc = pNetUserGetInfo(L"\\", L"testuser", 0, (LPBYTE *)&ui0); + rc = NetUserGetInfo(L"\\", L"testuser", 0, (BYTE **)&ui0); ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
if(delete_test_user() != NERR_Success) @@ -172,7 +142,7 @@ static void run_querydisplayinformation1_tests(void)
do { - Result = pNetQueryDisplayInformation( + Result = NetQueryDisplayInformation( NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount, (PVOID *)&Buffer);
@@ -200,7 +170,7 @@ static void run_querydisplayinformation1_tests(void) rec++; }
- pNetApiBufferFree(Buffer); + NetApiBufferFree(Buffer); } while (Result == ERROR_MORE_DATA);
ok(hasAdmin, "Doesn't have 'Administrator' account\n"); @@ -211,11 +181,11 @@ static void run_usermodalsget_tests(void) NET_API_STATUS rc; USER_MODALS_INFO_2 * umi2 = NULL;
- rc = pNetUserModalsGet(NULL, 2, (LPBYTE *)&umi2); + rc = NetUserModalsGet(NULL, 2, (BYTE **)&umi2); ok(rc == ERROR_SUCCESS, "NetUserModalsGet failed, rc = %d\n", rc);
if (umi2) - pNetApiBufferFree(umi2); + NetApiBufferFree(umi2); }
static void run_userhandling_tests(void) @@ -232,37 +202,26 @@ static void run_userhandling_tests(void) usri.usri1_name = sTooLongName; usri.usri1_password = sTestUserOldPass;
- ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL); - if (ret == NERR_Success || ret == NERR_UserExists) - { - /* Windows NT4 does create the user. Delete the user and also if it already existed - * due to a previous test run on NT4. - */ - trace("We are on NT4, we have to delete the user with the too long username\n"); - ret = pNetUserDel(NULL, sTooLongName); - ok(ret == NERR_Success, "Deleting the user failed : %d\n", ret); - } - else if (ret == ERROR_ACCESS_DENIED) + ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL); + if (ret == ERROR_ACCESS_DENIED) { skip("not enough permissions to add a user\n"); return; } else - ok(ret == NERR_BadUsername || - broken(ret == NERR_PasswordTooShort), /* NT4 */ - "Adding user with too long username returned 0x%08x\n", ret); + ok(ret == NERR_BadUsername, "Got %u.\n", ret);
usri.usri1_name = (WCHAR *)L"testuser"; usri.usri1_password = sTooLongPassword;
- ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL); + ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL); ok(ret == NERR_PasswordTooShort || ret == ERROR_ACCESS_DENIED /* Win2003 */, "Adding user with too long password returned 0x%08x\n", ret);
usri.usri1_name = sTooLongName; usri.usri1_password = sTooLongPassword;
- ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL); + ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL); /* NT4 doesn't have a problem with the username so it will report the too long password * as the error. NERR_PasswordTooShort is reported for all kind of password related errors. */ @@ -272,10 +231,10 @@ static void run_userhandling_tests(void) usri.usri1_name = (WCHAR *)L"testuser"; usri.usri1_password = sTestUserOldPass;
- ret = pNetUserAdd(NULL, 5, (LPBYTE)&usri, NULL); + ret = NetUserAdd(NULL, 5, (BYTE *)&usri, NULL); ok(ret == ERROR_INVALID_LEVEL, "Adding user with level 5 returned 0x%08x\n", ret);
- ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL); + ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL); if(ret == ERROR_ACCESS_DENIED) { skip("Insufficient permissions to add users. Skipping test.\n"); @@ -287,11 +246,7 @@ static void run_userhandling_tests(void) return; }
- ok(ret == NERR_Success || - broken(ret == NERR_PasswordTooShort), /* NT4 */ - "Adding user failed with error 0x%08x\n", ret); - if(ret != NERR_Success) - return; + ok(!ret, "Got %u.\n", ret);
/* On Windows XP (and newer), calling NetUserChangePassword with a NULL * domainname parameter creates a user home directory, iff the machine is @@ -301,10 +256,10 @@ static void run_userhandling_tests(void) * So let's not test NetUserChangePassword for now. */
- ret = pNetUserDel(NULL, L"testuser"); + ret = NetUserDel(NULL, L"testuser"); ok(ret == NERR_Success, "Deleting the user failed.\n");
- ret = pNetUserDel(NULL, L"testuser"); + ret = NetUserDel(NULL, L"testuser"); ok(ret == NERR_UserNotFound, "Deleting a nonexistent user returned 0x%08x\n",ret); }
@@ -316,7 +271,7 @@ static void run_localgroupgetinfo_tests(void) DWORD entries_read = 0, total_entries =0; int i;
- status = pNetLocalGroupGetInfo(NULL, L"Administrators", 1, (BYTE **)&lgi); + status = NetLocalGroupGetInfo(NULL, L"Administrators", 1, (BYTE **)&lgi); ok(status == NERR_Success || broken(status == NERR_GroupNotFound), "NetLocalGroupGetInfo unexpectedly returned %d\n", status); if (status != NERR_Success) return; @@ -324,9 +279,9 @@ static void run_localgroupgetinfo_tests(void) trace("Local groupname:%s\n", wine_dbgstr_w( lgi->lgrpi1_name)); trace("Comment: %s\n", wine_dbgstr_w( lgi->lgrpi1_comment));
- pNetApiBufferFree(lgi); + NetApiBufferFree(lgi);
- status = pNetLocalGroupGetMembers(NULL, L"Administrators", 3, (BYTE **)&buffer, + status = NetLocalGroupGetMembers(NULL, L"Administrators", 3, (BYTE **)&buffer, MAX_PREFERRED_LENGTH, &entries_read, &total_entries, NULL); ok(status == NERR_Success, "NetLocalGroupGetMembers unexpectedly returned %d\n", status); ok(entries_read > 0 && total_entries > 0, "Amount of entries is unexpectedly 0\n"); @@ -334,7 +289,7 @@ static void run_localgroupgetinfo_tests(void) for(i=0;i<entries_read;i++) trace("domain and name: %s\n", wine_dbgstr_w(buffer[i].lgrmi3_domainandname));
- pNetApiBufferFree(buffer); + NetApiBufferFree(buffer); }
static void test_DavGetHTTPFromUNCPath(void) @@ -532,38 +487,26 @@ static void test_DavGetUNCFromHTTPPath(void)
START_TEST(access) { - HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); - - pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree"); - pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize"); - pNetQueryDisplayInformation=(void*)GetProcAddress(hnetapi32,"NetQueryDisplayInformation"); - pNetUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetUserGetInfo"); - pNetUserModalsGet=(void*)GetProcAddress(hnetapi32,"NetUserModalsGet"); - pNetUserAdd=(void*)GetProcAddress(hnetapi32, "NetUserAdd"); - pNetUserDel=(void*)GetProcAddress(hnetapi32, "NetUserDel"); - pNetLocalGroupGetInfo=(void*)GetProcAddress(hnetapi32, "NetLocalGroupGetInfo"); - pNetLocalGroupGetMembers=(void*)GetProcAddress(hnetapi32, "NetLocalGroupGetMembers"); + HMODULE hnetapi32 = GetModuleHandleA("netapi32.dll"); + DWORD size; + BOOL ret; + pDavGetHTTPFromUNCPath = (void*)GetProcAddress(hnetapi32, "DavGetHTTPFromUNCPath"); pDavGetUNCFromHTTPPath = (void*)GetProcAddress(hnetapi32, "DavGetUNCFromHTTPPath");
- /* These functions were introduced with NT. It's safe to assume that - * if one is not available, none are. - */ - if (!pNetApiBufferFree) { - win_skip("Needed functions are not available\n"); - FreeLibrary(hnetapi32); - return; - } + size = sizeof(user_name); + ret = GetUserNameW(user_name, &size); + ok(ret, "Failed to get user name, error %u.\n", GetLastError()); + size = sizeof(computer_name); + ret = GetComputerNameW(computer_name, &size); + ok(ret, "Failed to get computer name, error %u.\n", GetLastError());
- if (init_access_tests()) { - run_userhandling_tests(); - run_usergetinfo_tests(); - run_querydisplayinformation1_tests(); - run_usermodalsget_tests(); - run_localgroupgetinfo_tests(); - } + run_userhandling_tests(); + run_usergetinfo_tests(); + run_querydisplayinformation1_tests(); + run_usermodalsget_tests(); + run_localgroupgetinfo_tests();
test_DavGetHTTPFromUNCPath(); test_DavGetUNCFromHTTPPath(); - FreeLibrary(hnetapi32); } diff --git a/dlls/netapi32/tests/apibuf.c b/dlls/netapi32/tests/apibuf.c index af4d39d2cdb..9063a4f6c55 100644 --- a/dlls/netapi32/tests/apibuf.c +++ b/dlls/netapi32/tests/apibuf.c @@ -29,12 +29,6 @@ #include <lmapibuf.h> #include <lmaccess.h>
-static NET_API_STATUS (WINAPI *pNetApiBufferAllocate)(DWORD,LPVOID*)=NULL; -static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID)=NULL; -static NET_API_STATUS (WINAPI *pNetApiBufferReallocate)(LPVOID,DWORD,LPVOID*)=NULL; -static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL; - - static void run_apibuf_tests(void) { VOID *p; @@ -42,46 +36,46 @@ static void run_apibuf_tests(void) NET_API_STATUS res;
/* test normal logic */ - ok(pNetApiBufferAllocate(1024, &p) == NERR_Success, + ok(NetApiBufferAllocate(1024, &p) == NERR_Success, "Reserved memory\n"); - ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); + ok(NetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); ok(dwSize >= 1024, "The size is correct\n");
- ok(pNetApiBufferReallocate(p, 1500, &p) == NERR_Success, + ok(NetApiBufferReallocate(p, 1500, &p) == NERR_Success, "Reallocated\n"); - ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); + ok(NetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); ok(dwSize >= 1500, "The size is correct\n");
- ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n"); + ok(NetApiBufferFree(p) == NERR_Success, "Freed\n");
- ok(pNetApiBufferSize(NULL, &dwSize) == ERROR_INVALID_PARAMETER, "Error for NULL pointer\n"); + ok(NetApiBufferSize(NULL, &dwSize) == ERROR_INVALID_PARAMETER, "Error for NULL pointer\n");
/* border reallocate cases */ - ok(pNetApiBufferReallocate(0, 1500, &p) == NERR_Success, "Reallocate with OldBuffer = NULL failed\n"); + ok(NetApiBufferReallocate(0, 1500, &p) == NERR_Success, "Reallocate with OldBuffer = NULL failed\n"); ok(p != NULL, "No memory got allocated\n"); - ok(pNetApiBufferFree(p) == NERR_Success, "NetApiBufferFree failed\n"); + ok(NetApiBufferFree(p) == NERR_Success, "NetApiBufferFree failed\n");
- ok(pNetApiBufferAllocate(1024, &p) == NERR_Success, "Memory not reserved\n"); - ok(pNetApiBufferReallocate(p, 0, &p) == NERR_Success, "Not freed\n"); + ok(NetApiBufferAllocate(1024, &p) == NERR_Success, "Memory not reserved\n"); + ok(NetApiBufferReallocate(p, 0, &p) == NERR_Success, "Not freed\n"); ok(p == NULL, "Pointer not cleared\n");
/* 0-length buffer */ - ok(pNetApiBufferAllocate(0, &p) == NERR_Success, + ok(NetApiBufferAllocate(0, &p) == NERR_Success, "Reserved memory\n"); - ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); + ok(NetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); ok(dwSize < 0xFFFFFFFF, "The size of the 0-length buffer\n"); - ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n"); + ok(NetApiBufferFree(p) == NERR_Success, "Freed\n");
/* NULL-Pointer */ /* NT: ERROR_INVALID_PARAMETER, lasterror is untouched) */ SetLastError(0xdeadbeef); - res = pNetApiBufferAllocate(0, NULL); + res = NetApiBufferAllocate(0, NULL); ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef), "returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with " "0xdeadbeef)\n", res, GetLastError());
SetLastError(0xdeadbeef); - res = pNetApiBufferAllocate(1024, NULL); + res = NetApiBufferAllocate(1024, NULL); ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef), "returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with " "0xdeadbeef)\n", res, GetLastError()); @@ -89,17 +83,5 @@ static void run_apibuf_tests(void)
START_TEST(apibuf) { - HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); - - pNetApiBufferAllocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferAllocate"); - pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree"); - pNetApiBufferReallocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferReallocate"); - pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize"); - - if (pNetApiBufferAllocate && pNetApiBufferFree && pNetApiBufferReallocate && pNetApiBufferSize) - run_apibuf_tests(); - else - win_skip("Needed functions are not available\n"); - - FreeLibrary(hnetapi32); + run_apibuf_tests(); } diff --git a/dlls/netapi32/tests/ds.c b/dlls/netapi32/tests/ds.c index 4b00499c8d5..10cbddab6cb 100644 --- a/dlls/netapi32/tests/ds.c +++ b/dlls/netapi32/tests/ds.c @@ -26,27 +26,24 @@ #include <winerror.h> #include <dsrole.h>
-static DWORD (WINAPI *pDsRoleGetPrimaryDomainInformation)(LPCWSTR, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL, PBYTE*); -static void (WINAPI *pDsRoleFreeMemory)(PVOID); - static void test_params(void) { DWORD ret; PDSROLE_PRIMARY_DOMAIN_INFO_BASIC dpdi;
SetLastError(0xdeadbeef); - ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, NULL); + ret = DsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, NULL); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
SetLastError(0xdeadbeef); - ret = pDsRoleGetPrimaryDomainInformation(NULL, 0, NULL); + ret = DsRoleGetPrimaryDomainInformation(NULL, 0, NULL); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret); SetLastError(0xdeadbeef); - ret = pDsRoleGetPrimaryDomainInformation(NULL, 4, NULL); + ret = DsRoleGetPrimaryDomainInformation(NULL, 4, NULL); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
SetLastError(0xdeadbeef); - ret = pDsRoleGetPrimaryDomainInformation(NULL, 4, (PBYTE *)&dpdi); + ret = DsRoleGetPrimaryDomainInformation(NULL, 4, (BYTE **)&dpdi); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret); }
@@ -58,36 +55,24 @@ static void test_get(void) PDSROLE_OPERATION_STATE_INFO dosi;
SetLastError(0xdeadbeef); - ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, (PBYTE *)&dpdi); + ret = DsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, (BYTE **)&dpdi); ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret); - pDsRoleFreeMemory(dpdi); + DsRoleFreeMemory(dpdi);
SetLastError(0xdeadbeef); - ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRoleUpgradeStatus, (PBYTE *)&dusi); + ret = DsRoleGetPrimaryDomainInformation(NULL, DsRoleUpgradeStatus, (BYTE **)&dusi); todo_wine { ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret); } - pDsRoleFreeMemory(dusi); + DsRoleFreeMemory(dusi);
SetLastError(0xdeadbeef); - ret = pDsRoleGetPrimaryDomainInformation(NULL, DsRoleOperationState, (PBYTE *)&dosi); + ret = DsRoleGetPrimaryDomainInformation(NULL, DsRoleOperationState, (BYTE **)&dosi); todo_wine { ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret); } - pDsRoleFreeMemory(dosi); + DsRoleFreeMemory(dosi); }
START_TEST(ds) { - HMODULE hnetapi32 = LoadLibraryA("netapi32.dll"); - - pDsRoleGetPrimaryDomainInformation=(void*)GetProcAddress(hnetapi32,"DsRoleGetPrimaryDomainInformation"); - if (pDsRoleGetPrimaryDomainInformation) - { - pDsRoleFreeMemory=(void*)GetProcAddress(hnetapi32,"DsRoleFreeMemory"); - - test_params(); - test_get(); - } - else - win_skip("DsRoleGetPrimaryDomainInformation is not available\n"); - - FreeLibrary(hnetapi32); + test_params(); + test_get(); } diff --git a/dlls/netapi32/tests/wksta.c b/dlls/netapi32/tests/wksta.c index 709ed776950..684905c4dcb 100644 --- a/dlls/netapi32/tests/wksta.c +++ b/dlls/netapi32/tests/wksta.c @@ -33,44 +33,18 @@ #include "lmapibuf.h" #include "lmjoin.h"
-static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID)=NULL; -static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL; static NET_API_STATUS (WINAPI *pNetpGetComputerName)(LPWSTR*)=NULL; -static NET_API_STATUS (WINAPI *pNetWkstaUserGetInfo)(LPWSTR,DWORD,PBYTE*)=NULL; -static NET_API_STATUS (WINAPI *pNetWkstaTransportEnum)(LPWSTR,DWORD,LPBYTE*, - DWORD,LPDWORD,LPDWORD,LPDWORD)=NULL; -static NET_API_STATUS (WINAPI *pNetGetJoinInformation)(LPCWSTR,LPWSTR*,PNETSETUP_JOIN_STATUS);
static WCHAR user_name[UNLEN + 1]; static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
-static BOOL init_wksta_tests(void) -{ - DWORD dwSize; - BOOL rc; - - user_name[0] = 0; - dwSize = ARRAY_SIZE(user_name); - rc=GetUserNameW(user_name, &dwSize); - if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) { - win_skip("GetUserNameW is not implemented\n"); - return FALSE; - } - ok(rc, "User Name Retrieved\n"); - - computer_name[0] = 0; - dwSize = ARRAY_SIZE(computer_name); - ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved\n"); - return TRUE; -} - static void run_get_comp_name_tests(void) { LPWSTR ws = NULL;
ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved\n"); ok(!wcscmp(computer_name, ws), "Expected %s, got %s.\n", debugstr_w(computer_name), debugstr_w(ws)); - pNetApiBufferFree(ws); + NetApiBufferFree(ws); }
static void run_wkstausergetinfo_tests(void) @@ -82,34 +56,25 @@ static void run_wkstausergetinfo_tests(void) NET_API_STATUS rc;
/* Level 0 */ - rc = pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0); + rc = NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0); if (rc == NERR_WkstaNotStarted) { skip("Workstation service not running\n"); return; } ok(!rc && ui0, "got %d and %p (expected NERR_Success and != NULL\n", rc, ui0); - - /* This failure occurred when I ran sshd as service and didn't authenticate - * Since the test dereferences ui0, the rest of this test is worthless - */ - if (!ui0) - { - return; - } - ok(!wcscmp(user_name, ui0->wkui0_username), "Expected username %s, got %s.\n", debugstr_w(user_name), debugstr_w(ui0->wkui0_username)); - pNetApiBufferSize(ui0, &dwSize); + NetApiBufferSize(ui0, &dwSize); ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) + wcslen(ui0->wkui0_username) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
/* Level 1 */ - ok(pNetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success, + ok(NetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success, "NetWkstaUserGetInfo is successful\n"); ok(!wcscmp(user_name, ui1->wkui1_username), "Expected username %s, got %s.\n", debugstr_w(user_name), debugstr_w(ui1->wkui1_username)); - pNetApiBufferSize(ui1, &dwSize); + NetApiBufferSize(ui1, &dwSize); ok(dwSize >= (sizeof(WKSTA_USER_INFO_1) + (wcslen(ui1->wkui1_username) + wcslen(ui1->wkui1_logon_domain) + @@ -118,20 +83,20 @@ static void run_wkstausergetinfo_tests(void) "Is allocated with NetApiBufferAllocate\n");
/* Level 1101 */ - ok(pNetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success, + ok(NetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success, "NetWkstaUserGetInfo is successful\n"); ok(!wcscmp(ui1101->wkui1101_oth_domains, ui1->wkui1_oth_domains), "Expected %s, got %s.\n", debugstr_w(ui1->wkui1_oth_domains), debugstr_w(ui1101->wkui1101_oth_domains)); - pNetApiBufferSize(ui1101, &dwSize); + NetApiBufferSize(ui1101, &dwSize); ok(dwSize >= (sizeof(WKSTA_USER_INFO_1101) + wcslen(ui1101->wkui1101_oth_domains) * sizeof(WCHAR)), "Is allocated with NetApiBufferAllocate\n");
- pNetApiBufferFree(ui0); - pNetApiBufferFree(ui1); - pNetApiBufferFree(ui1101); + NetApiBufferFree(ui0); + NetApiBufferFree(ui1); + NetApiBufferFree(ui1101);
/* errors handling */ - ok(pNetWkstaUserGetInfo(NULL, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL, + ok(NetWkstaUserGetInfo(NULL, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL, "Invalid level\n"); }
@@ -142,13 +107,13 @@ static void run_wkstatransportenum_tests(void) DWORD entriesRead, totalEntries;
/* 1st check: is param 2 (level) correct? (only if param 5 passed?) */ - apiReturn = pNetWkstaTransportEnum(NULL, 1, NULL, MAX_PREFERRED_LENGTH, + apiReturn = NetWkstaTransportEnum(NULL, 1, NULL, MAX_PREFERRED_LENGTH, NULL, &totalEntries, NULL); ok(apiReturn == ERROR_INVALID_LEVEL || apiReturn == ERROR_INVALID_PARAMETER, "NetWkstaTransportEnum returned %d\n", apiReturn);
/* 2nd check: is param 5 passed? (only if level passes?) */ - apiReturn = pNetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH, + apiReturn = NetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH, NULL, &totalEntries, NULL);
/* if no network adapter present, bail, the rest of the test will fail */ @@ -159,19 +124,19 @@ static void run_wkstatransportenum_tests(void) "NetWkstaTransportEnum returned %d\n", apiReturn);
/* 3rd check: is param 3 passed? */ - apiReturn = pNetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH, + apiReturn = NetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH, NULL, NULL, NULL); ok(apiReturn == STATUS_ACCESS_VIOLATION || apiReturn == RPC_X_NULL_REF_POINTER || apiReturn == ERROR_INVALID_PARAMETER, "NetWkstaTransportEnum returned %d\n", apiReturn);
/* 4th check: is param 6 passed? */ - apiReturn = pNetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH, + apiReturn = NetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH, &entriesRead, NULL, NULL); ok(apiReturn == RPC_X_NULL_REF_POINTER, "NetWkstaTransportEnum returned %d\n", apiReturn);
/* final check: valid return, actually get data back */ - apiReturn = pNetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH, + apiReturn = NetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH, &entriesRead, &totalEntries, NULL); ok(apiReturn == NERR_Success || apiReturn == ERROR_NETWORK_UNREACHABLE || apiReturn == NERR_WkstaNotStarted, "NetWkstaTransportEnum returned %d\n", apiReturn); @@ -182,7 +147,7 @@ static void run_wkstatransportenum_tests(void) ok(entriesRead > 0, "read at least one transport\n"); ok(totalEntries > 0 || broken(totalEntries == 0) /* Win7 */, "at least one transport\n"); - pNetApiBufferFree(bufPtr); + NetApiBufferFree(bufPtr); } }
@@ -191,52 +156,37 @@ static void run_wkstajoininfo_tests(void) NET_API_STATUS ret; LPWSTR buffer = NULL; NETSETUP_JOIN_STATUS buffertype = 0xdada; - /* NT4 doesn't have this function */ - if (!pNetGetJoinInformation) { - win_skip("NetGetJoinInformation not available\n"); - return; - }
- ret = pNetGetJoinInformation(NULL, NULL, NULL); + ret = NetGetJoinInformation(NULL, NULL, NULL); ok(ret == ERROR_INVALID_PARAMETER, "NetJoinGetInformation returned unexpected 0x%08x\n", ret); ok(buffertype == 0xdada, "buffertype set to unexpected value %d\n", buffertype);
- ret = pNetGetJoinInformation(NULL, &buffer, &buffertype); + ret = NetGetJoinInformation(NULL, &buffer, &buffertype); ok(ret == NERR_Success, "NetJoinGetInformation returned unexpected 0x%08x\n", ret); ok(buffertype != 0xdada && buffertype != NetSetupUnknownStatus, "buffertype set to unexpected value %d\n", buffertype); trace("workstation joined to %s with status %d\n", wine_dbgstr_w(buffer), buffertype); - pNetApiBufferFree(buffer); + NetApiBufferFree(buffer); }
START_TEST(wksta) { - HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); - - pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree"); - pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize"); - pNetpGetComputerName=(void*)GetProcAddress(hnetapi32,"NetpGetComputerName"); - pNetWkstaUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetWkstaUserGetInfo"); - pNetWkstaTransportEnum=(void*)GetProcAddress(hnetapi32,"NetWkstaTransportEnum"); - pNetGetJoinInformation=(void*)GetProcAddress(hnetapi32,"NetGetJoinInformation"); - - /* These functions were introduced with NT. It's safe to assume that - * if one is not available, none are. - */ - if (!pNetApiBufferFree) { - win_skip("Needed functions are not available\n"); - FreeLibrary(hnetapi32); - return; - } - - if (init_wksta_tests()) { - if (pNetpGetComputerName) - run_get_comp_name_tests(); - else - win_skip("Function NetpGetComputerName not available\n"); - run_wkstausergetinfo_tests(); - run_wkstatransportenum_tests(); - run_wkstajoininfo_tests(); - } - - FreeLibrary(hnetapi32); + DWORD size; + BOOL ret; + + pNetpGetComputerName = (void *)GetProcAddress(GetModuleHandleA("netapi32.dll"), "NetpGetComputerName"); + + size = sizeof(user_name); + ret = GetUserNameW(user_name, &size); + ok(ret, "Failed to get user name, error %u.\n", GetLastError()); + size = sizeof(computer_name); + ret = GetComputerNameW(computer_name, &size); + ok(ret, "Failed to get computer name, error %u.\n", GetLastError()); + + if (pNetpGetComputerName) + run_get_comp_name_tests(); + else + win_skip("Function NetpGetComputerName not available\n"); + run_wkstausergetinfo_tests(); + run_wkstatransportenum_tests(); + run_wkstajoininfo_tests(); }