2024-02-19 14:23:40 -08:00
|
|
|
From ce812bbd59547f6fb224da3351586912f35d2e33 Mon Sep 17 00:00:00 2001
|
2015-05-15 12:38:48 -07:00
|
|
|
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
|
|
|
Date: Fri, 15 May 2015 21:18:37 +0200
|
2019-09-04 15:52:02 -07:00
|
|
|
Subject: [PATCH] wininet/tests: Test auth credential reusage with host
|
|
|
|
override.
|
2015-05-15 12:38:48 -07:00
|
|
|
|
|
|
|
---
|
2024-02-19 14:23:40 -08:00
|
|
|
dlls/wininet/tests/http.c | 92 +++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 92 insertions(+)
|
2015-05-15 12:38:48 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
|
2024-02-19 14:23:40 -08:00
|
|
|
index 4c2c33ddd84..47236d5184d 100644
|
2015-05-15 12:38:48 -07:00
|
|
|
--- a/dlls/wininet/tests/http.c
|
|
|
|
+++ b/dlls/wininet/tests/http.c
|
2024-02-19 14:23:40 -08:00
|
|
|
@@ -2899,6 +2899,20 @@ static DWORD CALLBACK server_thread(LPVOID param)
|
2019-09-04 15:52:02 -07:00
|
|
|
sprintf(msg, largemsg, content_length);
|
|
|
|
send(c, msg, strlen(msg), 0);
|
|
|
|
}
|
2015-05-15 12:38:48 -07:00
|
|
|
+ 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);
|
|
|
|
+ }
|
2024-02-19 14:23:40 -08:00
|
|
|
if (strstr(buffer, "GET /proxy.pac"))
|
|
|
|
{
|
|
|
|
char script[sizeof(proxy_pac) + 16];
|
|
|
|
@@ -3609,6 +3623,84 @@ static void test_header_override(int port)
|
2015-06-25 07:37:32 -07:00
|
|
|
InternetCloseHandle(req);
|
|
|
|
InternetCloseHandle(con);
|
|
|
|
InternetCloseHandle(ses);
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ 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);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(con != NULL, "InternetConnectA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ req = HttpOpenRequestA( con, "HEAD", "/test_auth_host1", NULL, NULL, NULL, 0, 0);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(ret, "HttpSendRequestA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ 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);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(con != NULL, "InternetConnectA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host1", NULL, NULL, NULL, 0, 0);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
|
|
|
|
+ ok(ret, "HttpAddRequestHeaders failed\n");
|
|
|
|
+
|
|
|
|
+ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 );
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok( ret, "HttpSendRequestA failed %lu\n", GetLastError() );
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ 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);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(con != NULL, "InternetConnectA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL, NULL, NULL, 0, 0);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_ADD);
|
|
|
|
+ ok(ret, "HttpAddRequestHeaders failed\n");
|
|
|
|
+
|
|
|
|
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(ret, "HttpSendRequestA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ 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);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(con != NULL, "InternetConnectA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ req = HttpOpenRequestA(con, "HEAD", "/test_auth_host2", NULL, NULL, NULL, 0, 0);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(req != NULL, "HttpOpenRequestA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
|
2022-03-15 18:17:43 -07:00
|
|
|
+ ok(ret, "HttpSendRequestA failed %lu\n", GetLastError());
|
2015-05-15 12:38:48 -07:00
|
|
|
+
|
|
|
|
+ test_status_code(req, 200);
|
|
|
|
+
|
|
|
|
+ InternetCloseHandle(req);
|
|
|
|
+ InternetCloseHandle(con);
|
|
|
|
+ InternetCloseHandle(ses);
|
|
|
|
}
|
|
|
|
|
2016-05-14 17:23:15 -07:00
|
|
|
static void test_connection_closing(int port)
|
2015-05-15 12:38:48 -07:00
|
|
|
--
|
2024-02-19 14:23:40 -08:00
|
|
|
2.43.0
|
2015-05-15 12:38:48 -07:00
|
|
|
|