wininet: Use passive mode for the ftp tests.
[wine/multimedia.git] / dlls / wininet / tests / ftp.c
blob7aa42db251d7319987735dcf6eafbe579a83dfd6
1 /*
2 * Wininet - ftp tests
4 * Copyright 2007 Paul Vriens
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * FIXME:
23 * Use InternetGetLastResponseInfo when the last error is set to ERROR_INTERNET_EXTENDED_ERROR.
24 * TODO:
25 * Add W-function tests.
26 * Add missing function tests:
27 * FtpCommand
28 * FtpFindFirstFile
29 * FtpGetCurrentDirectory
30 * FtpGetFileSize
31 * FtpSetCurrentDirectory
34 #include <stdarg.h>
35 #include <stdio.h>
36 #include <stdlib.h>
38 #include "windef.h"
39 #include "winbase.h"
40 #include "wininet.h"
41 #include "winsock.h"
43 #include "wine/test.h"
45 static void test_getfile_no_open(void)
47 BOOL bRet;
49 /* Invalid internet handle, the others are valid parameters */
50 SetLastError(0xdeadbeef);
51 bRet = FtpGetFileA(NULL, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
52 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
53 ok ( GetLastError() == ERROR_INTERNET_NOT_INITIALIZED ||
54 GetLastError() == ERROR_INVALID_HANDLE,
55 "Expected ERROR_INTERNET_NOT_INITIALIZED or ERROR_INVALID_HANDLE (win98), got %d\n", GetLastError());
58 static void test_connect(void)
60 HINTERNET hInternet, hFtp;
62 SetLastError(0xdeadbeef);
63 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
64 ok(hInternet != NULL, "InternetOpen failed : %d\n", GetLastError());
66 if(!hInternet)
68 skip("No internet connection could be made\n");
69 return;
72 /* Try a few username/password combinations:
73 * anonymous : NULL
74 * NULL : IEUser@
75 * NULL : NULL
78 SetLastError(0xdeadbeef);
79 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", NULL, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
80 if (hFtp) /* some servers accept an empty password */
82 ok ( GetLastError() == ERROR_SUCCESS, "ERROR_SUCCESS, got %d\n", GetLastError());
83 InternetCloseHandle(hFtp);
85 else
86 ok ( GetLastError() == ERROR_INTERNET_LOGIN_FAILURE,
87 "Expected ERROR_INTERNET_LOGIN_FAILURE, got %d\n", GetLastError());
89 SetLastError(0xdeadbeef);
90 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, NULL, "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
91 ok ( hFtp == NULL, "Expected InternetConnect to fail\n");
92 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
93 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
95 /* Using a NULL username and password will be interpreted as anonymous ftp. The username will be 'anonymous' the password
96 * is created via some simple heuristics (see dlls/wininet/ftp.c).
97 * On Wine this registry key is not set by default so (NULL, NULL) will result in anonymous ftp with an (most likely) not
98 * accepted password (the username).
99 * If the first call fails because we get an ERROR_INTERNET_LOGIN_FAILURE, we try again with a (more) correct password.
102 SetLastError(0xdeadbeef);
103 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, NULL, NULL, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
104 if (!hFtp && (GetLastError() == ERROR_INTERNET_LOGIN_FAILURE))
106 /* We are most likely running on a clean Wine install or a Windows install where the registry key is removed */
107 SetLastError(0xdeadbeef);
108 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
110 ok ( hFtp != NULL, "InternetConnect failed : %d\n", GetLastError());
111 ok ( GetLastError() == ERROR_SUCCESS,
112 "ERROR_SUCCESS, got %d\n", GetLastError());
114 InternetCloseHandle(hFtp);
115 InternetCloseHandle(hInternet);
118 static void test_createdir(void)
120 BOOL bRet;
121 HINTERNET hInternet, hFtp, hConnect;
123 /* Invalid internet handle, the other is a valid parameter */
124 SetLastError(0xdeadbeef);
125 bRet = FtpCreateDirectoryA(NULL, "new_directory_deadbeef");
126 ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
127 ok ( GetLastError() == ERROR_INVALID_HANDLE,
128 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
130 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
131 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
132 if(!hFtp)
134 skip("No ftp connection could be made to ftp.winehq.org\n");
135 InternetCloseHandle(hInternet);
136 return;
139 /* We should have a ftp-connection (valid ftp session handle), try some creating */
141 /* No directory-name */
142 SetLastError(0xdeadbeef);
143 bRet = FtpCreateDirectoryA(hFtp, NULL);
144 ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
145 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
146 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
148 /* Parameters are OK, but we shouldn't be allowed to create the directory */
149 SetLastError(0xdeadbeef);
150 bRet = FtpCreateDirectoryA(hFtp, "new_directory_deadbeef");
151 ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
152 todo_wine
153 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
154 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
156 InternetCloseHandle(hFtp);
158 /* Http handle-type for ftp connection */
160 hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_PASSIVE, 0);
162 /* One small test to show that handle type is checked before parameters */
163 SetLastError(0xdeadbeef);
164 bRet = FtpCreateDirectoryA(hConnect, NULL);
165 ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
166 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
167 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
169 SetLastError(0xdeadbeef);
170 bRet = FtpCreateDirectoryA(hConnect, "new_directory_deadbeef");
171 ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
172 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
173 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
175 InternetCloseHandle(hConnect);
176 InternetCloseHandle(hInternet);
179 static void test_deletefile(void)
181 BOOL bRet;
182 HINTERNET hInternet, hFtp, hConnect;
184 /* Invalid internet handle, the other is a valid parameter */
185 SetLastError(0xdeadbeef);
186 bRet = FtpDeleteFileA(NULL, "non_existent_file_deadbeef");
187 ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
188 ok ( GetLastError() == ERROR_INVALID_HANDLE,
189 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
191 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
192 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
193 if(!hFtp)
195 skip("No ftp connection could be made to ftp.winehq.org\n");
196 InternetCloseHandle(hInternet);
197 return;
200 /* We should have a ftp-connection, try some deleting */
202 /* No filename */
203 SetLastError(0xdeadbeef);
204 bRet = FtpDeleteFileA(hFtp, NULL);
205 ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
206 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
207 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
209 /* Parameters are OK but remote file should not be there */
210 SetLastError(0xdeadbeef);
211 bRet = FtpDeleteFileA(hFtp, "non_existent_file_deadbeef");
212 ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
213 todo_wine
214 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
215 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
217 InternetCloseHandle(hFtp);
219 /* Http handle-type for ftp connection */
221 hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_PASSIVE, 0);
223 /* One small test to show that handle type is checked before parameters */
224 SetLastError(0xdeadbeef);
225 bRet = FtpDeleteFileA(hConnect, NULL);
226 ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
227 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
228 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
230 SetLastError(0xdeadbeef);
231 bRet = FtpDeleteFileA(hConnect, "non_existent_file_deadbeef");
232 ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
233 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
234 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
236 InternetCloseHandle(hConnect);
237 InternetCloseHandle(hInternet);
240 static void test_getfile(void)
242 BOOL bRet;
243 HINTERNET hInternet, hFtp, hConnect;
244 HANDLE hFile;
246 /* The order of checking is:
248 * All parameters except 'session handle' and 'condition flags'
249 * Session handle
250 * Session handle type
251 * Condition flags
254 /* Test to show the parameter checking order depends on the Windows version */
255 SetLastError(0xdeadbeef);
256 bRet = FtpGetFileA(NULL, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
257 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
258 ok ( GetLastError() == ERROR_INVALID_HANDLE ||
259 GetLastError() == ERROR_INVALID_PARAMETER,
260 "Expected ERROR_INVALID_HANDLE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
262 /* Test to show session handle is checked before 'condition flags' */
263 SetLastError(0xdeadbeef);
264 bRet = FtpGetFileA(NULL, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0);
265 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
266 ok ( GetLastError() == ERROR_INVALID_HANDLE,
267 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
269 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
270 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
271 if(!hFtp)
273 skip("No ftp connection could be made to ftp.winehq.org\n");
274 InternetCloseHandle(hInternet);
275 return;
278 /* Make sure we start clean */
280 DeleteFileA("should_be_non_existing_deadbeef");
281 DeleteFileA("should_also_be_non_existing_deadbeef");
283 /* We should have a ftp-connection, try some getting */
285 /* No remote file */
286 SetLastError(0xdeadbeef);
287 bRet = FtpGetFileA(hFtp, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
288 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
289 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
290 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
291 ok (GetFileAttributesA("should_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
292 "Local file should not have been created\n");
293 DeleteFileA("should_be_non_existing_deadbeef");
295 /* No local file */
296 SetLastError(0xdeadbeef);
297 bRet = FtpGetFileA(hFtp, "welcome.msg", NULL, FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
298 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
299 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
300 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
302 /* Zero attributes */
303 SetLastError(0xdeadbeef);
304 bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0);
305 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
306 todo_wine
308 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
309 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
310 ok (GetFileAttributesA("should_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
311 "Local file should not have been created\n");
313 DeleteFileA("should_be_non_existing_deadbeef");
315 /* Illegal condition flags */
316 SetLastError(0xdeadbeef);
317 bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 0xffffffff, 0);
318 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
319 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR || GetLastError() == ERROR_INVALID_PARAMETER,
320 "Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_INVALID_PARAMETER (win98), got %d\n", GetLastError());
321 ok (GetFileAttributesA("should_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
322 "Local file should not have been created\n");
323 DeleteFileA("should_be_non_existing_deadbeef");
325 /* Remote file doesn't exist (and local doesn't exist as well) */
326 SetLastError(0xdeadbeef);
327 bRet = FtpGetFileA(hFtp, "should_be_non_existing_deadbeef", "should_also_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
328 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
329 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
330 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
331 /* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
332 todo_wine
333 ok (GetFileAttributesA("should_also_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
334 "Local file should not have been created\n");
335 DeleteFileA("should_also_be_non_existing_deadbeef");
337 /* Same call as the previous but now the local file does exists. Windows just removes the file if the call fails
338 * even if the local existed before!
341 /* Create a temporary local file */
342 SetLastError(0xdeadbeef);
343 hFile = CreateFileA("should_also_be_non_existing_deadbeef", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
344 ok ( hFile != NULL, "Error creating a local file : %d\n", GetLastError());
345 CloseHandle(hFile);
346 SetLastError(0xdeadbeef);
347 bRet = FtpGetFileA(hFtp, "should_be_non_existing_deadbeef", "should_also_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
348 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
349 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
350 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
351 /* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
352 todo_wine
353 ok (GetFileAttributesA("should_also_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
354 "Local file should not have been created\n");
355 DeleteFileA("should_also_be_non_existing_deadbeef");
357 /* This one should fail */
358 SetLastError(0xdeadbeef);
359 bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
360 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
361 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
362 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
364 if (GetFileAttributesA("should_be_non_existing_deadbeef") != INVALID_FILE_ATTRIBUTES)
366 /* Should succeed as fFailIfExists is set to FALSE (meaning don't fail if local file exists) */
367 SetLastError(0xdeadbeef);
368 bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
369 todo_wine
371 ok ( bRet == TRUE, "Expected FtpGetFileA to succeed\n");
372 ok ( GetLastError() == ERROR_SUCCESS,
373 "Expected ERROR_SUCCESS, got %d\n", GetLastError());
376 /* Should fail as fFailIfExists is set to TRUE */
377 SetLastError(0xdeadbeef);
378 bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", TRUE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
379 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
380 ok ( GetLastError() == ERROR_FILE_EXISTS,
381 "Expected ERROR_FILE_EXISTS, got %d\n", GetLastError());
383 /* Prove that the existence of the local file is checked first (or at least reported last) */
384 SetLastError(0xdeadbeef);
385 bRet = FtpGetFileA(hFtp, "should_be_non_existing_deadbeef", "should_be_non_existing_deadbeef", TRUE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
386 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
387 ok ( GetLastError() == ERROR_FILE_EXISTS,
388 "Expected ERROR_FILE_EXISTS, got %d\n", GetLastError());
390 DeleteFileA("should_be_non_existing_deadbeef");
393 InternetCloseHandle(hFtp);
395 /* Http handle-type for ftp connection */
397 hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_PASSIVE, 0);
399 /* Test to show the parameter checking order depends on the Windows version */
400 SetLastError(0xdeadbeef);
401 bRet = FtpGetFileA(hConnect, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
402 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
403 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE ||
404 GetLastError() == ERROR_INVALID_PARAMETER,
405 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
407 /* Test to show that 'session handle type' is checked before 'condition flags' */
408 SetLastError(0xdeadbeef);
409 bRet = FtpGetFileA(hConnect, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0);
410 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
411 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
412 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
414 SetLastError(0xdeadbeef);
415 bRet = FtpGetFileA(hConnect, "should_be_non_existing_deadbeef", "should_be_non_existing_deadbeef", TRUE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
416 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
417 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
418 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
420 InternetCloseHandle(hConnect);
421 InternetCloseHandle(hInternet);
424 static void test_openfile(void)
426 HINTERNET hOpenFile, hInternet, hFtp, hConnect;
428 /* Invalid internet handle, the rest are valid parameters */
429 SetLastError(0xdeadbeef);
430 hOpenFile = FtpOpenFileA(NULL, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
431 ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
432 ok ( GetLastError() == ERROR_INVALID_HANDLE,
433 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
434 InternetCloseHandle(hOpenFile); /* Just in case */
436 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
437 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
438 if(!hFtp)
440 skip("No ftp connection could be made to ftp.winehq.org\n");
441 InternetCloseHandle(hInternet);
442 return;
445 /* We should have a ftp-connection (valid ftp session handle), try some opening */
447 /* No filename */
448 SetLastError(0xdeadbeef);
449 hOpenFile = FtpOpenFileA(hFtp, NULL, GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
450 ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
451 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
452 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
453 InternetCloseHandle(hOpenFile); /* Just in case */
455 /* Illegal access flags */
456 SetLastError(0xdeadbeef);
457 hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", 0, FTP_TRANSFER_TYPE_ASCII, 0);
458 ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
459 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
460 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
461 InternetCloseHandle(hOpenFile); /* Just in case */
463 /* Illegal combination of access flags */
464 SetLastError(0xdeadbeef);
465 hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ|GENERIC_WRITE, FTP_TRANSFER_TYPE_ASCII, 0);
466 ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
467 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
468 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
469 InternetCloseHandle(hOpenFile); /* Just in case */
471 /* Illegal condition flags */
472 SetLastError(0xdeadbeef);
473 hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, 0xffffffff, 0);
474 ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
475 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR || GetLastError() == ERROR_INVALID_PARAMETER,
476 "Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_INVALID_PARAMETER (win98), got %d\n", GetLastError());
477 InternetCloseHandle(hOpenFile); /* Just in case */
479 SetLastError(0xdeadbeef);
480 hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
481 todo_wine
483 ok ( hOpenFile == NULL, "Expected FtpOpenFileA to fail\n");
484 /* For some strange/unknown reason, win98 returns ERROR_FILE_NOT_FOUND */
485 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR || GetLastError() == ERROR_FILE_NOT_FOUND,
486 "Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_FILE_NOT_FOUND (win98), got %d\n", GetLastError());
489 if (hOpenFile)
491 BOOL bRet;
492 HINTERNET hOpenFile2;
493 HANDLE hFile;
495 /* We have a handle so all ftp calls should fail (TODO: Put all ftp-calls in here) */
496 SetLastError(0xdeadbeef);
497 bRet = FtpCreateDirectoryA(hFtp, "new_directory_deadbeef");
498 ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
499 todo_wine
500 ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
501 "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
503 SetLastError(0xdeadbeef);
504 bRet = FtpDeleteFileA(hFtp, "non_existent_file_deadbeef");
505 ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
506 todo_wine
507 ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
508 "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
510 SetLastError(0xdeadbeef);
511 bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
512 ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
513 ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
514 "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
515 DeleteFileA("should_be_non_existing_deadbeef"); /* Just in case */
517 SetLastError(0xdeadbeef);
518 hOpenFile2 = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
519 ok ( bRet == FALSE, "Expected FtpOpenFileA to fail\n");
520 ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
521 "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
522 InternetCloseHandle(hOpenFile2); /* Just in case */
524 /* Create a temporary local file */
525 SetLastError(0xdeadbeef);
526 hFile = CreateFileA("now_existing_local", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
527 ok ( hFile != NULL, "Error creating a local file : %d\n", GetLastError());
528 CloseHandle(hFile);
529 SetLastError(0xdeadbeef);
530 bRet = FtpPutFileA(hFtp, "now_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
531 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
532 todo_wine
533 ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
534 "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
535 DeleteFileA("now_existing_local");
537 SetLastError(0xdeadbeef);
538 bRet = FtpRemoveDirectoryA(hFtp, "should_be_non_existing_deadbeef_dir");
539 ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
540 todo_wine
541 ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
542 "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
544 SetLastError(0xdeadbeef);
545 bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", "new");
546 ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
547 todo_wine
548 ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
549 "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
552 InternetCloseHandle(hOpenFile);
553 InternetCloseHandle(hFtp);
555 /* Http handle-type for ftp connection */
557 hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_PASSIVE, 0);
559 /* One small test to show that handle type is checked before parameters */
560 SetLastError(0xdeadbeef);
561 hOpenFile = FtpOpenFileA(hConnect, "welcome.msg", GENERIC_READ, 5, 0);
562 ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
563 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
564 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
565 InternetCloseHandle(hOpenFile); /* Just in case */
567 SetLastError(0xdeadbeef);
568 hOpenFile = FtpOpenFileA(hConnect, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
569 ok ( hOpenFile == NULL, "Expected FtpOpenFileA to fail\n");
570 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
571 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
573 InternetCloseHandle(hOpenFile); /* Just in case */
574 InternetCloseHandle(hConnect);
575 InternetCloseHandle(hInternet);
578 static void test_putfile(void)
580 BOOL bRet;
581 HINTERNET hInternet, hFtp, hConnect;
582 HANDLE hFile;
584 /* The order of checking is:
586 * All parameters except 'session handle' and 'condition flags'
587 * Session handle
588 * Session handle type
589 * Condition flags
592 /* Test to show the parameter checking order depends on the Windows version */
593 SetLastError(0xdeadbeef);
594 bRet = FtpPutFileA(NULL, NULL, "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
595 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
596 ok ( GetLastError() == ERROR_INVALID_HANDLE ||
597 GetLastError() == ERROR_INVALID_PARAMETER,
598 "Expected ERROR_INVALID_HANDLE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
600 /* Test to show session handle is checked before 'condition flags' */
601 SetLastError(0xdeadbeef);
602 bRet = FtpPutFileA(NULL, "non_existing_local", "non_existing_remote", 5, 0);
603 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
604 ok ( GetLastError() == ERROR_INVALID_HANDLE,
605 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
607 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
608 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
609 if(!hFtp)
611 skip("No ftp connection could be made to ftp.winehq.org\n");
612 InternetCloseHandle(hInternet);
613 return;
616 /* Start clean */
617 DeleteFileA("non_existing_local");
619 /* We should have a ftp-connection, try some puts */
621 /* No local file given */
622 SetLastError(0xdeadbeef);
623 bRet = FtpPutFileA(hFtp, NULL, "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
624 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
625 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
626 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
628 /* No remote file given */
629 SetLastError(0xdeadbeef);
630 bRet = FtpPutFileA(hFtp, "non_existing_local", NULL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
631 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
632 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
633 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
635 /* Illegal condition flags */
636 SetLastError(0xdeadbeef);
637 bRet = FtpPutFileA(hFtp, "non_existing_local", "non_existing_remote", 5, 0);
638 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
639 ok ( GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_INVALID_PARAMETER,
640 "Expected ERROR_FILE_NOT_FOUND or ERROR_INVALID_PARAMETER (win98), got %d\n", GetLastError());
642 /* Parameters are OK but local file doesn't exist */
643 SetLastError(0xdeadbeef);
644 bRet = FtpPutFileA(hFtp, "non_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
645 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
646 ok ( GetLastError() == ERROR_FILE_NOT_FOUND,
647 "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
649 /* Create a temporary local file */
650 SetLastError(0xdeadbeef);
651 hFile = CreateFileA("now_existing_local", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
652 ok ( hFile != NULL, "Error creating a local file : %d\n", GetLastError());
653 CloseHandle(hFile);
655 /* Local file exists but we shouldn't be allowed to 'put' the file */
656 SetLastError(0xdeadbeef);
657 bRet = FtpPutFileA(hFtp, "now_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
658 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
659 todo_wine
660 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
661 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
663 DeleteFileA("now_existing_local");
665 InternetCloseHandle(hFtp);
667 /* Http handle-type for ftp connection */
669 hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_PASSIVE, 0);
671 /* Test to show the parameter checking order depends on the Windows version */
672 SetLastError(0xdeadbeef);
673 bRet = FtpPutFileA(hConnect, NULL, "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
674 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
675 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE ||
676 GetLastError() == ERROR_INVALID_PARAMETER,
677 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
679 /* Test to show that 'session handle type' is checked before 'condition flags' */
680 SetLastError(0xdeadbeef);
681 bRet = FtpPutFileA(hConnect, "non_existing_local", "non_existing_remote", 5, 0);
682 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
683 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
684 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
686 SetLastError(0xdeadbeef);
687 bRet = FtpPutFileA(hConnect, "non_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
688 ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
689 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
690 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
692 InternetCloseHandle(hConnect);
693 InternetCloseHandle(hInternet);
696 static void test_removedir(void)
698 BOOL bRet;
699 HINTERNET hInternet, hFtp, hConnect;
701 /* Invalid internet handle, the other is a valid parameter */
702 SetLastError(0xdeadbeef);
703 bRet = FtpRemoveDirectoryA(NULL, "should_be_non_existing_deadbeef_dir");
704 ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
705 ok ( GetLastError() == ERROR_INVALID_HANDLE,
706 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
708 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
709 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
710 if(!hFtp)
712 skip("No ftp connection could be made to ftp.winehq.org\n");
713 InternetCloseHandle(hInternet);
714 return;
717 /* We should have a ftp-connection, try some removing */
719 /* No remote directory given */
720 SetLastError(0xdeadbeef);
721 bRet = FtpRemoveDirectoryA(hFtp, NULL);
722 ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
723 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
724 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
726 /* Remote directory doesn't exist */
727 SetLastError(0xdeadbeef);
728 bRet = FtpRemoveDirectoryA(hFtp, "should_be_non_existing_deadbeef_dir");
729 ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
730 todo_wine
731 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
732 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
734 /* We shouldn't be allowed to remove that directory */
735 SetLastError(0xdeadbeef);
736 bRet = FtpRemoveDirectoryA(hFtp, "pub");
737 ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
738 todo_wine
739 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
740 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
742 InternetCloseHandle(hFtp);
744 /* Http handle-type for ftp connection */
746 hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_PASSIVE, 0);
748 /* One small test to show that handle type is checked before parameters */
749 SetLastError(0xdeadbeef);
750 bRet = FtpRemoveDirectoryA(hConnect, NULL);
751 ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
752 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
753 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
755 SetLastError(0xdeadbeef);
756 bRet = FtpRemoveDirectoryA(hConnect, "should_be_non_existing_deadbeef_dir");
757 ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
758 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
759 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
761 InternetCloseHandle(hConnect);
762 InternetCloseHandle(hInternet);
765 static void test_renamefile(void)
767 BOOL bRet;
768 HINTERNET hInternet, hFtp, hConnect;
770 /* Invalid internet handle, the rest are valid parameters */
771 SetLastError(0xdeadbeef);
772 bRet = FtpRenameFileA(NULL , "should_be_non_existing_deadbeef", "new");
773 ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
774 ok ( GetLastError() == ERROR_INVALID_HANDLE,
775 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
777 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
778 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
779 if(!hFtp)
781 skip("No ftp connection could be made to ftp.winehq.org\n");
782 InternetCloseHandle(hInternet);
783 return;
786 /* We should have a ftp-connection, try some renaming */
788 /* No 'existing' file */
789 SetLastError(0xdeadbeef);
790 bRet = FtpRenameFileA(hFtp , NULL, "new");
791 ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
792 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
793 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
795 /* No new file */
796 SetLastError(0xdeadbeef);
797 bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", NULL);
798 ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
799 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
800 "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
802 /* Existing file shouldn't be there */
803 SetLastError(0xdeadbeef);
804 bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", "new");
805 ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
806 todo_wine
807 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
808 "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
810 InternetCloseHandle(hFtp);
812 /* Http handle-type for ftp connection */
814 hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_PASSIVE, 0);
816 /* One small test to show that handle type is checked before parameters */
817 SetLastError(0xdeadbeef);
818 bRet = FtpRenameFileA(hConnect , "should_be_non_existing_deadbeef", NULL);
819 ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
820 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
821 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
823 SetLastError(0xdeadbeef);
824 bRet = FtpRenameFileA(hConnect , "should_be_non_existing_deadbeef", "new");
825 ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
826 ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
827 "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
829 InternetCloseHandle(hConnect);
830 InternetCloseHandle(hInternet);
833 static void test_multiple(void)
835 BOOL bRet;
836 HINTERNET hInternet, hFtp, hOpenFile;
838 hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
839 hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
840 if(!hFtp)
842 skip("No ftp connection could be made to ftp.winehq.org\n");
843 InternetCloseHandle(hInternet);
844 return;
847 /* A correct call */
848 bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
849 DeleteFileA("should_be_non_existing_deadbeef");
851 SetLastError(0xdeadbeef);
852 hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
853 ok ( hOpenFile == NULL, "Expected FtpOpenFileA to fail\n");
854 ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR || GetLastError() == ERROR_FILE_NOT_FOUND,
855 "Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_FILE_NOT_FOUND (win98), got %d\n", GetLastError());
857 InternetCloseHandle(hOpenFile);
858 InternetCloseHandle(hFtp);
859 InternetCloseHandle(hInternet);
862 START_TEST(ftp)
864 /* The first call should always be a proper InternetOpen, if not
865 * several calls will return ERROR_INTERNET_NOT_INITIALIZED when
866 * all parameters are correct but no session handle is given. Whereas
867 * the same call will return ERROR_INVALID_HANDLE if an InternetOpen
868 * is done before.
869 * The following test will show that behaviour, where the tests inside
870 * the other sub-tests will show the other situation.
872 test_getfile_no_open();
873 test_connect();
874 test_createdir();
875 test_deletefile();
876 test_getfile();
877 test_openfile();
878 test_putfile();
879 test_removedir();
880 test_renamefile();
882 /* A test that does two particular calls in one connection, this currently fails on Wine.
883 * The problem lies in FtpGetFile but is exposed in FtpOpenFile.
884 * Once this is fixed we should change the total test to setup and clear the connections
885 * only once. (and get rid of test_multiple).
887 test_multiple();