Commit e480fa87 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

netapi32/tests: Remove some workarounds for no longer supported versions of Windows.

parent cc5e52ea
TESTDLL = netapi32.dll TESTDLL = netapi32.dll
IMPORTS = advapi32 IMPORTS = advapi32 netapi32
C_SRCS = \ C_SRCS = \
access.c \ access.c \
......
...@@ -40,39 +40,9 @@ static WCHAR sTooLongPassword[] = L"abcdefghabcdefghabcdefghabcdefghabcdefgh" ...@@ -40,39 +40,9 @@ static WCHAR sTooLongPassword[] = L"abcdefghabcdefghabcdefghabcdefghabcdefgh"
static WCHAR sTestUserOldPass[] = L"OldPassW0rdSet!~"; 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 *pDavGetHTTPFromUNCPath)(LPCWSTR,LPWSTR,LPDWORD);
static DWORD (WINAPI *pDavGetUNCFromHTTPPath)(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) static NET_API_STATUS create_test_user(void)
{ {
USER_INFO_1 usri; USER_INFO_1 usri;
...@@ -85,12 +55,12 @@ static NET_API_STATUS create_test_user(void) ...@@ -85,12 +55,12 @@ static NET_API_STATUS create_test_user(void)
usri.usri1_flags = UF_SCRIPT; usri.usri1_flags = UF_SCRIPT;
usri.usri1_script_path = NULL; 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) static NET_API_STATUS delete_test_user(void)
{ {
return pNetUserDel(NULL, L"testuser"); return NetUserDel(NULL, L"testuser");
} }
static void run_usergetinfo_tests(void) static void run_usergetinfo_tests(void)
...@@ -107,18 +77,18 @@ static void run_usergetinfo_tests(void) ...@@ -107,18 +77,18 @@ static void run_usergetinfo_tests(void)
} }
/* Level 0 */ /* 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(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)); 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)), ok(dwSize >= (sizeof(USER_INFO_0) + (wcslen(ui0->usri0_name) + 1) * sizeof(WCHAR)),
"Is allocated with NetApiBufferAllocate\n"); "Is allocated with NetApiBufferAllocate\n");
/* Level 10 */ /* 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(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)); 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) + ok(dwSize >= (sizeof(USER_INFO_10) +
(wcslen(ui10->usri10_name) + 1 + (wcslen(ui10->usri10_name) + 1 +
wcslen(ui10->usri10_comment) + 1 + wcslen(ui10->usri10_comment) + 1 +
...@@ -126,22 +96,22 @@ static void run_usergetinfo_tests(void) ...@@ -126,22 +96,22 @@ static void run_usergetinfo_tests(void)
wcslen(ui10->usri10_full_name) + 1) * sizeof(WCHAR)), wcslen(ui10->usri10_full_name) + 1) * sizeof(WCHAR)),
"Is allocated with NetApiBufferAllocate\n"); "Is allocated with NetApiBufferAllocate\n");
pNetApiBufferFree(ui0); NetApiBufferFree(ui0);
pNetApiBufferFree(ui10); NetApiBufferFree(ui10);
/* NetUserGetInfo should always work for the current user. */ /* 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); ok(rc == NERR_Success, "NetUsetGetInfo for current user failed: 0x%08x.\n", rc);
pNetApiBufferFree(ui0); NetApiBufferFree(ui0);
/* errors handling */ /* 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); 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); ok(rc == NERR_UserNotFound,"Invalid User Name: rc=%d\n",rc);
todo_wine { todo_wine {
/* FIXME - Currently Wine can't verify whether the network path is good or bad */ /* 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 || ok(rc == ERROR_BAD_NETPATH ||
rc == ERROR_NETWORK_UNREACHABLE || rc == ERROR_NETWORK_UNREACHABLE ||
rc == RPC_S_SERVER_UNAVAILABLE || rc == RPC_S_SERVER_UNAVAILABLE ||
...@@ -149,12 +119,12 @@ static void run_usergetinfo_tests(void) ...@@ -149,12 +119,12 @@ static void run_usergetinfo_tests(void)
rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */ rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */
"Bad Network Path: rc=%d\n",rc); "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, ok(rc == ERROR_BAD_NETPATH || rc == NERR_Success,
"Bad Network Path: rc=%d\n",rc); "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); 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); ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
if(delete_test_user() != NERR_Success) if(delete_test_user() != NERR_Success)
...@@ -172,7 +142,7 @@ static void run_querydisplayinformation1_tests(void) ...@@ -172,7 +142,7 @@ static void run_querydisplayinformation1_tests(void)
do do
{ {
Result = pNetQueryDisplayInformation( Result = NetQueryDisplayInformation(
NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount, NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount,
(PVOID *)&Buffer); (PVOID *)&Buffer);
...@@ -200,7 +170,7 @@ static void run_querydisplayinformation1_tests(void) ...@@ -200,7 +170,7 @@ static void run_querydisplayinformation1_tests(void)
rec++; rec++;
} }
pNetApiBufferFree(Buffer); NetApiBufferFree(Buffer);
} while (Result == ERROR_MORE_DATA); } while (Result == ERROR_MORE_DATA);
ok(hasAdmin, "Doesn't have 'Administrator' account\n"); ok(hasAdmin, "Doesn't have 'Administrator' account\n");
...@@ -211,11 +181,11 @@ static void run_usermodalsget_tests(void) ...@@ -211,11 +181,11 @@ static void run_usermodalsget_tests(void)
NET_API_STATUS rc; NET_API_STATUS rc;
USER_MODALS_INFO_2 * umi2 = NULL; 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); ok(rc == ERROR_SUCCESS, "NetUserModalsGet failed, rc = %d\n", rc);
if (umi2) if (umi2)
pNetApiBufferFree(umi2); NetApiBufferFree(umi2);
} }
static void run_userhandling_tests(void) static void run_userhandling_tests(void)
...@@ -232,37 +202,26 @@ static void run_userhandling_tests(void) ...@@ -232,37 +202,26 @@ static void run_userhandling_tests(void)
usri.usri1_name = sTooLongName; usri.usri1_name = sTooLongName;
usri.usri1_password = sTestUserOldPass; usri.usri1_password = sTestUserOldPass;
ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL); ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL);
if (ret == NERR_Success || ret == NERR_UserExists) if (ret == ERROR_ACCESS_DENIED)
{
/* 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)
{ {
skip("not enough permissions to add a user\n"); skip("not enough permissions to add a user\n");
return; return;
} }
else else
ok(ret == NERR_BadUsername || ok(ret == NERR_BadUsername, "Got %u.\n", ret);
broken(ret == NERR_PasswordTooShort), /* NT4 */
"Adding user with too long username returned 0x%08x\n", ret);
usri.usri1_name = (WCHAR *)L"testuser"; usri.usri1_name = (WCHAR *)L"testuser";
usri.usri1_password = sTooLongPassword; 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 */, ok(ret == NERR_PasswordTooShort || ret == ERROR_ACCESS_DENIED /* Win2003 */,
"Adding user with too long password returned 0x%08x\n", ret); "Adding user with too long password returned 0x%08x\n", ret);
usri.usri1_name = sTooLongName; usri.usri1_name = sTooLongName;
usri.usri1_password = sTooLongPassword; 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 /* 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. * as the error. NERR_PasswordTooShort is reported for all kind of password related errors.
*/ */
...@@ -272,10 +231,10 @@ static void run_userhandling_tests(void) ...@@ -272,10 +231,10 @@ static void run_userhandling_tests(void)
usri.usri1_name = (WCHAR *)L"testuser"; usri.usri1_name = (WCHAR *)L"testuser";
usri.usri1_password = sTestUserOldPass; 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); 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) if(ret == ERROR_ACCESS_DENIED)
{ {
skip("Insufficient permissions to add users. Skipping test.\n"); skip("Insufficient permissions to add users. Skipping test.\n");
...@@ -287,11 +246,7 @@ static void run_userhandling_tests(void) ...@@ -287,11 +246,7 @@ static void run_userhandling_tests(void)
return; return;
} }
ok(ret == NERR_Success || ok(!ret, "Got %u.\n", ret);
broken(ret == NERR_PasswordTooShort), /* NT4 */
"Adding user failed with error 0x%08x\n", ret);
if(ret != NERR_Success)
return;
/* On Windows XP (and newer), calling NetUserChangePassword with a NULL /* On Windows XP (and newer), calling NetUserChangePassword with a NULL
* domainname parameter creates a user home directory, iff the machine is * domainname parameter creates a user home directory, iff the machine is
...@@ -301,10 +256,10 @@ static void run_userhandling_tests(void) ...@@ -301,10 +256,10 @@ static void run_userhandling_tests(void)
* So let's not test NetUserChangePassword for now. * 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"); 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); ok(ret == NERR_UserNotFound, "Deleting a nonexistent user returned 0x%08x\n",ret);
} }
...@@ -316,7 +271,7 @@ static void run_localgroupgetinfo_tests(void) ...@@ -316,7 +271,7 @@ static void run_localgroupgetinfo_tests(void)
DWORD entries_read = 0, total_entries =0; DWORD entries_read = 0, total_entries =0;
int i; 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), ok(status == NERR_Success || broken(status == NERR_GroupNotFound),
"NetLocalGroupGetInfo unexpectedly returned %d\n", status); "NetLocalGroupGetInfo unexpectedly returned %d\n", status);
if (status != NERR_Success) return; if (status != NERR_Success) return;
...@@ -324,9 +279,9 @@ static void run_localgroupgetinfo_tests(void) ...@@ -324,9 +279,9 @@ static void run_localgroupgetinfo_tests(void)
trace("Local groupname:%s\n", wine_dbgstr_w( lgi->lgrpi1_name)); trace("Local groupname:%s\n", wine_dbgstr_w( lgi->lgrpi1_name));
trace("Comment: %s\n", wine_dbgstr_w( lgi->lgrpi1_comment)); 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); MAX_PREFERRED_LENGTH, &entries_read, &total_entries, NULL);
ok(status == NERR_Success, "NetLocalGroupGetMembers unexpectedly returned %d\n", status); ok(status == NERR_Success, "NetLocalGroupGetMembers unexpectedly returned %d\n", status);
ok(entries_read > 0 && total_entries > 0, "Amount of entries is unexpectedly 0\n"); ok(entries_read > 0 && total_entries > 0, "Amount of entries is unexpectedly 0\n");
...@@ -334,7 +289,7 @@ static void run_localgroupgetinfo_tests(void) ...@@ -334,7 +289,7 @@ static void run_localgroupgetinfo_tests(void)
for(i=0;i<entries_read;i++) for(i=0;i<entries_read;i++)
trace("domain and name: %s\n", wine_dbgstr_w(buffer[i].lgrmi3_domainandname)); trace("domain and name: %s\n", wine_dbgstr_w(buffer[i].lgrmi3_domainandname));
pNetApiBufferFree(buffer); NetApiBufferFree(buffer);
} }
static void test_DavGetHTTPFromUNCPath(void) static void test_DavGetHTTPFromUNCPath(void)
...@@ -532,38 +487,26 @@ static void test_DavGetUNCFromHTTPPath(void) ...@@ -532,38 +487,26 @@ static void test_DavGetUNCFromHTTPPath(void)
START_TEST(access) START_TEST(access)
{ {
HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); HMODULE hnetapi32 = GetModuleHandleA("netapi32.dll");
DWORD size;
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree"); BOOL ret;
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");
pDavGetHTTPFromUNCPath = (void*)GetProcAddress(hnetapi32, "DavGetHTTPFromUNCPath"); pDavGetHTTPFromUNCPath = (void*)GetProcAddress(hnetapi32, "DavGetHTTPFromUNCPath");
pDavGetUNCFromHTTPPath = (void*)GetProcAddress(hnetapi32, "DavGetUNCFromHTTPPath"); pDavGetUNCFromHTTPPath = (void*)GetProcAddress(hnetapi32, "DavGetUNCFromHTTPPath");
/* These functions were introduced with NT. It's safe to assume that size = sizeof(user_name);
* if one is not available, none are. ret = GetUserNameW(user_name, &size);
*/ ok(ret, "Failed to get user name, error %u.\n", GetLastError());
if (!pNetApiBufferFree) { size = sizeof(computer_name);
win_skip("Needed functions are not available\n"); ret = GetComputerNameW(computer_name, &size);
FreeLibrary(hnetapi32); ok(ret, "Failed to get computer name, error %u.\n", GetLastError());
return;
}
if (init_access_tests()) { run_userhandling_tests();
run_userhandling_tests(); run_usergetinfo_tests();
run_usergetinfo_tests(); run_querydisplayinformation1_tests();
run_querydisplayinformation1_tests(); run_usermodalsget_tests();
run_usermodalsget_tests(); run_localgroupgetinfo_tests();
run_localgroupgetinfo_tests();
}
test_DavGetHTTPFromUNCPath(); test_DavGetHTTPFromUNCPath();
test_DavGetUNCFromHTTPPath(); test_DavGetUNCFromHTTPPath();
FreeLibrary(hnetapi32);
} }
...@@ -29,12 +29,6 @@ ...@@ -29,12 +29,6 @@
#include <lmapibuf.h> #include <lmapibuf.h>
#include <lmaccess.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) static void run_apibuf_tests(void)
{ {
VOID *p; VOID *p;
...@@ -42,46 +36,46 @@ static void run_apibuf_tests(void) ...@@ -42,46 +36,46 @@ static void run_apibuf_tests(void)
NET_API_STATUS res; NET_API_STATUS res;
/* test normal logic */ /* test normal logic */
ok(pNetApiBufferAllocate(1024, &p) == NERR_Success, ok(NetApiBufferAllocate(1024, &p) == NERR_Success,
"Reserved memory\n"); "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(dwSize >= 1024, "The size is correct\n");
ok(pNetApiBufferReallocate(p, 1500, &p) == NERR_Success, ok(NetApiBufferReallocate(p, 1500, &p) == NERR_Success,
"Reallocated\n"); "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(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 */ /* 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(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(NetApiBufferAllocate(1024, &p) == NERR_Success, "Memory not reserved\n");
ok(pNetApiBufferReallocate(p, 0, &p) == NERR_Success, "Not freed\n"); ok(NetApiBufferReallocate(p, 0, &p) == NERR_Success, "Not freed\n");
ok(p == NULL, "Pointer not cleared\n"); ok(p == NULL, "Pointer not cleared\n");
/* 0-length buffer */ /* 0-length buffer */
ok(pNetApiBufferAllocate(0, &p) == NERR_Success, ok(NetApiBufferAllocate(0, &p) == NERR_Success,
"Reserved memory\n"); "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(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 */ /* NULL-Pointer */
/* NT: ERROR_INVALID_PARAMETER, lasterror is untouched) */ /* NT: ERROR_INVALID_PARAMETER, lasterror is untouched) */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pNetApiBufferAllocate(0, NULL); res = NetApiBufferAllocate(0, NULL);
ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef), ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef),
"returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with " "returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with "
"0xdeadbeef)\n", res, GetLastError()); "0xdeadbeef)\n", res, GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = pNetApiBufferAllocate(1024, NULL); res = NetApiBufferAllocate(1024, NULL);
ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef), ok( (res == ERROR_INVALID_PARAMETER) && (GetLastError() == 0xdeadbeef),
"returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with " "returned %d with 0x%x (expected ERROR_INVALID_PARAMETER with "
"0xdeadbeef)\n", res, GetLastError()); "0xdeadbeef)\n", res, GetLastError());
...@@ -89,17 +83,5 @@ static void run_apibuf_tests(void) ...@@ -89,17 +83,5 @@ static void run_apibuf_tests(void)
START_TEST(apibuf) START_TEST(apibuf)
{ {
HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); run_apibuf_tests();
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);
} }
...@@ -26,27 +26,24 @@ ...@@ -26,27 +26,24 @@
#include <winerror.h> #include <winerror.h>
#include <dsrole.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) static void test_params(void)
{ {
DWORD ret; DWORD ret;
PDSROLE_PRIMARY_DOMAIN_INFO_BASIC dpdi; PDSROLE_PRIMARY_DOMAIN_INFO_BASIC dpdi;
SetLastError(0xdeadbeef); 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); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
SetLastError(0xdeadbeef); 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); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
SetLastError(0xdeadbeef); 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); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
SetLastError(0xdeadbeef); 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); ok( ret == ERROR_INVALID_PARAMETER, "Expected error ERROR_INVALID_PARAMETER, got (%d)\n", ret);
} }
...@@ -58,36 +55,24 @@ static void test_get(void) ...@@ -58,36 +55,24 @@ static void test_get(void)
PDSROLE_OPERATION_STATE_INFO dosi; PDSROLE_OPERATION_STATE_INFO dosi;
SetLastError(0xdeadbeef); 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); ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret);
pDsRoleFreeMemory(dpdi); DsRoleFreeMemory(dpdi);
SetLastError(0xdeadbeef); 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); } todo_wine { ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret); }
pDsRoleFreeMemory(dusi); DsRoleFreeMemory(dusi);
SetLastError(0xdeadbeef); 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); } todo_wine { ok( ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got (%d)\n", ret); }
pDsRoleFreeMemory(dosi); DsRoleFreeMemory(dosi);
} }
START_TEST(ds) START_TEST(ds)
{ {
HMODULE hnetapi32 = LoadLibraryA("netapi32.dll"); test_params();
test_get();
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);
} }
...@@ -33,44 +33,18 @@ ...@@ -33,44 +33,18 @@
#include "lmapibuf.h" #include "lmapibuf.h"
#include "lmjoin.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 *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 user_name[UNLEN + 1];
static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 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) static void run_get_comp_name_tests(void)
{ {
LPWSTR ws = NULL; LPWSTR ws = NULL;
ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved\n"); 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)); 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) static void run_wkstausergetinfo_tests(void)
...@@ -82,34 +56,25 @@ static void run_wkstausergetinfo_tests(void) ...@@ -82,34 +56,25 @@ static void run_wkstausergetinfo_tests(void)
NET_API_STATUS rc; NET_API_STATUS rc;
/* Level 0 */ /* Level 0 */
rc = pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0); rc = NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0);
if (rc == NERR_WkstaNotStarted) if (rc == NERR_WkstaNotStarted)
{ {
skip("Workstation service not running\n"); skip("Workstation service not running\n");
return; return;
} }
ok(!rc && ui0, "got %d and %p (expected NERR_Success and != NULL\n", rc, ui0); 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", ok(!wcscmp(user_name, ui0->wkui0_username), "Expected username %s, got %s.\n",
debugstr_w(user_name), debugstr_w(ui0->wkui0_username)); 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)), ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) + wcslen(ui0->wkui0_username) * sizeof(WCHAR)),
"Is allocated with NetApiBufferAllocate\n"); "Is allocated with NetApiBufferAllocate\n");
/* Level 1 */ /* Level 1 */
ok(pNetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success, ok(NetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success,
"NetWkstaUserGetInfo is successful\n"); "NetWkstaUserGetInfo is successful\n");
ok(!wcscmp(user_name, ui1->wkui1_username), "Expected username %s, got %s.\n", ok(!wcscmp(user_name, ui1->wkui1_username), "Expected username %s, got %s.\n",
debugstr_w(user_name), debugstr_w(ui1->wkui1_username)); debugstr_w(user_name), debugstr_w(ui1->wkui1_username));
pNetApiBufferSize(ui1, &dwSize); NetApiBufferSize(ui1, &dwSize);
ok(dwSize >= (sizeof(WKSTA_USER_INFO_1) + ok(dwSize >= (sizeof(WKSTA_USER_INFO_1) +
(wcslen(ui1->wkui1_username) + (wcslen(ui1->wkui1_username) +
wcslen(ui1->wkui1_logon_domain) + wcslen(ui1->wkui1_logon_domain) +
...@@ -118,20 +83,20 @@ static void run_wkstausergetinfo_tests(void) ...@@ -118,20 +83,20 @@ static void run_wkstausergetinfo_tests(void)
"Is allocated with NetApiBufferAllocate\n"); "Is allocated with NetApiBufferAllocate\n");
/* Level 1101 */ /* Level 1101 */
ok(pNetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success, ok(NetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success,
"NetWkstaUserGetInfo is successful\n"); "NetWkstaUserGetInfo is successful\n");
ok(!wcscmp(ui1101->wkui1101_oth_domains, ui1->wkui1_oth_domains), "Expected %s, got %s.\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)); 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)), ok(dwSize >= (sizeof(WKSTA_USER_INFO_1101) + wcslen(ui1101->wkui1101_oth_domains) * sizeof(WCHAR)),
"Is allocated with NetApiBufferAllocate\n"); "Is allocated with NetApiBufferAllocate\n");
pNetApiBufferFree(ui0); NetApiBufferFree(ui0);
pNetApiBufferFree(ui1); NetApiBufferFree(ui1);
pNetApiBufferFree(ui1101); NetApiBufferFree(ui1101);
/* errors handling */ /* errors handling */
ok(pNetWkstaUserGetInfo(NULL, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL, ok(NetWkstaUserGetInfo(NULL, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL,
"Invalid level\n"); "Invalid level\n");
} }
...@@ -142,13 +107,13 @@ static void run_wkstatransportenum_tests(void) ...@@ -142,13 +107,13 @@ static void run_wkstatransportenum_tests(void)
DWORD entriesRead, totalEntries; DWORD entriesRead, totalEntries;
/* 1st check: is param 2 (level) correct? (only if param 5 passed?) */ /* 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); NULL, &totalEntries, NULL);
ok(apiReturn == ERROR_INVALID_LEVEL || apiReturn == ERROR_INVALID_PARAMETER, ok(apiReturn == ERROR_INVALID_LEVEL || apiReturn == ERROR_INVALID_PARAMETER,
"NetWkstaTransportEnum returned %d\n", apiReturn); "NetWkstaTransportEnum returned %d\n", apiReturn);
/* 2nd check: is param 5 passed? (only if level passes?) */ /* 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); NULL, &totalEntries, NULL);
/* if no network adapter present, bail, the rest of the test will fail */ /* if no network adapter present, bail, the rest of the test will fail */
...@@ -159,19 +124,19 @@ static void run_wkstatransportenum_tests(void) ...@@ -159,19 +124,19 @@ static void run_wkstatransportenum_tests(void)
"NetWkstaTransportEnum returned %d\n", apiReturn); "NetWkstaTransportEnum returned %d\n", apiReturn);
/* 3rd check: is param 3 passed? */ /* 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); NULL, NULL, NULL);
ok(apiReturn == STATUS_ACCESS_VIOLATION || apiReturn == RPC_X_NULL_REF_POINTER || apiReturn == ERROR_INVALID_PARAMETER, ok(apiReturn == STATUS_ACCESS_VIOLATION || apiReturn == RPC_X_NULL_REF_POINTER || apiReturn == ERROR_INVALID_PARAMETER,
"NetWkstaTransportEnum returned %d\n", apiReturn); "NetWkstaTransportEnum returned %d\n", apiReturn);
/* 4th check: is param 6 passed? */ /* 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); &entriesRead, NULL, NULL);
ok(apiReturn == RPC_X_NULL_REF_POINTER, ok(apiReturn == RPC_X_NULL_REF_POINTER,
"NetWkstaTransportEnum returned %d\n", apiReturn); "NetWkstaTransportEnum returned %d\n", apiReturn);
/* final check: valid return, actually get data back */ /* 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); &entriesRead, &totalEntries, NULL);
ok(apiReturn == NERR_Success || apiReturn == ERROR_NETWORK_UNREACHABLE || apiReturn == NERR_WkstaNotStarted, ok(apiReturn == NERR_Success || apiReturn == ERROR_NETWORK_UNREACHABLE || apiReturn == NERR_WkstaNotStarted,
"NetWkstaTransportEnum returned %d\n", apiReturn); "NetWkstaTransportEnum returned %d\n", apiReturn);
...@@ -182,7 +147,7 @@ static void run_wkstatransportenum_tests(void) ...@@ -182,7 +147,7 @@ static void run_wkstatransportenum_tests(void)
ok(entriesRead > 0, "read at least one transport\n"); ok(entriesRead > 0, "read at least one transport\n");
ok(totalEntries > 0 || broken(totalEntries == 0) /* Win7 */, ok(totalEntries > 0 || broken(totalEntries == 0) /* Win7 */,
"at least one transport\n"); "at least one transport\n");
pNetApiBufferFree(bufPtr); NetApiBufferFree(bufPtr);
} }
} }
...@@ -191,52 +156,37 @@ static void run_wkstajoininfo_tests(void) ...@@ -191,52 +156,37 @@ static void run_wkstajoininfo_tests(void)
NET_API_STATUS ret; NET_API_STATUS ret;
LPWSTR buffer = NULL; LPWSTR buffer = NULL;
NETSETUP_JOIN_STATUS buffertype = 0xdada; 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(ret == ERROR_INVALID_PARAMETER, "NetJoinGetInformation returned unexpected 0x%08x\n", ret);
ok(buffertype == 0xdada, "buffertype set to unexpected value %d\n", buffertype); 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(ret == NERR_Success, "NetJoinGetInformation returned unexpected 0x%08x\n", ret);
ok(buffertype != 0xdada && buffertype != NetSetupUnknownStatus, "buffertype set to unexpected value %d\n", buffertype); 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); trace("workstation joined to %s with status %d\n", wine_dbgstr_w(buffer), buffertype);
pNetApiBufferFree(buffer); NetApiBufferFree(buffer);
} }
START_TEST(wksta) START_TEST(wksta)
{ {
HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); DWORD size;
BOOL ret;
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize"); pNetpGetComputerName = (void *)GetProcAddress(GetModuleHandleA("netapi32.dll"), "NetpGetComputerName");
pNetpGetComputerName=(void*)GetProcAddress(hnetapi32,"NetpGetComputerName");
pNetWkstaUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetWkstaUserGetInfo"); size = sizeof(user_name);
pNetWkstaTransportEnum=(void*)GetProcAddress(hnetapi32,"NetWkstaTransportEnum"); ret = GetUserNameW(user_name, &size);
pNetGetJoinInformation=(void*)GetProcAddress(hnetapi32,"NetGetJoinInformation"); ok(ret, "Failed to get user name, error %u.\n", GetLastError());
size = sizeof(computer_name);
/* These functions were introduced with NT. It's safe to assume that ret = GetComputerNameW(computer_name, &size);
* if one is not available, none are. ok(ret, "Failed to get computer name, error %u.\n", GetLastError());
*/
if (!pNetApiBufferFree) { if (pNetpGetComputerName)
win_skip("Needed functions are not available\n"); run_get_comp_name_tests();
FreeLibrary(hnetapi32); else
return; win_skip("Function NetpGetComputerName not available\n");
} run_wkstausergetinfo_tests();
run_wkstatransportenum_tests();
if (init_wksta_tests()) { run_wkstajoininfo_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);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment