2002-09-23 22:36:50 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2002 Andriy Palamarchuk
|
|
|
|
*
|
|
|
|
* Conformance test of the access 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-23 22:36:50 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include <windef.h>
|
2002-09-23 22:36:50 +02:00
|
|
|
#include <winbase.h>
|
|
|
|
#include <winerror.h>
|
|
|
|
#include <lmaccess.h>
|
|
|
|
#include <lmerr.h>
|
|
|
|
#include <lmapibuf.h>
|
|
|
|
|
2007-03-19 16:48:39 +01:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
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
|
|
|
|
2020-01-08 22:23:21 +01:00
|
|
|
static WCHAR sTooLongName[] = L"This is a bad username";
|
|
|
|
static WCHAR sTooLongPassword[] = L"abcdefghabcdefghabcdefghabcdefghabcdefgh"
|
|
|
|
"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh"
|
|
|
|
"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh"
|
|
|
|
"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgha";
|
|
|
|
|
|
|
|
static WCHAR sTestUserOldPass[] = L"OldPassW0rdSet!~";
|
2002-09-23 22:36:50 +02:00
|
|
|
|
2015-07-24 10:35:07 +02:00
|
|
|
static DWORD (WINAPI *pDavGetHTTPFromUNCPath)(LPCWSTR,LPWSTR,LPDWORD);
|
2016-10-24 10:04:19 +02:00
|
|
|
static DWORD (WINAPI *pDavGetUNCFromHTTPPath)(LPCWSTR,LPWSTR,LPDWORD);
|
2002-09-23 22:36:50 +02:00
|
|
|
|
2007-03-24 09:02:54 +01:00
|
|
|
static NET_API_STATUS create_test_user(void)
|
|
|
|
{
|
|
|
|
USER_INFO_1 usri;
|
|
|
|
|
2020-01-08 22:23:21 +01:00
|
|
|
usri.usri1_name = (WCHAR *)L"testuser";
|
2007-03-24 09:02:54 +01:00
|
|
|
usri.usri1_password = sTestUserOldPass;
|
|
|
|
usri.usri1_priv = USER_PRIV_USER;
|
|
|
|
usri.usri1_home_dir = NULL;
|
|
|
|
usri.usri1_comment = NULL;
|
|
|
|
usri.usri1_flags = UF_SCRIPT;
|
|
|
|
usri.usri1_script_path = NULL;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
return NetUserAdd(NULL, 1, (BYTE *)&usri, NULL);
|
2007-03-24 09:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static NET_API_STATUS delete_test_user(void)
|
|
|
|
{
|
2020-01-08 22:23:22 +01:00
|
|
|
return NetUserDel(NULL, L"testuser");
|
2007-03-24 09:02:54 +01:00
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void run_usergetinfo_tests(void)
|
2002-09-23 22:36:50 +02:00
|
|
|
{
|
2002-12-19 02:04:12 +01:00
|
|
|
NET_API_STATUS rc;
|
2002-09-23 22:36:50 +02:00
|
|
|
PUSER_INFO_0 ui0 = NULL;
|
|
|
|
PUSER_INFO_10 ui10 = NULL;
|
|
|
|
DWORD dwSize;
|
|
|
|
|
2007-03-24 09:02:54 +01:00
|
|
|
if((rc = create_test_user()) != NERR_Success )
|
|
|
|
{
|
|
|
|
skip("Skipping usergetinfo_tests, create_test_user failed: 0x%08x\n", rc);
|
2007-03-19 09:39:11 +01:00
|
|
|
return;
|
2005-03-25 11:24:45 +01:00
|
|
|
}
|
2007-03-24 09:02:54 +01:00
|
|
|
|
|
|
|
/* Level 0 */
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(NULL, L"testuser", 0, (BYTE **)&ui0);
|
2007-03-24 09:02:54 +01:00
|
|
|
ok(rc == NERR_Success, "NetUserGetInfo level 0 failed: 0x%08x.\n", rc);
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(!wcscmp(L"testuser", ui0->usri0_name), "Got level 0 name %s.\n", debugstr_w(ui0->usri0_name));
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferSize(ui0, &dwSize);
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(dwSize >= (sizeof(USER_INFO_0) + (wcslen(ui0->usri0_name) + 1) * sizeof(WCHAR)),
|
2004-01-27 21:13:03 +01:00
|
|
|
"Is allocated with NetApiBufferAllocate\n");
|
2002-09-23 22:36:50 +02:00
|
|
|
|
|
|
|
/* Level 10 */
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(NULL, L"testuser", 10, (BYTE **)&ui10);
|
2007-03-24 09:02:54 +01:00
|
|
|
ok(rc == NERR_Success, "NetUserGetInfo level 10 failed: 0x%08x.\n", rc);
|
2020-01-08 22:23:21 +01:00
|
|
|
ok(!wcscmp(L"testuser", ui10->usri10_name), "Got level 10 name %s.\n", debugstr_w(ui10->usri10_name));
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferSize(ui10, &dwSize);
|
2002-09-23 22:36:50 +02:00
|
|
|
ok(dwSize >= (sizeof(USER_INFO_10) +
|
2020-01-08 22:23:21 +01:00
|
|
|
(wcslen(ui10->usri10_name) + 1 +
|
|
|
|
wcslen(ui10->usri10_comment) + 1 +
|
|
|
|
wcslen(ui10->usri10_usr_comment) + 1 +
|
|
|
|
wcslen(ui10->usri10_full_name) + 1) * sizeof(WCHAR)),
|
2004-01-27 21:13:03 +01:00
|
|
|
"Is allocated with NetApiBufferAllocate\n");
|
2002-09-23 22:36:50 +02:00
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(ui0);
|
|
|
|
NetApiBufferFree(ui10);
|
2002-09-23 22:36:50 +02:00
|
|
|
|
2008-07-02 12:26:35 +02:00
|
|
|
/* NetUserGetInfo should always work for the current user. */
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(NULL, user_name, 0, (BYTE **)&ui0);
|
2008-07-02 12:26:35 +02:00
|
|
|
ok(rc == NERR_Success, "NetUsetGetInfo for current user failed: 0x%08x.\n", rc);
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(ui0);
|
2008-07-02 12:26:35 +02:00
|
|
|
|
2002-09-23 22:36:50 +02:00
|
|
|
/* errors handling */
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(NULL, L"testuser", 10000, (BYTE **)&ui0);
|
2006-10-08 19:35:50 +02:00
|
|
|
ok(rc == ERROR_INVALID_LEVEL,"Invalid Level: rc=%d\n",rc);
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(NULL, L"Nonexistent User", 0, (BYTE **)&ui0);
|
2006-10-08 19:35:50 +02:00
|
|
|
ok(rc == NERR_UserNotFound,"Invalid User Name: rc=%d\n",rc);
|
2002-09-23 22:36:50 +02:00
|
|
|
todo_wine {
|
|
|
|
/* FIXME - Currently Wine can't verify whether the network path is good or bad */
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(L"\\\\Ba path", L"testuser", 0, (BYTE **)&ui0);
|
2009-11-20 10:12:17 +01:00
|
|
|
ok(rc == ERROR_BAD_NETPATH ||
|
|
|
|
rc == ERROR_NETWORK_UNREACHABLE ||
|
|
|
|
rc == RPC_S_SERVER_UNAVAILABLE ||
|
2012-11-13 23:50:14 +01:00
|
|
|
rc == NERR_WkstaNotStarted || /* workstation service not running */
|
2009-11-20 10:12:17 +01:00
|
|
|
rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */
|
2006-10-08 19:35:50 +02:00
|
|
|
"Bad Network Path: rc=%d\n",rc);
|
2002-09-23 22:36:50 +02:00
|
|
|
}
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(L"", L"testuser", 0, (BYTE **)&ui0);
|
2004-04-05 22:17:45 +02:00
|
|
|
ok(rc == ERROR_BAD_NETPATH || rc == NERR_Success,
|
2006-10-08 19:35:50 +02:00
|
|
|
"Bad Network Path: rc=%d\n",rc);
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(L"\\", L"testuser", 0, (BYTE **)&ui0);
|
2009-08-28 14:54:28 +02:00
|
|
|
ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserGetInfo(L"\\\\", L"testuser", 0, (BYTE **)&ui0);
|
2009-08-28 14:54:28 +02:00
|
|
|
ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
|
2007-03-24 09:02:54 +01:00
|
|
|
|
|
|
|
if(delete_test_user() != NERR_Success)
|
2007-03-28 10:00:58 +02:00
|
|
|
trace("Deleting the test user failed. You might have to manually delete it.\n");
|
2002-09-23 22:36:50 +02:00
|
|
|
}
|
|
|
|
|
2008-10-16 23:53:36 +02:00
|
|
|
/* Checks Level 1 of NetQueryDisplayInformation */
|
2005-06-20 17:35:54 +02:00
|
|
|
static void run_querydisplayinformation1_tests(void)
|
2002-09-23 22:36:50 +02:00
|
|
|
{
|
|
|
|
PNET_DISPLAY_USER Buffer, rec;
|
|
|
|
DWORD Result, EntryCount;
|
|
|
|
DWORD i = 0;
|
|
|
|
BOOL hasAdmin = FALSE;
|
|
|
|
BOOL hasGuest = FALSE;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2020-01-08 22:23:22 +01:00
|
|
|
Result = NetQueryDisplayInformation(
|
2002-09-23 22:36:50 +02:00
|
|
|
NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount,
|
|
|
|
(PVOID *)&Buffer);
|
|
|
|
|
|
|
|
ok((Result == ERROR_SUCCESS) || (Result == ERROR_MORE_DATA),
|
2004-01-27 21:13:03 +01:00
|
|
|
"Information Retrieved\n");
|
2002-09-23 22:36:50 +02:00
|
|
|
rec = Buffer;
|
|
|
|
for(; EntryCount > 0; EntryCount--)
|
|
|
|
{
|
2008-10-16 23:53:36 +02:00
|
|
|
if (rec->usri1_user_id == DOMAIN_USER_RID_ADMIN)
|
2002-09-23 22:36:50 +02:00
|
|
|
{
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(!hasAdmin, "One admin user\n");
|
|
|
|
ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set\n");
|
|
|
|
ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set\n");
|
2002-09-23 22:36:50 +02:00
|
|
|
hasAdmin = TRUE;
|
|
|
|
}
|
2008-10-16 23:53:36 +02:00
|
|
|
else if (rec->usri1_user_id == DOMAIN_USER_RID_GUEST)
|
2002-09-23 22:36:50 +02:00
|
|
|
{
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(!hasGuest, "One guest record\n");
|
|
|
|
ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set\n");
|
|
|
|
ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set\n");
|
2002-09-23 22:36:50 +02:00
|
|
|
hasGuest = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = rec->usri1_next_index;
|
|
|
|
rec++;
|
|
|
|
}
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(Buffer);
|
2002-09-23 22:36:50 +02:00
|
|
|
} while (Result == ERROR_MORE_DATA);
|
|
|
|
|
2008-08-27 13:19:01 +02:00
|
|
|
ok(hasAdmin, "Doesn't have 'Administrator' account\n");
|
2002-09-23 22:36:50 +02:00
|
|
|
}
|
|
|
|
|
2006-04-22 16:22:48 +02:00
|
|
|
static void run_usermodalsget_tests(void)
|
|
|
|
{
|
|
|
|
NET_API_STATUS rc;
|
|
|
|
USER_MODALS_INFO_2 * umi2 = NULL;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
rc = NetUserModalsGet(NULL, 2, (BYTE **)&umi2);
|
2006-10-08 19:35:50 +02:00
|
|
|
ok(rc == ERROR_SUCCESS, "NetUserModalsGet failed, rc = %d\n", rc);
|
2006-04-22 16:22:48 +02:00
|
|
|
|
|
|
|
if (umi2)
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(umi2);
|
2006-04-22 16:22:48 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 16:48:39 +01:00
|
|
|
static void run_userhandling_tests(void)
|
|
|
|
{
|
|
|
|
NET_API_STATUS ret;
|
|
|
|
USER_INFO_1 usri;
|
|
|
|
|
|
|
|
usri.usri1_priv = USER_PRIV_USER;
|
|
|
|
usri.usri1_home_dir = NULL;
|
|
|
|
usri.usri1_comment = NULL;
|
|
|
|
usri.usri1_flags = UF_SCRIPT;
|
|
|
|
usri.usri1_script_path = NULL;
|
|
|
|
|
2007-03-24 09:00:34 +01:00
|
|
|
usri.usri1_name = sTooLongName;
|
|
|
|
usri.usri1_password = sTestUserOldPass;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL);
|
|
|
|
if (ret == ERROR_ACCESS_DENIED)
|
2009-02-12 21:36:27 +01:00
|
|
|
{
|
|
|
|
skip("not enough permissions to add a user\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-02-14 14:35:47 +01:00
|
|
|
else
|
2020-01-08 22:23:22 +01:00
|
|
|
ok(ret == NERR_BadUsername, "Got %u.\n", ret);
|
2007-03-24 09:00:34 +01:00
|
|
|
|
2020-01-08 22:23:21 +01:00
|
|
|
usri.usri1_name = (WCHAR *)L"testuser";
|
2007-03-24 09:00:34 +01:00
|
|
|
usri.usri1_password = sTooLongPassword;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL);
|
2009-02-12 21:36:27 +01:00
|
|
|
ok(ret == NERR_PasswordTooShort || ret == ERROR_ACCESS_DENIED /* Win2003 */,
|
|
|
|
"Adding user with too long password returned 0x%08x\n", ret);
|
2007-03-24 09:00:34 +01:00
|
|
|
|
|
|
|
usri.usri1_name = sTooLongName;
|
|
|
|
usri.usri1_password = sTooLongPassword;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL);
|
2008-02-14 14:35:47 +01:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
ok(ret == NERR_BadUsername || ret == NERR_PasswordTooShort,
|
2007-03-24 09:00:34 +01:00
|
|
|
"Adding user with too long username/password returned 0x%08x\n", ret);
|
|
|
|
|
2020-01-08 22:23:21 +01:00
|
|
|
usri.usri1_name = (WCHAR *)L"testuser";
|
2007-03-24 09:00:34 +01:00
|
|
|
usri.usri1_password = sTestUserOldPass;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetUserAdd(NULL, 5, (BYTE *)&usri, NULL);
|
2007-03-24 09:01:13 +01:00
|
|
|
ok(ret == ERROR_INVALID_LEVEL, "Adding user with level 5 returned 0x%08x\n", ret);
|
2007-03-24 09:00:34 +01:00
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetUserAdd(NULL, 1, (BYTE *)&usri, NULL);
|
2007-03-19 16:48:39 +01:00
|
|
|
if(ret == ERROR_ACCESS_DENIED)
|
|
|
|
{
|
|
|
|
skip("Insufficient permissions to add users. Skipping test.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(ret == NERR_UserExists)
|
|
|
|
{
|
|
|
|
skip("User already exists, skipping test to not mess up the system\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ok(!ret, "Got %u.\n", ret);
|
2007-03-19 16:48:39 +01:00
|
|
|
|
2008-06-24 19:29:19 +02:00
|
|
|
/* On Windows XP (and newer), calling NetUserChangePassword with a NULL
|
|
|
|
* domainname parameter creates a user home directory, iff the machine is
|
|
|
|
* not member of a domain.
|
2008-06-27 11:45:18 +02:00
|
|
|
* Using \\127.0.0.1 as domain name does not work on standalone machines
|
|
|
|
* either, unless the ForceGuest option in the registry is turned off.
|
|
|
|
* So let's not test NetUserChangePassword for now.
|
2008-06-24 19:29:19 +02:00
|
|
|
*/
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetUserDel(NULL, L"testuser");
|
2007-03-24 09:01:32 +01:00
|
|
|
ok(ret == NERR_Success, "Deleting the user failed.\n");
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
ret = NetUserDel(NULL, L"testuser");
|
2007-03-24 09:01:32 +01:00
|
|
|
ok(ret == NERR_UserNotFound, "Deleting a nonexistent user returned 0x%08x\n",ret);
|
2007-03-19 16:48:39 +01:00
|
|
|
}
|
|
|
|
|
2011-06-05 09:58:33 +02:00
|
|
|
static void run_localgroupgetinfo_tests(void)
|
|
|
|
{
|
|
|
|
NET_API_STATUS status;
|
|
|
|
PLOCALGROUP_INFO_1 lgi = NULL;
|
|
|
|
PLOCALGROUP_MEMBERS_INFO_3 buffer = NULL;
|
|
|
|
DWORD entries_read = 0, total_entries =0;
|
|
|
|
int i;
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
status = NetLocalGroupGetInfo(NULL, L"Administrators", 1, (BYTE **)&lgi);
|
2011-07-15 09:59:26 +02:00
|
|
|
ok(status == NERR_Success || broken(status == NERR_GroupNotFound),
|
|
|
|
"NetLocalGroupGetInfo unexpectedly returned %d\n", status);
|
|
|
|
if (status != NERR_Success) return;
|
2011-06-05 09:58:33 +02:00
|
|
|
|
|
|
|
trace("Local groupname:%s\n", wine_dbgstr_w( lgi->lgrpi1_name));
|
|
|
|
trace("Comment: %s\n", wine_dbgstr_w( lgi->lgrpi1_comment));
|
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(lgi);
|
2011-06-05 09:58:33 +02:00
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
status = NetLocalGroupGetMembers(NULL, L"Administrators", 3, (BYTE **)&buffer,
|
2020-01-08 22:23:21 +01:00
|
|
|
MAX_PREFERRED_LENGTH, &entries_read, &total_entries, NULL);
|
2011-06-05 09:58:33 +02:00
|
|
|
ok(status == NERR_Success, "NetLocalGroupGetMembers unexpectedly returned %d\n", status);
|
|
|
|
ok(entries_read > 0 && total_entries > 0, "Amount of entries is unexpectedly 0\n");
|
|
|
|
|
|
|
|
for(i=0;i<entries_read;i++)
|
|
|
|
trace("domain and name: %s\n", wine_dbgstr_w(buffer[i].lgrmi3_domainandname));
|
2015-03-21 04:05:40 +01:00
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
NetApiBufferFree(buffer);
|
2011-06-05 09:58:33 +02:00
|
|
|
}
|
|
|
|
|
2015-07-24 10:35:07 +02:00
|
|
|
static void test_DavGetHTTPFromUNCPath(void)
|
|
|
|
{
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const WCHAR *path;
|
2020-01-08 22:23:20 +01:00
|
|
|
DWORD ret;
|
2015-07-24 10:35:07 +02:00
|
|
|
const WCHAR *ret_path;
|
2020-01-08 22:23:20 +01:00
|
|
|
DWORD broken_ret; /* < Win10 1709 */
|
|
|
|
BOOL todo;
|
2015-07-24 10:35:07 +02:00
|
|
|
}
|
|
|
|
tests[] =
|
|
|
|
{
|
2020-01-08 22:23:20 +01:00
|
|
|
{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"},
|
|
|
|
{L"\\\\a\\", ERROR_SUCCESS, L"http://a"},
|
|
|
|
{L"\\\\a\\b", ERROR_SUCCESS, L"http://a/b"},
|
|
|
|
{L"\\\\a\\b\\", ERROR_SUCCESS, L"http://a/b"},
|
|
|
|
{L"\\\\a\\b\\c", ERROR_SUCCESS, L"http://a/b/c"},
|
|
|
|
{L"\\\\a@SSL\\b", ERROR_SUCCESS, L"https://a/b"},
|
|
|
|
{L"\\\\a@ssl\\b", ERROR_SUCCESS, L"https://a/b"},
|
|
|
|
{L"\\\\a@tls\\b", ERROR_INVALID_PARAMETER},
|
|
|
|
{L"\\\\a@SSL@443\\b", ERROR_SUCCESS, L"https://a/b"},
|
|
|
|
{L"\\\\a@SSL@80\\b", ERROR_SUCCESS, L"https://a:80/b"},
|
|
|
|
{L"\\\\a@80@SSL\\b", ERROR_INVALID_PARAMETER},
|
|
|
|
{L"\\\\a@80\\b", ERROR_SUCCESS, L"http://a/b"},
|
|
|
|
{L"\\\\a@8080\\b", ERROR_SUCCESS, L"http://a:8080/b"},
|
|
|
|
{L"\\\\a\\b/", ERROR_SUCCESS, L"http://a/b"},
|
|
|
|
{L"\\\\a/b", ERROR_SUCCESS, L"http://a/b"},
|
|
|
|
{L"\\\\a.\\b", ERROR_SUCCESS, L"http://a./b"},
|
|
|
|
{L"\\\\.a\\b", ERROR_SUCCESS, L"http://.a/b"},
|
|
|
|
{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},
|
2015-07-24 10:35:07 +02:00
|
|
|
};
|
|
|
|
WCHAR buf[MAX_PATH];
|
|
|
|
DWORD i, ret, size;
|
|
|
|
|
|
|
|
if (!pDavGetHTTPFromUNCPath)
|
|
|
|
{
|
|
|
|
win_skip( "DavGetHTTPFromUNCPath is missing\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-08 22:23:20 +01:00
|
|
|
if (0) /* crashes on Windows */
|
|
|
|
{
|
|
|
|
ret = pDavGetHTTPFromUNCPath(NULL, NULL, NULL);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
|
2015-07-24 10:35:07 +02:00
|
|
|
|
2020-01-08 22:23:20 +01:00
|
|
|
size = 0;
|
|
|
|
ret = pDavGetHTTPFromUNCPath(L"", buf, &size);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
|
2015-07-24 10:35:07 +02:00
|
|
|
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetHTTPFromUNCPath(L"\\\\a\\b", buf, NULL);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
|
|
|
|
}
|
2015-07-24 10:35:07 +02:00
|
|
|
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetHTTPFromUNCPath(L"", buf, NULL);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
|
2015-07-24 10:35:07 +02:00
|
|
|
|
2020-01-08 22:23:20 +01:00
|
|
|
size = 0;
|
|
|
|
ret = pDavGetHTTPFromUNCPath(L"", NULL, &size);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER || ret == ERROR_BAD_NET_NAME /* Win10 1709+ */, "got %u\n", ret);
|
2015-07-24 10:35:07 +02:00
|
|
|
|
|
|
|
size = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetHTTPFromUNCPath(L"\\\\a\\b", NULL, &size);
|
|
|
|
ok(ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret);
|
2015-07-24 10:35:07 +02:00
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
size = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetHTTPFromUNCPath(L"\\\\a\\b", buf, &size);
|
|
|
|
ok(ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret);
|
|
|
|
ok(size == 11, "got %u\n", size);
|
2015-07-24 10:35:07 +02:00
|
|
|
|
2018-06-06 00:38:37 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
2015-07-24 10:35:07 +02:00
|
|
|
{
|
|
|
|
buf[0] = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
size = ARRAY_SIZE(buf);
|
2015-07-24 10:35:07 +02:00
|
|
|
ret = pDavGetHTTPFromUNCPath( tests[i].path, buf, &size );
|
2020-01-08 22:23:20 +01:00
|
|
|
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)
|
2015-07-24 10:35:07 +02:00
|
|
|
{
|
|
|
|
if (tests[i].ret_path)
|
2020-01-08 22:23:20 +01:00
|
|
|
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: got %u\n", i, size);
|
2015-07-24 10:35:07 +02:00
|
|
|
}
|
|
|
|
else
|
2020-01-08 22:23:20 +01:00
|
|
|
ok(size == ARRAY_SIZE(buf), "%u: wrong size %u\n", i, size);
|
2015-07-24 10:35:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 22:23:20 +01:00
|
|
|
|
2016-10-24 10:04:19 +02:00
|
|
|
static void test_DavGetUNCFromHTTPPath(void)
|
|
|
|
{
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const WCHAR *path;
|
2020-01-08 22:23:20 +01:00
|
|
|
DWORD ret;
|
2016-10-24 10:04:19 +02:00
|
|
|
const WCHAR *ret_path;
|
2020-01-08 22:23:20 +01:00
|
|
|
DWORD broken_ret; /* < Win10 1709 */
|
|
|
|
BOOL todo;
|
2016-10-24 10:04:19 +02:00
|
|
|
}
|
|
|
|
tests[] =
|
|
|
|
{
|
2020-01-08 22:23:20 +01:00
|
|
|
{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"},
|
2016-10-24 10:04:19 +02:00
|
|
|
};
|
|
|
|
WCHAR buf[MAX_PATH];
|
|
|
|
DWORD i, ret, size;
|
|
|
|
|
|
|
|
if (!pDavGetUNCFromHTTPPath)
|
|
|
|
{
|
|
|
|
win_skip( "DavGetUNCFromHTTPPath is missing\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-08 22:23:20 +01:00
|
|
|
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);
|
2016-10-24 10:04:19 +02:00
|
|
|
}
|
2020-01-08 22:23:20 +01:00
|
|
|
|
|
|
|
ret = pDavGetUNCFromHTTPPath(L"", buf, NULL);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
|
2016-10-24 10:04:19 +02:00
|
|
|
|
|
|
|
size = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetUNCFromHTTPPath(L"", NULL, &size);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
|
2016-10-24 10:04:19 +02:00
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
size = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetUNCFromHTTPPath(L"", buf, &size);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %u\n", ret);
|
2016-10-24 10:04:19 +02:00
|
|
|
|
|
|
|
size = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetUNCFromHTTPPath(L"http://server/path", NULL, &size);
|
2016-10-24 10:04:19 +02:00
|
|
|
ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
size = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
ret = pDavGetUNCFromHTTPPath(L"http://server/path", buf, &size);
|
|
|
|
ok(ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret);
|
|
|
|
ok(size == 25, "got %u\n", size);
|
2016-10-24 10:04:19 +02:00
|
|
|
|
2018-06-06 00:38:37 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(tests); i++)
|
2016-10-24 10:04:19 +02:00
|
|
|
{
|
|
|
|
buf[0] = 0;
|
2020-01-08 22:23:20 +01:00
|
|
|
size = ARRAY_SIZE(buf);
|
2016-10-24 10:04:19 +02:00
|
|
|
ret = pDavGetUNCFromHTTPPath( tests[i].path, buf, &size );
|
2020-01-08 22:23:20 +01:00
|
|
|
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)
|
2016-10-24 10:04:19 +02:00
|
|
|
{
|
2020-01-08 22:23:20 +01:00
|
|
|
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: got %u\n", i, size);
|
2016-10-24 10:04:19 +02:00
|
|
|
}
|
2020-01-08 22:23:20 +01:00
|
|
|
else
|
|
|
|
ok(size == ARRAY_SIZE(buf), "%u: wrong size %u\n", i, size);
|
2016-10-24 10:04:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-23 22:36:50 +02:00
|
|
|
START_TEST(access)
|
|
|
|
{
|
2020-01-08 22:23:22 +01:00
|
|
|
HMODULE hnetapi32 = GetModuleHandleA("netapi32.dll");
|
|
|
|
DWORD size;
|
|
|
|
BOOL ret;
|
|
|
|
|
2015-07-24 10:35:07 +02:00
|
|
|
pDavGetHTTPFromUNCPath = (void*)GetProcAddress(hnetapi32, "DavGetHTTPFromUNCPath");
|
2016-10-24 10:04:19 +02:00
|
|
|
pDavGetUNCFromHTTPPath = (void*)GetProcAddress(hnetapi32, "DavGetUNCFromHTTPPath");
|
2006-04-22 16:22:48 +02:00
|
|
|
|
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());
|
2002-12-19 02:04:12 +01:00
|
|
|
|
2020-01-08 22:23:22 +01:00
|
|
|
run_userhandling_tests();
|
|
|
|
run_usergetinfo_tests();
|
|
|
|
run_querydisplayinformation1_tests();
|
|
|
|
run_usermodalsget_tests();
|
|
|
|
run_localgroupgetinfo_tests();
|
2007-03-23 11:32:36 +01:00
|
|
|
|
2015-07-24 10:35:07 +02:00
|
|
|
test_DavGetHTTPFromUNCPath();
|
2016-10-24 10:04:19 +02:00
|
|
|
test_DavGetUNCFromHTTPPath();
|
2002-09-23 22:36:50 +02:00
|
|
|
}
|