mirror of
https://github.com/reactos/reactos.git
synced 2025-01-06 06:20:13 +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 */
|
||||
int todo;
|
||||
int ignore;
|
||||
int skipped_for_proxy;
|
||||
};
|
||||
|
||||
struct info
|
||||
|
@ -58,6 +59,25 @@ struct info
|
|||
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 )
|
||||
{
|
||||
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 (proxy_active())
|
||||
{
|
||||
while (info->test[info->index].skipped_for_proxy)
|
||||
info->index++;
|
||||
}
|
||||
|
||||
if (status & (WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING))
|
||||
{
|
||||
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_RESPONSE_RECEIVED, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0, 0, 1 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0, 0, 1 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0, 0, 1 },
|
||||
{ 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_REQUEST_SENT, 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__ );
|
||||
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__ );
|
||||
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_RESPONSE_RECEIVED, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, 0 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, 0, 0, 1 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, 0, 0, 1 },
|
||||
{ winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, 0, 0, 1 },
|
||||
{ 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_REQUEST_SENT, 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 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)
|
||||
{
|
||||
BOOL ret;
|
||||
|
@ -770,6 +789,8 @@ static void test_secure_connection(void)
|
|||
DWORD size, status, policy, bitness;
|
||||
BOOL ret;
|
||||
CERT_CONTEXT *cert;
|
||||
WINHTTP_CERTIFICATE_INFO info;
|
||||
char buffer[32];
|
||||
|
||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||
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());
|
||||
|
||||
ret = WinHttpReceiveResponse(req, NULL);
|
||||
ok(!ret, "succeeded unexpectedly\n");
|
||||
ok(!ret || proxy_active(), "succeeded unexpectedly\n");
|
||||
|
||||
size = 0;
|
||||
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 );
|
||||
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);
|
||||
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);
|
||||
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:
|
||||
WinHttpCloseHandle(req);
|
||||
WinHttpCloseHandle(con);
|
||||
|
@ -1648,28 +1688,33 @@ static void test_resolve_timeout(void)
|
|||
DWORD timeout;
|
||||
BOOL ret;
|
||||
|
||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
||||
if (! proxy_active())
|
||||
{
|
||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
||||
|
||||
timeout = 10000;
|
||||
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &timeout, sizeof(timeout));
|
||||
ok(ret, "failed to set resolve timeout %u\n", GetLastError());
|
||||
timeout = 10000;
|
||||
ret = WinHttpSetOption(ses, WINHTTP_OPTION_RESOLVE_TIMEOUT, &timeout, sizeof(timeout));
|
||||
ok(ret, "failed to set resolve timeout %u\n", GetLastError());
|
||||
|
||||
con = WinHttpConnect(ses, nxdomain, 0, 0);
|
||||
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
||||
con = WinHttpConnect(ses, nxdomain, 0, 0);
|
||||
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
|
||||
|
||||
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
||||
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
|
||||
ok(req != NULL, "failed to open a request %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
||||
ok(!ret, "sent request\n");
|
||||
ok(GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED,
|
||||
"expected ERROR_WINHTTP_NAME_NOT_RESOLVED got %u\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
|
||||
ok(!ret, "sent request\n");
|
||||
ok(GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED,
|
||||
"expected ERROR_WINHTTP_NAME_NOT_RESOLVED got %u\n", GetLastError());
|
||||
|
||||
WinHttpCloseHandle(req);
|
||||
WinHttpCloseHandle(con);
|
||||
WinHttpCloseHandle(ses);
|
||||
WinHttpCloseHandle(req);
|
||||
WinHttpCloseHandle(con);
|
||||
WinHttpCloseHandle(ses);
|
||||
}
|
||||
else
|
||||
skip("Skipping host resolution tests, host resolution preformed by proxy\n");
|
||||
|
||||
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
|
||||
ok(ses != NULL, "failed to open session %u\n", GetLastError());
|
||||
|
|
Loading…
Reference in a new issue