1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
/*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <lmaccess.h>
#include <lmerr.h>
#include <lmapibuf.h>
#include "wine/test.h"
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 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 BOOL init_access_tests(void)
{
DWORD dwSize;
BOOL rc;
user_name[0] = 0;
dwSize = sizeof(user_name)/sizeof(WCHAR);
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 = sizeof(computer_name)/sizeof(WCHAR);
ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved\n");
return TRUE;
}
static NET_API_STATUS create_test_user(void)
{
USER_INFO_1 usri;
usri.usri1_name = sTestUserName;
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;
return pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL);
}
static NET_API_STATUS delete_test_user(void)
{
return pNetUserDel(NULL, sTestUserName);
}
static void run_usergetinfo_tests(void)
{
NET_API_STATUS rc;
PUSER_INFO_0 ui0 = NULL;
PUSER_INFO_10 ui10 = NULL;
DWORD dwSize;
if((rc = create_test_user()) != NERR_Success )
{
skip("Skipping usergetinfo_tests, create_test_user failed: 0x%08x\n", rc);
return;
}
/* Level 0 */
rc=pNetUserGetInfo(NULL, sTestUserName, 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");
pNetApiBufferSize(ui0, &dwSize);
ok(dwSize >= (sizeof(USER_INFO_0) +
(lstrlenW(ui0->usri0_name) + 1) * sizeof(WCHAR)),
"Is allocated with NetApiBufferAllocate\n");
/* Level 10 */
rc=pNetUserGetInfo(NULL, sTestUserName, 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");
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)),
"Is allocated with NetApiBufferAllocate\n");
pNetApiBufferFree(ui0);
pNetApiBufferFree(ui10);
/* NetUserGetInfo should always work for the current user. */
rc=pNetUserGetInfo(NULL, user_name, 0, (LPBYTE*)&ui0);
ok(rc == NERR_Success, "NetUsetGetInfo for current user failed: 0x%08x.\n", rc);
pNetApiBufferFree(ui0);
/* errors handling */
rc=pNetUserGetInfo(NULL, sTestUserName, 10000, (LPBYTE *)&ui0);
ok(rc == ERROR_INVALID_LEVEL,"Invalid Level: rc=%d\n",rc);
rc=pNetUserGetInfo(NULL, sNonexistentUser, 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);
ok(rc == ERROR_BAD_NETPATH ||
rc == ERROR_NETWORK_UNREACHABLE ||
rc == RPC_S_SERVER_UNAVAILABLE ||
rc == NERR_WkstaNotStarted || /* workstation service not running */
rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */
"Bad Network Path: rc=%d\n",rc);
}
rc=pNetUserGetInfo(sEmptyStr, sTestUserName, 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);
ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
rc=pNetUserGetInfo(sInvalidName2, sTestUserName, 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)
trace("Deleting the test user failed. You might have to manually delete it.\n");
}
/* Checks Level 1 of NetQueryDisplayInformation */
static void run_querydisplayinformation1_tests(void)
{
PNET_DISPLAY_USER Buffer, rec;
DWORD Result, EntryCount;
DWORD i = 0;
BOOL hasAdmin = FALSE;
BOOL hasGuest = FALSE;
do
{
Result = pNetQueryDisplayInformation(
NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount,
(PVOID *)&Buffer);
ok((Result == ERROR_SUCCESS) || (Result == ERROR_MORE_DATA),
"Information Retrieved\n");
rec = Buffer;
for(; EntryCount > 0; EntryCount--)
{
if (rec->usri1_user_id == DOMAIN_USER_RID_ADMIN)
{
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");
hasAdmin = TRUE;
}
else if (rec->usri1_user_id == DOMAIN_USER_RID_GUEST)
{
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");
hasGuest = TRUE;
}
i = rec->usri1_next_index;
rec++;
}
pNetApiBufferFree(Buffer);
} while (Result == ERROR_MORE_DATA);
ok(hasAdmin, "Doesn't have 'Administrator' account\n");
}
static void run_usermodalsget_tests(void)
{
NET_API_STATUS rc;
USER_MODALS_INFO_2 * umi2 = NULL;
rc = pNetUserModalsGet(NULL, 2, (LPBYTE *)&umi2);
ok(rc == ERROR_SUCCESS, "NetUserModalsGet failed, rc = %d\n", rc);
if (umi2)
pNetApiBufferFree(umi2);
}
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;
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)
{
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);
usri.usri1_name = sTestUserName;
usri.usri1_password = sTooLongPassword;
ret = pNetUserAdd(NULL, 1, (LPBYTE)&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);
/* 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,
"Adding user with too long username/password returned 0x%08x\n", ret);
usri.usri1_name = sTestUserName;
usri.usri1_password = sTestUserOldPass;
ret = pNetUserAdd(NULL, 5, (LPBYTE)&usri, NULL);
ok(ret == ERROR_INVALID_LEVEL, "Adding user with level 5 returned 0x%08x\n", ret);
ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL);
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;
}
ok(ret == NERR_Success ||
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
* domainname parameter creates a user home directory, iff the machine is
* not member of a domain.
* 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.
*/
ret = pNetUserDel(NULL, sTestUserName);
ok(ret == NERR_Success, "Deleting the user failed.\n");
ret = pNetUserDel(NULL, sTestUserName);
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);
ok(status == NERR_Success || broken(status == NERR_GroupNotFound),
"NetLocalGroupGetInfo unexpectedly returned %d\n", status);
if (status != NERR_Success) return;
trace("Local groupname:%s\n", wine_dbgstr_w( lgi->lgrpi1_name));
trace("Comment: %s\n", wine_dbgstr_w( lgi->lgrpi1_comment));
pNetApiBufferFree(lgi);
status = pNetLocalGroupGetMembers(NULL, admins, 3, (LPBYTE *)&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");
for(i=0;i<entries_read;i++)
trace("domain and name: %s\n", wine_dbgstr_w(buffer[i].lgrmi3_domainandname));
pNetApiBufferFree(buffer);
}
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;
const WCHAR *ret_path;
DWORD ret_size;
int 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 },
};
WCHAR buf[MAX_PATH];
DWORD i, ret, size;
if (!pDavGetHTTPFromUNCPath)
{
win_skip( "DavGetHTTPFromUNCPath is missing\n" );
return;
}
if (0) { /* crash */
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( path, NULL, &size );
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( path3, buf, NULL );
ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
}
size = 0;
ret = pDavGetHTTPFromUNCPath( path3, 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 );
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
{
buf[0] = 0;
size = tests[i].size;
ret = pDavGetHTTPFromUNCPath( tests[i].path, buf, &size );
if (tests[i].todo)
{
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 );
}
}
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 );
}
}
}
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");
pDavGetHTTPFromUNCPath = (void*)GetProcAddress(hnetapi32, "DavGetHTTPFromUNCPath");
/* 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_access_tests()) {
run_userhandling_tests();
run_usergetinfo_tests();
run_querydisplayinformation1_tests();
run_usermodalsget_tests();
run_localgroupgetinfo_tests();
}
test_DavGetHTTPFromUNCPath();
FreeLibrary(hnetapi32);
}