mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
[WINHTTP_WINETEST]
- Sync to wine 1.3.21 svn path=/trunk/; revision=52106
This commit is contained in:
parent
d7abc4fbf1
commit
9616b43abc
2 changed files with 98 additions and 26 deletions
|
@ -46,6 +46,7 @@ struct notification
|
||||||
unsigned int status; /* status received */
|
unsigned int status; /* status received */
|
||||||
int todo;
|
int todo;
|
||||||
int ignore;
|
int ignore;
|
||||||
|
int skipped_for_proxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct info
|
struct info
|
||||||
|
@ -58,6 +59,25 @@ struct info
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static BOOL proxy_active(void)
|
||||||
|
{
|
||||||
|
WINHTTP_PROXY_INFO proxy_info;
|
||||||
|
BOOL active = FALSE;
|
||||||
|
|
||||||
|
if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
|
||||||
|
{
|
||||||
|
active = (proxy_info.lpszProxy != NULL);
|
||||||
|
if (active)
|
||||||
|
GlobalFree((HGLOBAL) proxy_info.lpszProxy);
|
||||||
|
if (proxy_info.lpszProxyBypass != NULL)
|
||||||
|
GlobalFree((HGLOBAL) proxy_info.lpszProxyBypass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
active = FALSE;
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen )
|
static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen )
|
||||||
{
|
{
|
||||||
BOOL status_ok, function_ok;
|
BOOL status_ok, function_ok;
|
||||||
|
@ -88,6 +108,12 @@ static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DW
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status_ok) info->index++;
|
if (status_ok) info->index++;
|
||||||
|
if (proxy_active())
|
||||||
|
{
|
||||||
|
while (info->test[info->index].skipped_for_proxy)
|
||||||
|
info->index++;
|
||||||
|
}
|
||||||
|
|
||||||
if (status & (WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING))
|
if (status & (WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING))
|
||||||
{
|
{
|
||||||
SetEvent( info->wait );
|
SetEvent( info->wait );
|
||||||
|
@ -222,10 +248,10 @@ static const struct notification redirect_test[] =
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
||||||
|
@ -269,6 +295,7 @@ static void test_redirect( void )
|
||||||
|
|
||||||
setup_test( &info, winhttp_send_request, __LINE__ );
|
setup_test( &info, winhttp_send_request, __LINE__ );
|
||||||
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
|
||||||
|
ok(ret, "failed to send request %u\n", GetLastError());
|
||||||
|
|
||||||
setup_test( &info, winhttp_receive_response, __LINE__ );
|
setup_test( &info, winhttp_receive_response, __LINE__ );
|
||||||
ret = WinHttpReceiveResponse( req, NULL );
|
ret = WinHttpReceiveResponse( req, NULL );
|
||||||
|
@ -299,10 +326,10 @@ static const struct notification async_test[] =
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0, 0, 1 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT, 0 },
|
||||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, 0 },
|
||||||
|
|
|
@ -34,6 +34,25 @@ static const WCHAR test_useragent[] =
|
||||||
static const WCHAR test_server[] = {'w','i','n','e','h','q','.','o','r','g',0};
|
static const WCHAR test_server[] = {'w','i','n','e','h','q','.','o','r','g',0};
|
||||||
static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0};
|
static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0};
|
||||||
|
|
||||||
|
static BOOL proxy_active(void)
|
||||||
|
{
|
||||||
|
WINHTTP_PROXY_INFO proxy_info;
|
||||||
|
BOOL active = FALSE;
|
||||||
|
|
||||||
|
if (WinHttpGetDefaultProxyConfiguration(&proxy_info))
|
||||||
|
{
|
||||||
|
active = (proxy_info.lpszProxy != NULL);
|
||||||
|
if (active)
|
||||||
|
GlobalFree((HGLOBAL) proxy_info.lpszProxy);
|
||||||
|
if (proxy_info.lpszProxyBypass != NULL)
|
||||||
|
GlobalFree((HGLOBAL) proxy_info.lpszProxyBypass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
active = FALSE;
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_QueryOption(void)
|
static void test_QueryOption(void)
|
||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
@ -770,6 +789,8 @@ static void test_secure_connection(void)
|
||||||
DWORD size, status, policy, bitness;
|
DWORD size, status, policy, bitness;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
CERT_CONTEXT *cert;
|
CERT_CONTEXT *cert;
|
||||||
|
WINHTTP_CERTIFICATE_INFO info;
|
||||||
|
char buffer[32];
|
||||||
|
|
||||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||||
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
||||||
|
@ -794,7 +815,7 @@ static void test_secure_connection(void)
|
||||||
ok(ret, "failed to send request %u\n", GetLastError());
|
ok(ret, "failed to send request %u\n", GetLastError());
|
||||||
|
|
||||||
ret = WinHttpReceiveResponse(req, NULL);
|
ret = WinHttpReceiveResponse(req, NULL);
|
||||||
ok(!ret, "succeeded unexpectedly\n");
|
ok(!ret || proxy_active(), "succeeded unexpectedly\n");
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size, NULL);
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size, NULL);
|
||||||
|
@ -823,6 +844,17 @@ static void test_secure_connection(void)
|
||||||
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_KEY_BITNESS, &bitness, &size );
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_KEY_BITNESS, &bitness, &size );
|
||||||
ok(ret, "failed to retrieve key bitness %u\n", GetLastError());
|
ok(ret, "failed to retrieve key bitness %u\n", GetLastError());
|
||||||
|
|
||||||
|
size = sizeof(info);
|
||||||
|
ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT, &info, &size );
|
||||||
|
ok(ret, "failed to retrieve certificate info %u\n", GetLastError());
|
||||||
|
|
||||||
|
trace("lpszSubjectInfo %s\n", wine_dbgstr_w(info.lpszSubjectInfo));
|
||||||
|
trace("lpszIssuerInfo %s\n", wine_dbgstr_w(info.lpszIssuerInfo));
|
||||||
|
trace("lpszProtocolName %s\n", wine_dbgstr_w(info.lpszProtocolName));
|
||||||
|
trace("lpszSignatureAlgName %s\n", wine_dbgstr_w(info.lpszSignatureAlgName));
|
||||||
|
trace("lpszEncryptionAlgName %s\n", wine_dbgstr_w(info.lpszEncryptionAlgName));
|
||||||
|
trace("dwKeySize %u\n", info.dwKeySize);
|
||||||
|
|
||||||
ret = WinHttpReceiveResponse(req, NULL);
|
ret = WinHttpReceiveResponse(req, NULL);
|
||||||
ok(ret, "failed to receive response %u\n", GetLastError());
|
ok(ret, "failed to receive response %u\n", GetLastError());
|
||||||
|
|
||||||
|
@ -835,6 +867,14 @@ static void test_secure_connection(void)
|
||||||
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size, NULL);
|
ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_RAW_HEADERS_CRLF, NULL, NULL, &size, NULL);
|
||||||
ok(!ret, "succeeded unexpectedly\n");
|
ok(!ret, "succeeded unexpectedly\n");
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
|
||||||
|
ok(ret == TRUE, "WinHttpReadData failed: %u.\n", GetLastError());
|
||||||
|
if (!size) break;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
WinHttpCloseHandle(req);
|
WinHttpCloseHandle(req);
|
||||||
WinHttpCloseHandle(con);
|
WinHttpCloseHandle(con);
|
||||||
|
@ -1648,6 +1688,8 @@ static void test_resolve_timeout(void)
|
||||||
DWORD timeout;
|
DWORD timeout;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
|
if (! proxy_active())
|
||||||
|
{
|
||||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||||
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
||||||
|
|
||||||
|
@ -1670,6 +1712,9 @@ static void test_resolve_timeout(void)
|
||||||
WinHttpCloseHandle(req);
|
WinHttpCloseHandle(req);
|
||||||
WinHttpCloseHandle(con);
|
WinHttpCloseHandle(con);
|
||||||
WinHttpCloseHandle(ses);
|
WinHttpCloseHandle(ses);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
skip("Skipping host resolution tests, host resolution preformed by proxy\n");
|
||||||
|
|
||||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||||
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue