Added patches for additional tests of wininet cookie/header/authentication handling, in preparation of various cleanup patches.

This commit is contained in:
Sebastian Lackner 2015-05-15 21:38:48 +02:00
parent 90bf076dfc
commit 26e06cc151
5 changed files with 449 additions and 0 deletions

2
debian/changelog vendored
View File

@ -34,6 +34,8 @@ wine-staging (1.7.43) UNRELEASED; urgency=low
* Added patch with tests for
imagehlp.{ImageLoad,ImageUnload,GetImageUnusedHeaderBytes}.
* Added patch to fix memory leak in wininet.HTTP_InsertCookies.
* Added patches for additional tests of wininet cookie/header/authentication
handling, in preparation of various cleanup patches.
* Removed patch to use lockfree implementation for FD cache (accepted
upstream).
* Removed patch to properly handle closing sockets during a select call

View File

@ -276,6 +276,7 @@ patch_enable_all ()
enable_winex11_Window_Style="$1"
enable_winex11_XEMBED="$1"
enable_winex11_wglShareLists="$1"
enable_wininet_Cleanup="$1"
enable_wininet_Memory_Leak="$1"
enable_wininet_ParseX509EncodedCertificateForListBoxEntry="$1"
enable_winmm_Delay_Import_Depends="$1"
@ -896,6 +897,9 @@ patch_enable ()
winex11-wglShareLists)
enable_winex11_wglShareLists="$2"
;;
wininet-Cleanup)
enable_wininet_Cleanup="$2"
;;
wininet-Memory_Leak)
enable_wininet_Memory_Leak="$2"
;;
@ -5496,6 +5500,22 @@ if test "$enable_winex11_wglShareLists" -eq 1; then
) >> "$patchlist"
fi
# Patchset wininet-Cleanup
# |
# | Modified files:
# | * dlls/wininet/tests/http.c
# |
if test "$enable_wininet_Cleanup" -eq 1; then
patch_apply wininet-Cleanup/0001-wininet-tests-Add-more-tests-for-cookies.patch
patch_apply wininet-Cleanup/0002-wininet-tests-Add-tests-for-overriding-host-header.patch
patch_apply wininet-Cleanup/0003-wininet-tests-Test-auth-credential-reusage-with-host.patch
(
echo '+ { "Michael Müller", "wininet/tests: Add more tests for cookies.", 1 },';
echo '+ { "Michael Müller", "wininet/tests: Add tests for overriding host header.", 1 },';
echo '+ { "Michael Müller", "wininet/tests: Test auth credential reusage with host override.", 1 },';
) >> "$patchlist"
fi
# Patchset wininet-Memory_Leak
# |
# | Modified files:

View File

@ -0,0 +1,145 @@
From abee6ead437c5bb951ef80093c464712e41ef270 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 15 May 2015 20:37:19 +0200
Subject: wininet/tests: Add more tests for cookies.
---
dlls/wininet/tests/http.c | 92 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 89 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 3b2f9a5..bbfdaf0 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1974,6 +1974,14 @@ static const char okmsg2[] =
"Set-Cookie: two\r\n"
"\r\n";
+static const char okmsg_cookie_path[] =
+"HTTP/1.1 200 OK\r\n"
+"Date: Mon, 01 Dec 2008 13:44:34 GMT\r\n"
+"Server: winetest\r\n"
+"Content-Length: 0\r\n"
+"Set-Cookie: subcookie2=data; path=/test_cookie_set_path\r\n"
+"\r\n";
+
static const char notokmsg[] =
"HTTP/1.1 400 Bad Request\r\n"
"Server: winetest\r\n"
@@ -2335,6 +2343,32 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
+ if (strstr(buffer, "/test_cookie_path1"))
+ {
+ if (strstr(buffer, "subcookie=data"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_path2"))
+ {
+ if (strstr(buffer, "subcookie2=data"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_set_path"))
+ {
+ send(c, okmsg_cookie_path, sizeof okmsg_cookie_path-1, 0);
+ }
+ if (strstr(buffer, "/test_cookie_merge"))
+ {
+ if (strstr(buffer, "subcookie=data") &&
+ !strstr(buffer, "manual_cookie=test"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
shutdown(c, 2);
closesocket(c);
c = -1;
@@ -3545,7 +3579,7 @@ static void test_cookie_header(int port)
HINTERNET ses, con, req;
DWORD size, error;
BOOL ret;
- char buffer[64];
+ char buffer[256];
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
@@ -3573,7 +3607,7 @@ static void test_cookie_header(int port)
size = sizeof(buffer);
ret = HttpQueryInfoA(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
- ok(!strcmp(buffer, "cookie=not biscuit"), "got '%s' expected \'cookie=not biscuit\'\n", buffer);
+ ok(!!strstr(buffer, "cookie=not biscuit"), "got '%s' expected \'cookie=not biscuit\'\n", buffer);
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
@@ -3584,9 +3618,61 @@ static void test_cookie_header(int port)
size = sizeof(buffer);
ret = HttpQueryInfoA(req, HTTP_QUERY_COOKIE | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL);
ok(ret, "HttpQueryInfo failed: %u\n", GetLastError());
- ok(!strcmp(buffer, "cookie=biscuit"), "got '%s' expected \'cookie=biscuit\'\n", buffer);
+ ok(!strstr(buffer, "cookie=not biscuit"), "'%s' should not contain \'cookie=not biscuit\'\n", buffer);
+ ok(!!strstr(buffer, "cookie=biscuit"), "'%s' should contain \'cookie=biscuit\'\n", buffer);
InternetCloseHandle(req);
+
+ InternetSetCookieA("http://localhost/testCCCC", "subcookie", "data");
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path1", 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\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path1/abc", 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\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_set_path", 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\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_path2", 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\n");
+
+ test_status_code(req, 400);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_cookie_merge", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, "Cookie: manual_cookie=test\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed: %u\n", GetLastError());
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
InternetCloseHandle(con);
InternetCloseHandle(ses);
}
--
2.4.0

View File

@ -0,0 +1,160 @@
From e6ff4bc0e13f286c8c64fbcbb0835e275286464f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 15 May 2015 21:07:19 +0200
Subject: wininet/tests: Add tests for overriding host header.
---
dlls/wininet/tests/http.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index bbfdaf0..94f4ae9 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2043,6 +2043,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
WSADATA wsaData;
int last_request = 0;
char host_header[22];
+ char host_header_override[30];
static BOOL test_b = FALSE;
static int test_no_cache = 0;
@@ -2069,6 +2070,7 @@ static DWORD CALLBACK server_thread(LPVOID param)
SetEvent(si->hEvent);
sprintf(host_header, "Host: localhost:%d", si->port);
+ sprintf(host_header_override, "Host: test.local:%d\r\n", si->port);
do
{
@@ -2369,6 +2371,13 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
+ if (strstr(buffer, "/test_host_override"))
+ {
+ if (strstr(buffer, host_header_override))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
shutdown(c, 2);
closesocket(c);
c = -1;
@@ -2964,6 +2973,105 @@ static void test_connection_header(int port)
InternetCloseHandle(ses);
}
+static void test_header_override(int port)
+{
+ char buffer[128], host_header_override[30], full_url[128];
+ HINTERNET ses, con, req;
+ DWORD size, count, err;
+ BOOL ret;
+
+ sprintf(host_header_override, "Host: test.local:%d\r\n", port);
+ sprintf(full_url, "http://localhost:%d/test_host_override", port);
+
+ 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, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ memset(buffer, 0, sizeof(buffer));
+ size = sizeof(buffer)-1;
+ count = 0;
+ ret = HttpQueryInfoA(req, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &count);
+ err = GetLastError();
+ todo_wine ok(!ret, "HttpQueryInfo succeeded\n");
+ todo_wine ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error ERROR_HTTP_HEADER_NOT_FOUND, got %d\n", err);
+
+ memset(buffer, 0, sizeof(buffer));
+ size = sizeof(buffer)-1;
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_URL, buffer, &size);
+ ok(ret, "InternetQueryOption failed\n");
+ ok(!strcmp(full_url, buffer), "Expected %s, got %s\n", full_url, buffer);
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ memset(buffer, 0, sizeof(buffer));
+ size = sizeof(buffer)-1;
+ count = 0;
+ ret = HttpQueryInfoA(req, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &count);
+ ok(ret, "HttpQueryInfo failed\n");
+
+ memset(buffer, 0, sizeof(buffer));
+ size = sizeof(buffer)-1;
+ ret = InternetQueryOptionA(req, INTERNET_OPTION_URL, buffer, &size);
+ ok(ret, "InternetQueryOption failed\n");
+ todo_wine ok(!strcmp(full_url, buffer), "Expected %s, got %s\n", full_url, buffer);
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code_todo(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 400);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code(req, 200);
+ InternetCloseHandle(req);
+
+ req = HttpOpenRequestA(con, NULL, "/test_host_override", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(req != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_REPLACE);
+ err = GetLastError();
+ todo_wine ok(!ret, "HttpAddRequestHeaders succeeded\n");
+ todo_wine ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error ERROR_HTTP_HEADER_NOT_FOUND, got %d\n", err);
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ test_status_code_todo(req, 400);
+ InternetCloseHandle(req);
+
+ InternetCloseHandle( con );
+ InternetCloseHandle( ses );
+}
+
static void test_http1_1(int port)
{
HINTERNET ses, con, req;
@@ -4392,6 +4500,7 @@ static void test_http_connection(void)
test_basic_request(si.port, "GET", "/test6");
test_basic_request(si.port, "GET", "/testF");
test_connection_header(si.port);
+ test_header_override(si.port);
test_http1_1(si.port);
test_cookie_header(si.port);
test_basic_authentication(si.port);
--
2.4.0

View File

@ -0,0 +1,122 @@
From a380fe97276133844c8321d14bf37563ce01e8b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 15 May 2015 21:18:37 +0200
Subject: wininet/tests: Test auth credential reusage with host override.
---
dlls/wininet/tests/http.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 94f4ae9..4c515b7 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2378,6 +2378,20 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
+ if (strstr(buffer, "HEAD /test_auth_host1"))
+ {
+ if (strstr(buffer, "Authorization: Basic dGVzdDE6cGFzcw=="))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, noauthmsg, sizeof noauthmsg-1, 0);
+ }
+ if (strstr(buffer, "HEAD /test_auth_host2"))
+ {
+ if (strstr(buffer, "Authorization: Basic dGVzdDE6cGFzczI="))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, noauthmsg, sizeof noauthmsg-1, 0);
+ }
shutdown(c, 2);
closesocket(c);
c = -1;
@@ -3070,6 +3084,84 @@ static void test_header_override(int port)
InternetCloseHandle( con );
InternetCloseHandle( ses );
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA(ses, "localhost", port, "test1", "pass", INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA( con, "HEAD", "/test_auth_host1", NULL, NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA( ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host1", NULL, NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
+ ok( ret, "HttpSendRequestA failed %u\n", GetLastError() );
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA(ses, "localhost", port, "test1", "pass2", INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL, NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
+ ok(ret, "HttpAddRequestHeaders failed\n");
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+
+ ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(ses != NULL, "InternetOpenA failed\n");
+
+ con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(con != NULL, "InternetConnectA failed %u\n", GetLastError());
+
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL, NULL, NULL, 0, 0);
+ ok(req != NULL, "HttpOpenRequestA failed %u\n", GetLastError());
+
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequestA failed %u\n", GetLastError());
+
+ test_status_code(req, 200);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
}
static void test_http1_1(int port)
--
2.4.0