https://git.reactos.org/?p=reactos.git;a=commitdiff;h=45c19ac584a4cb0a232e1…
commit 45c19ac584a4cb0a232e16e9f68edcc8c4ca8888
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Tue Dec 8 18:22:03 2020 +0100
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Tue Jan 5 11:03:13 2021 +0100
[WINESYNC] wininet/tests: Add more tests for cookies.
wine-staging patch by Michael Müller <michael(a)fds-team.de>
---
modules/rostests/winetests/wininet/http.c | 92 +++++++++++++-
...-wininet_tests__Add_more_tests_for_cookies.diff | 133 +++++++++++++++++++++
2 files changed, 222 insertions(+), 3 deletions(-)
diff --git a/modules/rostests/winetests/wininet/http.c
b/modules/rostests/winetests/wininet/http.c
index 882f293b856..c7cdea84ce3 100644
--- a/modules/rostests/winetests/wininet/http.c
+++ b/modules/rostests/winetests/wininet/http.c
@@ -2130,6 +2130,14 @@ static const char largemsg[] =
"Content-Length: %I64u\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"
@@ -2509,6 +2517,32 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, noauthmsg, sizeof noauthmsg-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);
+ }
if (strstr(buffer, "/test_host_override"))
{
if (strstr(buffer, host_header_override))
@@ -3887,7 +3921,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");
@@ -3915,7 +3949,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());
@@ -3926,9 +3960,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);
}
diff --git
a/sdk/tools/winesync/wininet_staging/0001-wininet_tests__Add_more_tests_for_cookies.diff
b/sdk/tools/winesync/wininet_staging/0001-wininet_tests__Add_more_tests_for_cookies.diff
new file mode 100644
index 00000000000..ca5ed5a6d44
--- /dev/null
+++
b/sdk/tools/winesync/wininet_staging/0001-wininet_tests__Add_more_tests_for_cookies.diff
@@ -0,0 +1,133 @@
+diff --git a/modules/rostests/winetests/wininet/http.c
b/modules/rostests/winetests/wininet/http.c
+index a5f5215..9ef56ce 100644
+--- a/modules/rostests/winetests/wininet/http.c
++++ b/modules/rostests/winetests/wininet/http.c
+@@ -2129,6 +2129,14 @@ static const char largemsg[] =
+ "Content-Length: %I64u\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"
+@@ -2508,6 +2516,32 @@ static DWORD CALLBACK server_thread(LPVOID param)
+ else
+ send(c, noauthmsg, sizeof noauthmsg-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);
++ }
+ if (strstr(buffer, "/test_host_override"))
+ {
+ if (strstr(buffer, host_header_override))
+@@ -3886,7 +3920,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");
+@@ -3914,7 +3948,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());
+@@ -3925,9 +3959,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);
+ }