https://git.reactos.org/?p=reactos.git;a=commitdiff;h=69d123ae2547edb8b80d0…
commit 69d123ae2547edb8b80d013fe6e2ecd3bf3a8b47
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Sat Jan 20 13:56:09 2018 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sat Jan 20 13:56:09 2018 +0100
[WINHTTP_WINETEST] Sync with Wine 3.0. CORE-14225
---
modules/rostests/winetests/winhttp/notification.c | 6 +-
modules/rostests/winetests/winhttp/winhttp.c | 71 ++++++++++++++++++++++-
2 files changed, 72 insertions(+), 5 deletions(-)
diff --git a/modules/rostests/winetests/winhttp/notification.c
b/modules/rostests/winetests/winhttp/notification.c
index 79f6b8c935..bcb7a0b318 100644
--- a/modules/rostests/winetests/winhttp/notification.c
+++ b/modules/rostests/winetests/winhttp/notification.c
@@ -944,7 +944,7 @@ static void _read_request_data(struct test_request *req, struct info
*info, cons
WaitForSingleObject( info->wait, INFINITE );
len = strlen(expected_data);
- ok(!memcmp(buffer, expected_data, len), "unexpeceted data\n");
+ ok(!memcmp(buffer, expected_data, len), "unexpected data\n");
}
static void test_persistent_connection(int port)
@@ -1033,14 +1033,16 @@ START_TEST (notification)
ret = WaitForSingleObject( si.event, 10000 );
ok(ret == WAIT_OBJECT_0, "failed to start winhttp test server %u\n",
GetLastError());
if (ret != WAIT_OBJECT_0)
+ {
+ CloseHandle(thread);
return;
+ }
#ifdef __REACTOS__
if (!winetest_interactive)
{
skip("Skipping test_persistent_connection due to hang. See
ROSTESTS-295.\n");
}
-else
#endif
test_persistent_connection( si.port );
diff --git a/modules/rostests/winetests/winhttp/winhttp.c
b/modules/rostests/winetests/winhttp/winhttp.c
index 8b2b601ba6..d9024dfb7d 100644
--- a/modules/rostests/winetests/winhttp/winhttp.c
+++ b/modules/rostests/winetests/winhttp/winhttp.c
@@ -326,7 +326,7 @@ static void test_SendRequest (void)
static CHAR post_data[] = "mode=Test";
static const char test_post[] = "mode => Test\0\n";
HINTERNET session, request, connection;
- DWORD header_len, optional_len, total_len, bytes_rw, size, err;
+ DWORD header_len, optional_len, total_len, bytes_rw, size, err, disable;
DWORD_PTR context;
BOOL ret;
CHAR buffer[256];
@@ -357,6 +357,12 @@ static void test_SendRequest (void)
ret = WinHttpSetOption(request, WINHTTP_OPTION_CONTEXT_VALUE, &context,
sizeof(context));
ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
+ /* writing more data than promised by the content-length header causes an error when
the connection
+ is resued, so disable keep-alive */
+ disable = WINHTTP_DISABLE_KEEP_ALIVE;
+ ret = WinHttpSetOption(request, WINHTTP_OPTION_DISABLE_FEATURE, &disable,
sizeof(disable));
+ ok(ret, "WinHttpSetOption failed: %u\n", GetLastError());
+
context++;
ret = WinHttpSendRequest(request, content_type, header_len, post_data, optional_len,
total_len, context);
err = GetLastError();
@@ -575,7 +581,7 @@ static void test_WinHttpAddHeaders(void)
SetLastError(0xdeadbeef);
ret = WinHttpAddRequestHeaders(request, test_headers[0], -1L,
WINHTTP_ADDREQ_FLAG_ADD);
err = GetLastError();
- ok(ret, "WinHttpAddRequestHeader failed to add new header, got %d with error
%u.\n", ret, err);
+ ok(ret, "WinHttpAddRequestHeaders failed to add new header, got %d with error
%u.\n", ret, err);
ok(err == ERROR_SUCCESS || broken(err == 0xdeadbeef) /* < win7 */, "got
%u\n", err);
index = 0;
@@ -981,7 +987,7 @@ static void test_secure_connection(void)
{
static const char data_start[] = "<!DOCTYPE html PUBLIC";
HINTERNET ses, con, req;
- DWORD size, status, policy, bitness, read_size, err, available_size;
+ DWORD size, status, policy, bitness, read_size, err, available_size, protocols;
BOOL ret;
CERT_CONTEXT *cert;
WINHTTP_CERTIFICATE_INFO info;
@@ -994,6 +1000,11 @@ static void test_secure_connection(void)
ret = WinHttpSetOption(ses, WINHTTP_OPTION_REDIRECT_POLICY, &policy,
sizeof(policy));
ok(ret, "failed to set redirect policy %u\n", GetLastError());
+ protocols = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;
+ ret = WinHttpSetOption(ses, WINHTTP_OPTION_SECURE_PROTOCOLS, &protocols,
sizeof(protocols));
+ err = GetLastError();
+ ok(ret || err == ERROR_INVALID_PARAMETER /* < win7 */, "failed to set
protocols %u\n", err);
+
con = WinHttpConnect(ses, test_winehq, 443, 0);
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
@@ -2077,6 +2088,7 @@ static const char largeauth[] =
static const char unauthorized[] = "Unauthorized";
static const char hello_world[] = "Hello World";
+static const char auth_unseen[] = "Auth Unseen";
struct server_info
{
@@ -2136,6 +2148,15 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, okmsg, sizeof okmsg - 1, 0);
send(c, page1, sizeof page1 - 1, 0);
}
+ if (strstr(buffer, "/auth_with_creds"))
+ {
+ send(c, okauthmsg, sizeof okauthmsg - 1, 0);
+ if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
+ send(c, hello_world, sizeof hello_world - 1, 0);
+ else
+ send(c, auth_unseen, sizeof auth_unseen - 1, 0);
+ continue;
+ }
if (strstr(buffer, "/auth"))
{
if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
@@ -2316,6 +2337,7 @@ static void test_basic_request(int port, const WCHAR *verb, const
WCHAR *path)
static void test_basic_authentication(int port)
{
static const WCHAR authW[] =
{'/','a','u','t','h',0};
+ static const WCHAR auth_with_credsW[] =
{'/','a','u','t','h','_','w','i','t','h','_','c','r','e','d','s',0};
static WCHAR userW[] = {'u','s','e','r',0};
static WCHAR passW[] = {'p','w','d',0};
static WCHAR pass2W[] = {'p','w','d','2',0};
@@ -2479,6 +2501,45 @@ static void test_basic_authentication(int port)
WinHttpCloseHandle(con);
WinHttpCloseHandle(ses);
+ /* now set the credentials first to show that they get sent with the first request
*/
+ ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
+ ok(ses != NULL, "failed to open session %u\n", GetLastError());
+
+ con = WinHttpConnect(ses, localhostW, port, 0);
+ ok(con != NULL, "failed to open a connection %u\n", GetLastError());
+
+ req = WinHttpOpenRequest(con, NULL, auth_with_credsW, NULL, NULL, NULL, 0);
+ ok(req != NULL, "failed to open a request %u\n", GetLastError());
+
+ ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER,
WINHTTP_AUTH_SCHEME_BASIC, userW, passW, NULL);
+ ok(ret, "failed to set credentials %u\n", GetLastError());
+
+ ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
+ ok(ret, "failed to send request %u\n", GetLastError());
+
+ ret = WinHttpReceiveResponse(req, NULL);
+ ok(ret, "failed to receive response %u\n", GetLastError());
+
+ status = 0xdeadbeef;
+ size = sizeof(status);
+ ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER,
NULL, &status, &size, NULL);
+ ok(ret, "failed to query status code %u\n", GetLastError());
+ ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
+
+ size = 0;
+ ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
+ error = GetLastError();
+ ok(ret || broken(error == ERROR_WINHTTP_SHUTDOWN || error == ERROR_WINHTTP_TIMEOUT)
/* XP */, "failed to read data %u\n", GetLastError());
+ if (ret)
+ {
+ ok(size == 11, "expected 11, got %u\n", size);
+ ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
+ }
+
+ WinHttpCloseHandle(req);
+ WinHttpCloseHandle(con);
+ WinHttpCloseHandle(ses);
+
/* credentials set with WinHttpSetCredentials take precedence over those set through
options */
ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
@@ -4426,7 +4487,10 @@ START_TEST (winhttp)
ret = WaitForSingleObject(si.event, 10000);
ok(ret == WAIT_OBJECT_0, "failed to start winhttp test server %u\n",
GetLastError());
if (ret != WAIT_OBJECT_0)
+ {
+ CloseHandle(thread);
return;
+ }
test_IWinHttpRequest(si.port);
test_connection_info(si.port);
@@ -4446,4 +4510,5 @@ START_TEST (winhttp)
test_basic_request(si.port, NULL, quitW);
WaitForSingleObject(thread, 3000);
+ CloseHandle(thread);
}