https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0adc3ed6ba137516f2676…
commit 0adc3ed6ba137516f2676fe2a8f9933643cf671e
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: Test auth credential reusage with host override.
wine-staging patch by Michael Müller <michael(a)fds-team.de>
---
modules/rostests/winetests/wininet/http.c | 93 ++++++++++++++++
...auth_credential_reusage_with_host_override.diff | 117 +++++++++++++++++++++
2 files changed, 210 insertions(+)
diff --git a/modules/rostests/winetests/wininet/http.c
b/modules/rostests/winetests/wininet/http.c
index c7cdea84ce3..11d9f8b18db 100644
--- a/modules/rostests/winetests/wininet/http.c
+++ b/modules/rostests/winetests/wininet/http.c
@@ -2574,12 +2574,27 @@ static DWORD CALLBACK server_thread(LPVOID param)
{
send(c, okmsg, sizeof(okmsg)-1, 0);
}
+
if (strstr(buffer, "HEAD /test_large_content"))
{
char msg[sizeof(largemsg) + 16];
sprintf(msg, largemsg, content_length);
send(c, msg, strlen(msg), 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;
@@ -3278,6 +3293,84 @@ static void test_header_override(int port)
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",
"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_connection_closing(int port)
diff --git
a/sdk/tools/winesync/wininet_staging/0002-wininet_tests__Test_auth_credential_reusage_with_host_override.diff
b/sdk/tools/winesync/wininet_staging/0002-wininet_tests__Test_auth_credential_reusage_with_host_override.diff
new file mode 100644
index 00000000000..4fe77d35487
--- /dev/null
+++
b/sdk/tools/winesync/wininet_staging/0002-wininet_tests__Test_auth_credential_reusage_with_host_override.diff
@@ -0,0 +1,117 @@
+diff --git a/modules/rostests/winetests/wininet/http.c
b/modules/rostests/winetests/wininet/http.c
+index 9ef56ce..79fd5e9 100644
+--- a/modules/rostests/winetests/wininet/http.c
++++ b/modules/rostests/winetests/wininet/http.c
+@@ -2573,12 +2573,27 @@ static DWORD CALLBACK server_thread(LPVOID param)
+ {
+ send(c, okmsg, sizeof(okmsg)-1, 0);
+ }
++
+ if (strstr(buffer, "HEAD /test_large_content"))
+ {
+ char msg[sizeof(largemsg) + 16];
+ sprintf(msg, largemsg, content_length);
+ send(c, msg, strlen(msg), 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;
+@@ -3277,6 +3292,84 @@ static void test_header_override(int port)
+ 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",
"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_connection_closing(int port)