2002-09-11 04:35:17 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2002 Andriy Palamarchuk
|
|
|
|
*
|
|
|
|
* Conformance test of the workstation functions.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-09-11 04:35:17 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-09-11 04:35:17 +02:00
|
|
|
#include "winbase.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winnls.h"
|
2003-07-19 00:53:49 +02:00
|
|
|
#include "winresrc.h" /* Ensure we use Unicode defns with native headers */
|
2002-09-11 04:35:17 +02:00
|
|
|
#include "nb30.h"
|
|
|
|
#include "lmcons.h"
|
|
|
|
#include "lmerr.h"
|
|
|
|
#include "lmwksta.h"
|
|
|
|
#include "lmapibuf.h"
|
2011-06-10 10:41:50 +02:00
|
|
|
#include "lmjoin.h"
|
2002-09-11 04:35:17 +02:00
|
|
|
|
2002-12-19 02:04:12 +01:00
|
|
|
static NET_API_STATUS (WINAPI *pNetpGetComputerName)(LPWSTR*)=NULL;
|
2002-09-11 04:35:17 +02:00
|
|
|
|
2010-10-01 13:36:54 +02:00
|
|
|
static WCHAR user_name[UNLEN + 1];
|
|
|
|
static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
|
2002-09-23 22:36:50 +02:00
|
|
|
|
2002-12-19 02:04:12 +01:00
|
|
|
static void run_get_comp_name_tests(void)
|
2002-09-11 04:35:17 +02:00
|
|
|
{
|
2004-04-20 04:14:00 +02:00
|
|
|
LPWSTR ws = NULL;
|
2002-12-19 02:04:12 +01:00
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved\n");
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(!wcscmp(computer_name, ws), "Expected %s, got %s.\n", debugstr_w(computer_name), debugstr_w(ws));
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(ws);
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|
|
|
|
|
2002-12-19 02:04:12 +01:00
|
|
|
static void run_wkstausergetinfo_tests(void)
|
2002-09-11 04:35:17 +02:00
|
|
|
{
|
|
|
|
LPWKSTA_USER_INFO_0 ui0 = NULL;
|
|
|
|
LPWKSTA_USER_INFO_1 ui1 = NULL;
|
|
|
|
LPWKSTA_USER_INFO_1101 ui1101 = NULL;
|
|
|
|
DWORD dwSize;
|
2012-11-13 23:50:15 +01:00
|
|
|
NET_API_STATUS rc;
|
2002-09-11 04:35:17 +02:00
|
|
|
|
|
|
|
/* Level 0 */
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0);
|
2012-11-13 23:50:15 +01:00
|
|
|
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);
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(!wcscmp(user_name, ui0->wkui0_username), "Expected username %s, got %s.\n",
|
|
|
|
debugstr_w(user_name), debugstr_w(ui0->wkui0_username));
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferSize(ui0, &dwSize);
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) + wcslen(ui0->wkui0_username) * sizeof(WCHAR)),
|
2004-01-27 21:13:03 +01:00
|
|
|
"Is allocated with NetApiBufferAllocate\n");
|
2002-09-11 04:35:17 +02:00
|
|
|
|
|
|
|
/* Level 1 */
|
2020-01-08 22:23:22 +01:00
|
|
|
ok(NetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success,
|
2004-01-27 21:13:03 +01:00
|
|
|
"NetWkstaUserGetInfo is successful\n");
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(!wcscmp(user_name, ui1->wkui1_username), "Expected username %s, got %s.\n",
|
|
|
|
debugstr_w(user_name), debugstr_w(ui1->wkui1_username));
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferSize(ui1, &dwSize);
|
2002-09-11 04:35:17 +02:00
|
|
|
ok(dwSize >= (sizeof(WKSTA_USER_INFO_1) +
|
2020-01-08 22:23:21 +01:00
|
|
|
(wcslen(ui1->wkui1_username) +
|
|
|
|
wcslen(ui1->wkui1_logon_domain) +
|
|
|
|
wcslen(ui1->wkui1_oth_domains) +
|
|
|
|
wcslen(ui1->wkui1_logon_server)) * sizeof(WCHAR)),
|
2004-01-27 21:13:03 +01:00
|
|
|
"Is allocated with NetApiBufferAllocate\n");
|
2002-09-11 04:35:17 +02:00
|
|
|
|
|
|
|
/* Level 1101 */
|
2020-01-08 22:23:22 +01:00
|
|
|
ok(NetWkstaUserGetInfo(NULL, 1101, (LPBYTE *)&ui1101) == NERR_Success,
|
2004-01-27 21:13:03 +01:00
|
|
|
"NetWkstaUserGetInfo is successful\n");
|
2020-01-08 22:23:21 +01:00
|
|
|
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));
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferSize(ui1101, &dwSize);
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(dwSize >= (sizeof(WKSTA_USER_INFO_1101) + wcslen(ui1101->wkui1101_oth_domains) * sizeof(WCHAR)),
|
2004-01-27 21:13:03 +01:00
|
|
|
"Is allocated with NetApiBufferAllocate\n");
|
2002-09-11 04:35:17 +02:00
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(ui0);
|
|
|
|
NetApiBufferFree(ui1);
|
|
|
|
NetApiBufferFree(ui1101);
|
2002-09-11 04:35:17 +02:00
|
|
|
|
|
|
|
/* errors handling */
|
2020-01-08 22:23:22 +01:00
|
|
|
ok(NetWkstaUserGetInfo(NULL, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL,
|
2004-01-27 21:13:03 +01:00
|
|
|
"Invalid level\n");
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|
|
|
|
|
2003-04-30 02:48:56 +02:00
|
|
|
static void run_wkstatransportenum_tests(void)
|
|
|
|
{
|
|
|
|
LPBYTE bufPtr;
|
|
|
|
NET_API_STATUS apiReturn;
|
|
|
|
DWORD entriesRead, totalEntries;
|
|
|
|
|
|
|
|
/* 1st check: is param 2 (level) correct? (only if param 5 passed?) */
|
2020-01-08 22:23:22 +01:00
|
|
|
apiReturn = NetWkstaTransportEnum(NULL, 1, NULL, MAX_PREFERRED_LENGTH,
|
2003-04-30 02:48:56 +02:00
|
|
|
NULL, &totalEntries, NULL);
|
2003-09-25 22:29:40 +02:00
|
|
|
ok(apiReturn == ERROR_INVALID_LEVEL || apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-08 19:35:50 +02:00
|
|
|
"NetWkstaTransportEnum returned %d\n", apiReturn);
|
2003-04-30 02:48:56 +02:00
|
|
|
|
|
|
|
/* 2nd check: is param 5 passed? (only if level passes?) */
|
2020-01-08 22:23:22 +01:00
|
|
|
apiReturn = NetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH,
|
2003-04-30 02:48:56 +02:00
|
|
|
NULL, &totalEntries, NULL);
|
|
|
|
|
|
|
|
/* if no network adapter present, bail, the rest of the test will fail */
|
|
|
|
if (apiReturn == ERROR_NETWORK_UNREACHABLE)
|
|
|
|
return;
|
|
|
|
|
2003-09-25 22:29:40 +02:00
|
|
|
ok(apiReturn == STATUS_ACCESS_VIOLATION || apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-08 19:35:50 +02:00
|
|
|
"NetWkstaTransportEnum returned %d\n", apiReturn);
|
2003-04-30 02:48:56 +02:00
|
|
|
|
|
|
|
/* 3rd check: is param 3 passed? */
|
2020-01-08 22:23:22 +01:00
|
|
|
apiReturn = NetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH,
|
2003-04-30 02:48:56 +02:00
|
|
|
NULL, NULL, NULL);
|
2005-03-14 11:05:58 +01:00
|
|
|
ok(apiReturn == STATUS_ACCESS_VIOLATION || apiReturn == RPC_X_NULL_REF_POINTER || apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-08 19:35:50 +02:00
|
|
|
"NetWkstaTransportEnum returned %d\n", apiReturn);
|
2003-04-30 02:48:56 +02:00
|
|
|
|
|
|
|
/* 4th check: is param 6 passed? */
|
2020-01-08 22:23:22 +01:00
|
|
|
apiReturn = NetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH,
|
2003-04-30 02:48:56 +02:00
|
|
|
&entriesRead, NULL, NULL);
|
2017-12-20 07:02:06 +01:00
|
|
|
ok(apiReturn == RPC_X_NULL_REF_POINTER,
|
|
|
|
"NetWkstaTransportEnum returned %d\n", apiReturn);
|
2003-04-30 02:48:56 +02:00
|
|
|
|
|
|
|
/* final check: valid return, actually get data back */
|
2020-01-08 22:23:22 +01:00
|
|
|
apiReturn = NetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH,
|
2003-04-30 02:48:56 +02:00
|
|
|
&entriesRead, &totalEntries, NULL);
|
2012-11-13 23:50:15 +01:00
|
|
|
ok(apiReturn == NERR_Success || apiReturn == ERROR_NETWORK_UNREACHABLE || apiReturn == NERR_WkstaNotStarted,
|
2006-10-08 19:35:50 +02:00
|
|
|
"NetWkstaTransportEnum returned %d\n", apiReturn);
|
2003-04-30 02:48:56 +02:00
|
|
|
if (apiReturn == NERR_Success) {
|
|
|
|
/* WKSTA_TRANSPORT_INFO_0 *transports = (WKSTA_TRANSPORT_INFO_0 *)bufPtr; */
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(bufPtr != NULL, "got data back\n");
|
|
|
|
ok(entriesRead > 0, "read at least one transport\n");
|
2009-08-24 14:19:11 +02:00
|
|
|
ok(totalEntries > 0 || broken(totalEntries == 0) /* Win7 */,
|
|
|
|
"at least one transport\n");
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(bufPtr);
|
2003-04-30 02:48:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-10 10:41:50 +02:00
|
|
|
static void run_wkstajoininfo_tests(void)
|
|
|
|
{
|
|
|
|
NET_API_STATUS ret;
|
|
|
|
LPWSTR buffer = NULL;
|
|
|
|
NETSETUP_JOIN_STATUS buffertype = 0xdada;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetGetJoinInformation(NULL, NULL, NULL);
|
2011-06-10 10:41:50 +02:00
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "NetJoinGetInformation returned unexpected 0x%08x\n", ret);
|
|
|
|
ok(buffertype == 0xdada, "buffertype set to unexpected value %d\n", buffertype);
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetGetJoinInformation(NULL, &buffer, &buffertype);
|
2011-06-10 10:41:50 +02:00
|
|
|
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);
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(buffer);
|
2011-06-10 10:41:50 +02:00
|
|
|
}
|
|
|
|
|
2002-09-11 04:35:17 +02:00
|
|
|
START_TEST(wksta)
|
|
|
|
{
|
2020-01-08 22:23:22 +01:00
|
|
|
DWORD size;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
pNetpGetComputerName = (void *)GetProcAddress(GetModuleHandleA("netapi32.dll"), "NetpGetComputerName");
|
|
|
|
|
2020-01-12 21:27:06 +01:00
|
|
|
size = ARRAY_SIZE(user_name);
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = GetUserNameW(user_name, &size);
|
|
|
|
ok(ret, "Failed to get user name, error %u.\n", GetLastError());
|
2020-01-12 21:27:06 +01:00
|
|
|
size = ARRAY_SIZE(computer_name);
|
2020-01-08 22:23:22 +01:00
|
|
|
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();
|
2002-09-11 04:35:17 +02:00
|
|
|
}
|