https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ff5fa7aea456e4cfecbe2401725b31b1ba664d3b

commit ff5fa7aea456e4cfecbe2401725b31b1ba664d3b
Author:     winesync <[email protected]>
AuthorDate: Tue Dec 8 18:22:04 2020 +0100
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Tue Jan 5 11:03:13 2021 +0100

    [WINESYNC] wininet/tests: Check cookie behaviour when overriding host.
    
    wine-staging patch by Michael Müller <[email protected]>
---
 modules/rostests/winetests/wininet/http.c          |  95 ++++++++++++++++
 ...heck_cookie_behaviour_when_overriding_host.diff | 120 +++++++++++++++++++++
 2 files changed, 215 insertions(+)

diff --git a/modules/rostests/winetests/wininet/http.c 
b/modules/rostests/winetests/wininet/http.c
index 11d9f8b18db..ce2dfd477c3 100644
--- a/modules/rostests/winetests/wininet/http.c
+++ b/modules/rostests/winetests/wininet/http.c
@@ -2138,6 +2138,14 @@ static const char okmsg_cookie_path[] =
 "Set-Cookie: subcookie2=data; path=/test_cookie_set_path\r\n"
 "\r\n";
 
+static const char okmsg_cookie[] =
+"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: testcookie=testvalue\r\n"
+"\r\n";
+
 static const char notokmsg[] =
 "HTTP/1.1 400 Bad Request\r\n"
 "Server: winetest\r\n"
@@ -2543,6 +2551,25 @@ static DWORD CALLBACK server_thread(LPVOID param)
              else
                  send(c, notokmsg, sizeof notokmsg-1, 0);
         }
+        if (strstr(buffer, "/test_cookie_set_host_override"))
+        {
+            send(c, okmsg_cookie, sizeof okmsg_cookie-1, 0);
+        }
+        if (strstr(buffer, "/test_cookie_check_host_override"))
+        {
+            if (strstr(buffer, "Cookie:") && strstr(buffer, 
"testcookie=testvalue"))
+                send(c, okmsg, sizeof okmsg-1, 0);
+            else
+                send(c, notokmsg, sizeof notokmsg-1, 0);
+        }
+        if (strstr(buffer, "/test_cookie_check_different_host"))
+        {
+            if (!strstr(buffer, "foo") &&
+                strstr(buffer, "cookie=biscuit"))
+                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))
@@ -3290,6 +3317,74 @@ static void test_header_override(int port)
         test_status_code(req, 400);
     }
 
+    InternetCloseHandle(req);
+    InternetSetCookieA("http://localhost";, "cookie", "biscuit");
+    req = HttpOpenRequestA(con, NULL, "/testC", 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_cookie_set_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_cookie_check_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_todo(req, 200);
+
+    InternetCloseHandle(req);
+    req = HttpOpenRequestA(con, NULL, "/test_cookie_check_host_override", 
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_todo(req, 200);
+
+    InternetCloseHandle(req);
+    InternetSetCookieA("http://test.local";, "foo", "bar");
+    req = HttpOpenRequestA(con, NULL, "/test_cookie_check_different_host", 
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_check_different_host", 
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);
     InternetCloseHandle(con);
     InternetCloseHandle(ses);
diff --git 
a/sdk/tools/winesync/wininet_staging/0003-wininet_tests__Check_cookie_behaviour_when_overriding_host.diff
 
b/sdk/tools/winesync/wininet_staging/0003-wininet_tests__Check_cookie_behaviour_when_overriding_host.diff
new file mode 100644
index 00000000000..f9d45bd4382
--- /dev/null
+++ 
b/sdk/tools/winesync/wininet_staging/0003-wininet_tests__Check_cookie_behaviour_when_overriding_host.diff
@@ -0,0 +1,120 @@
+diff --git a/modules/rostests/winetests/wininet/http.c 
b/modules/rostests/winetests/wininet/http.c
+index 79fd5e9..510c3ac 100644
+--- a/modules/rostests/winetests/wininet/http.c
++++ b/modules/rostests/winetests/wininet/http.c
+@@ -2137,6 +2137,14 @@ static const char okmsg_cookie_path[] =
+ "Set-Cookie: subcookie2=data; path=/test_cookie_set_path\r\n"
+ "\r\n";
+ 
++static const char okmsg_cookie[] =
++"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: testcookie=testvalue\r\n"
++"\r\n";
++
+ static const char notokmsg[] =
+ "HTTP/1.1 400 Bad Request\r\n"
+ "Server: winetest\r\n"
+@@ -2542,6 +2550,25 @@ static DWORD CALLBACK server_thread(LPVOID param)
+              else
+                  send(c, notokmsg, sizeof notokmsg-1, 0);
+         }
++        if (strstr(buffer, "/test_cookie_set_host_override"))
++        {
++            send(c, okmsg_cookie, sizeof okmsg_cookie-1, 0);
++        }
++        if (strstr(buffer, "/test_cookie_check_host_override"))
++        {
++            if (strstr(buffer, "Cookie:") && strstr(buffer, 
"testcookie=testvalue"))
++                send(c, okmsg, sizeof okmsg-1, 0);
++            else
++                send(c, notokmsg, sizeof notokmsg-1, 0);
++        }
++        if (strstr(buffer, "/test_cookie_check_different_host"))
++        {
++            if (!strstr(buffer, "foo") &&
++                strstr(buffer, "cookie=biscuit"))
++                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))
+@@ -3290,6 +3317,74 @@ static void test_header_override(int port)
+     }
+ 
+     InternetCloseHandle(req);
++    InternetSetCookieA("http://localhost";, "cookie", "biscuit");
++    req = HttpOpenRequestA(con, NULL, "/testC", 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_cookie_set_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_cookie_check_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_todo(req, 200);
++
++    InternetCloseHandle(req);
++    req = HttpOpenRequestA(con, NULL, "/test_cookie_check_host_override", 
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_todo(req, 200);
++
++    InternetCloseHandle(req);
++    InternetSetCookieA("http://test.local";, "foo", "bar");
++    req = HttpOpenRequestA(con, NULL, "/test_cookie_check_different_host", 
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_check_different_host", 
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);
+     InternetCloseHandle(con);
+     InternetCloseHandle(ses);
+ 

Reply via email to