2015-05-15 17:07:36 -07:00
|
|
|
From 92d5f7bb41006cbe61ef3226abdb36bbb13d26dd 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
|
|
|
|
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
|
|
|
|
|