mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[WININET_WINETEST] Sync with Wine Staging 1.7.37. CORE-9246
svn path=/trunk/; revision=67344
This commit is contained in:
parent
4d912f865f
commit
4295aef9da
3 changed files with 232 additions and 16 deletions
|
@ -754,6 +754,7 @@ static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)
|
|||
HINTERNET hSearch2;
|
||||
HINTERNET hOpenFile;
|
||||
DWORD error;
|
||||
BOOL success;
|
||||
|
||||
/* NULL as the search file ought to return the first file in the directory */
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -773,13 +774,13 @@ static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)
|
|||
/* Try a valid filename in a subdirectory search */
|
||||
SetLastError(0xdeadbeef);
|
||||
hSearch = FtpFindFirstFileA(hFtp, "pub/wine", &findData, 0, 0);
|
||||
todo_wine ok ( hSearch != NULL, "Expected FtpFindFirstFileA to pass\n" );
|
||||
ok( hSearch != NULL, "Expected FtpFindFirstFileA to pass\n" );
|
||||
InternetCloseHandle(hSearch);
|
||||
|
||||
/* Try a valid filename in a subdirectory wildcard search */
|
||||
SetLastError(0xdeadbeef);
|
||||
hSearch = FtpFindFirstFileA(hFtp, "pub/w*", &findData, 0, 0);
|
||||
todo_wine ok ( hSearch != NULL, "Expected FtpFindFirstFileA to pass\n" );
|
||||
ok( hSearch != NULL, "Expected FtpFindFirstFileA to pass\n" );
|
||||
InternetCloseHandle(hSearch);
|
||||
|
||||
/* Try an invalid wildcard search */
|
||||
|
@ -788,6 +789,24 @@ static void test_find_first_file(HINTERNET hFtp, HINTERNET hConnect)
|
|||
ok ( hSearch == NULL, "Expected FtpFindFirstFileA to fail\n" );
|
||||
InternetCloseHandle(hSearch); /* Just in case */
|
||||
|
||||
/* change current directory, and repeat those tests - this shows
|
||||
* that the search string is interpreted as relative directory. */
|
||||
success = FtpSetCurrentDirectoryA(hFtp, "pub");
|
||||
ok( success, "Expected FtpSetCurrentDirectory to succeed\n" );
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hSearch = FtpFindFirstFileA(hFtp, "wine", &findData, 0, 0);
|
||||
ok( hSearch != NULL, "Expected FtpFindFirstFileA to pass\n" );
|
||||
InternetCloseHandle(hSearch);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hSearch = FtpFindFirstFileA(hFtp, "w*", &findData, 0, 0);
|
||||
ok( hSearch != NULL, "Expected FtpFindFirstFileA to pass\n" );
|
||||
InternetCloseHandle(hSearch);
|
||||
|
||||
success = FtpSetCurrentDirectoryA(hFtp, "..");
|
||||
ok( success, "Expected FtpSetCurrentDirectory to succeed\n" );
|
||||
|
||||
/* Try FindFirstFile between FtpOpenFile and InternetCloseHandle */
|
||||
SetLastError(0xdeadbeef);
|
||||
hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
|
||||
|
|
|
@ -2295,9 +2295,37 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
|||
else if (strstr(buffer, "Cache-Control: no-cache\r\n")) send(c, okmsg, sizeof(okmsg)-1, 0);
|
||||
else send(c, notokmsg, sizeof(notokmsg)-1, 0);
|
||||
}
|
||||
if (strstr(buffer, "/test_request_content_length"))
|
||||
{
|
||||
static char msg[] = "HTTP/1.1 200 OK\r\nConnection: Keep-Alive\r\n\r\n";
|
||||
static int seen_content_length;
|
||||
|
||||
if (!seen_content_length)
|
||||
{
|
||||
if (strstr(buffer, "Content-Length: 0"))
|
||||
{
|
||||
seen_content_length = 1;
|
||||
send(c, msg, sizeof msg-1, 0);
|
||||
}
|
||||
else send(c, notokmsg, sizeof notokmsg-1, 0);
|
||||
WaitForSingleObject(hCompleteEvent, 5000);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strstr(buffer, "Content-Length: 0")) send(c, msg, sizeof msg-1, 0);
|
||||
else send(c, notokmsg, sizeof notokmsg-1, 0);
|
||||
WaitForSingleObject(hCompleteEvent, 5000);
|
||||
}
|
||||
}
|
||||
if (strstr(buffer, "GET /test_premature_disconnect"))
|
||||
trace("closing connection\n");
|
||||
|
||||
if (strstr(buffer, "/test_accept_encoding_http10"))
|
||||
{
|
||||
if (strstr(buffer, "Accept-Encoding: gzip"))
|
||||
send(c, okmsg, sizeof okmsg-1, 0);
|
||||
else
|
||||
send(c, notokmsg, sizeof notokmsg-1, 0);
|
||||
}
|
||||
shutdown(c, 2);
|
||||
closesocket(c);
|
||||
c = -1;
|
||||
|
@ -4120,6 +4148,79 @@ static void test_cache_control_verb(int port)
|
|||
InternetCloseHandle(session);
|
||||
}
|
||||
|
||||
static void test_request_content_length(int port)
|
||||
{
|
||||
char data[] = {'t','e','s','t'};
|
||||
HINTERNET ses, con, req;
|
||||
BOOL ret;
|
||||
|
||||
hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||
|
||||
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||
ok(ses != NULL, "InternetOpen failed\n");
|
||||
|
||||
con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
|
||||
ok(con != NULL, "InternetConnect failed\n");
|
||||
|
||||
req = HttpOpenRequestA(con, "POST", "/test_request_content_length", NULL, NULL, NULL,
|
||||
INTERNET_FLAG_KEEP_CONNECTION, 0);
|
||||
ok(req != NULL, "HttpOpenRequest failed\n");
|
||||
|
||||
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
|
||||
ok(ret, "HttpSendRequest failed %u\n", GetLastError());
|
||||
test_status_code(req, 200);
|
||||
|
||||
SetEvent(hCompleteEvent);
|
||||
|
||||
ret = HttpSendRequestA(req, NULL, 0, data, sizeof(data));
|
||||
ok(ret, "HttpSendRequest failed %u\n", GetLastError());
|
||||
test_status_code(req, 200);
|
||||
|
||||
SetEvent(hCompleteEvent);
|
||||
|
||||
InternetCloseHandle(req);
|
||||
InternetCloseHandle(con);
|
||||
InternetCloseHandle(ses);
|
||||
CloseHandle(hCompleteEvent);
|
||||
}
|
||||
|
||||
static void test_accept_encoding(int port)
|
||||
{
|
||||
HINTERNET ses, con, req;
|
||||
BOOL ret;
|
||||
|
||||
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
||||
ok(ses != NULL, "InternetOpen failed\n");
|
||||
|
||||
con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
|
||||
ok(con != NULL, "InternetConnect failed\n");
|
||||
|
||||
req = HttpOpenRequestA(con, "GET", "/test_accept_encoding_http10", "HTTP/1.0", NULL, NULL, 0, 0);
|
||||
ok(req != NULL, "HttpOpenRequest failed\n");
|
||||
|
||||
ret = HttpAddRequestHeadersA(req, "Accept-Encoding: gzip\r\n", ~0u, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
|
||||
ok(ret, "HttpAddRequestHeaders failed\n");
|
||||
|
||||
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
|
||||
ok(ret, "HttpSendRequestA failed\n");
|
||||
|
||||
test_status_code(req, 200);
|
||||
|
||||
InternetCloseHandle(req);
|
||||
|
||||
req = HttpOpenRequestA(con, "GET", "/test_accept_encoding_http10", "HTTP/1.0", NULL, NULL, 0, 0);
|
||||
ok(req != NULL, "HttpOpenRequest failed\n");
|
||||
|
||||
ret = HttpSendRequestA(req, "Accept-Encoding: gzip", ~0u, NULL, 0);
|
||||
ok(ret, "HttpSendRequestA failed\n");
|
||||
|
||||
test_status_code(req, 200);
|
||||
|
||||
InternetCloseHandle(req);
|
||||
InternetCloseHandle(con);
|
||||
InternetCloseHandle(ses);
|
||||
}
|
||||
|
||||
static void test_http_connection(void)
|
||||
{
|
||||
struct server_info si;
|
||||
|
@ -4165,6 +4266,8 @@ static void test_http_connection(void)
|
|||
test_cache_control_verb(si.port);
|
||||
test_successive_HttpSendRequest(si.port);
|
||||
test_head_request(si.port);
|
||||
test_request_content_length(si.port);
|
||||
test_accept_encoding(si.port);
|
||||
|
||||
/* send the basic request again to shutdown the server thread */
|
||||
test_basic_request(si.port, "GET", "/quit");
|
||||
|
@ -4232,7 +4335,7 @@ static void test_cert_struct(HINTERNET req, const cert_struct_test_t *test)
|
|||
ok(!info.lpszSignatureAlgName, "lpszSignatureAlgName = %s\n", info.lpszSignatureAlgName);
|
||||
ok(!info.lpszEncryptionAlgName, "lpszEncryptionAlgName = %s\n", info.lpszEncryptionAlgName);
|
||||
ok(!info.lpszProtocolName, "lpszProtocolName = %s\n", info.lpszProtocolName);
|
||||
ok(info.dwKeySize == 128 || info.dwKeySize == 256, "dwKeySize = %u\n", info.dwKeySize);
|
||||
ok(info.dwKeySize >= 128 && info.dwKeySize <= 256, "dwKeySize = %u\n", info.dwKeySize);
|
||||
|
||||
release_cert_info(&info);
|
||||
}
|
||||
|
@ -5484,6 +5587,55 @@ static void init_status_tests(void)
|
|||
#undef STATUS_STRING
|
||||
}
|
||||
|
||||
static void WINAPI header_cb( HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD len )
|
||||
{
|
||||
if (status == INTERNET_STATUS_REQUEST_COMPLETE) SetEvent( (HANDLE)ctx );
|
||||
}
|
||||
|
||||
static void test_concurrent_header_access(void)
|
||||
{
|
||||
HINTERNET ses, con, req;
|
||||
DWORD index, len, err;
|
||||
BOOL ret;
|
||||
char buf[128];
|
||||
HANDLE wait = CreateEventW( NULL, FALSE, FALSE, NULL );
|
||||
|
||||
ses = InternetOpenA( "winetest", 0, NULL, NULL, INTERNET_FLAG_ASYNC );
|
||||
ok( ses != NULL, "InternetOpenA failed\n" );
|
||||
|
||||
con = InternetConnectA( ses, "test.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
|
||||
INTERNET_SERVICE_HTTP, 0, 0 );
|
||||
ok( con != NULL, "InternetConnectA failed %u\n", GetLastError() );
|
||||
|
||||
req = HttpOpenRequestA( con, NULL, "/", NULL, NULL, NULL, 0, (DWORD_PTR)wait );
|
||||
ok( req != NULL, "HttpOpenRequestA failed %u\n", GetLastError() );
|
||||
|
||||
pInternetSetStatusCallbackA( req, header_cb );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
|
||||
err = GetLastError();
|
||||
ok( !ret, "HttpSendRequestA succeeded\n" );
|
||||
ok( err == ERROR_IO_PENDING, "got %u\n", ERROR_IO_PENDING );
|
||||
|
||||
ret = HttpAddRequestHeadersA( req, "winetest: winetest", ~0u, HTTP_ADDREQ_FLAG_ADD );
|
||||
ok( ret, "HttpAddRequestHeadersA failed %u\n", GetLastError() );
|
||||
|
||||
index = 0;
|
||||
len = sizeof(buf);
|
||||
ret = HttpQueryInfoA( req, HTTP_QUERY_RAW_HEADERS_CRLF|HTTP_QUERY_FLAG_REQUEST_HEADERS,
|
||||
buf, &len, &index );
|
||||
ok( ret, "HttpQueryInfoA failed %u\n", GetLastError() );
|
||||
ok( strstr( buf, "winetest: winetest" ) != NULL, "header missing\n" );
|
||||
|
||||
WaitForSingleObject( wait, 5000 );
|
||||
|
||||
InternetCloseHandle( req );
|
||||
InternetCloseHandle( con );
|
||||
InternetCloseHandle( ses );
|
||||
CloseHandle( wait );
|
||||
}
|
||||
|
||||
START_TEST(http)
|
||||
{
|
||||
HMODULE hdll;
|
||||
|
@ -5526,4 +5678,5 @@ START_TEST(http)
|
|||
InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[3]);
|
||||
test_connection_failure();
|
||||
test_default_service_port();
|
||||
test_concurrent_header_access();
|
||||
}
|
||||
|
|
|
@ -1526,19 +1526,16 @@ static void test_InternetGetConnectedStateExA(void)
|
|||
trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, buffer);
|
||||
|
||||
res = pInternetGetConnectedStateExA(NULL, NULL, 0, 0);
|
||||
todo_wine
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExA(&flags, NULL, 0, 0);
|
||||
todo_wine
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExA(&flags, buffer, 0, 0);
|
||||
todo_wine
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
|
||||
|
@ -1557,6 +1554,11 @@ todo_wine
|
|||
sz = strlen(buffer);
|
||||
ok(sz > 0, "Expected a connection name\n");
|
||||
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExA(&flags, NULL, sizeof(buffer), 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
|
||||
/* no space for complete string this time */
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
|
@ -1567,11 +1569,31 @@ todo_wine
|
|||
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
|
||||
todo_wine
|
||||
res = pInternetGetConnectedStateExA(&flags, buffer, sz / 2, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(strlen(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenA(buffer));
|
||||
ok(sz / 2 - 1 == strlen(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenA(buffer));
|
||||
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
|
||||
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExA(&flags, buffer, 2, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(strlen(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenA(buffer));
|
||||
|
||||
flags = 0;
|
||||
buffer[0] = 0xDE;
|
||||
res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
|
||||
}
|
||||
|
||||
static void test_InternetGetConnectedStateExW(void)
|
||||
|
@ -1593,12 +1615,10 @@ static void test_InternetGetConnectedStateExW(void)
|
|||
trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, wine_dbgstr_w(buffer));
|
||||
|
||||
res = pInternetGetConnectedStateExW(NULL, NULL, 0, 0);
|
||||
todo_wine
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExW(&flags, NULL, 0, 0);
|
||||
todo_wine
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
|
||||
|
@ -1607,7 +1627,6 @@ todo_wine
|
|||
res = pInternetGetConnectedStateExW(&flags, buffer, 0, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
todo_wine
|
||||
ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
|
||||
|
||||
buffer[0] = 0;
|
||||
|
@ -1624,6 +1643,11 @@ todo_wine
|
|||
sz = lstrlenW(buffer);
|
||||
ok(sz > 0, "Expected a connection name\n");
|
||||
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExW(&flags, NULL, sizeof(buffer) / sizeof(buffer[0]), 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
|
||||
/* no space for complete string this time */
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
|
@ -1634,11 +1658,31 @@ todo_wine
|
|||
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
|
||||
todo_wine
|
||||
res = pInternetGetConnectedStateExW(&flags, buffer, sz / 2, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(lstrlenW(buffer) == 0, "Expected 0 bytes, got %u\n", lstrlenW(buffer));
|
||||
ok(sz / 2 - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenW(buffer));
|
||||
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
|
||||
|
||||
buffer[0] = 0;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExW(&flags, buffer, 2, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(lstrlenW(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer));
|
||||
|
||||
buffer[0] = 0xDEAD;
|
||||
flags = 0;
|
||||
res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
|
||||
ok(res == TRUE, "Expected TRUE, got %d\n", res);
|
||||
ok(flags, "Expected at least one flag set\n");
|
||||
ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
|
||||
}
|
||||
|
||||
/* ############################### */
|
||||
|
|
Loading…
Reference in a new issue