Commit 12c983a6 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

winhttp/tests: Send a not empty payload in the server authorization response,…

winhttp/tests: Send a not empty payload in the server authorization response, check the received data on the client side. Signed-off-by: 's avatarDmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: 's avatarHans Leidekker <hans@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 545a4175
......@@ -2005,12 +2005,16 @@ static const char noauthmsg[] =
"Server: winetest\r\n"
"Connection: close\r\n"
"WWW-Authenticate: Basic realm=\"placebo\"\r\n"
"Content-Length: 12\r\n"
"Content-Type: text/plain\r\n"
"\r\n";
static const char okauthmsg[] =
"HTTP/1.1 200 OK\r\n"
"Server: winetest\r\n"
"Connection: close\r\n"
"Content-Length: 11\r\n"
"Content-Type: text/plain\r\n"
"\r\n";
static const char headmsg[] =
......@@ -2018,6 +2022,9 @@ static const char headmsg[] =
"Content-Length: 100\r\n"
"\r\n";
static const char unauthorized[] = "Unauthorized";
static const char hello_world[] = "Hello World";
struct server_info
{
HANDLE event;
......@@ -2079,9 +2086,15 @@ static DWORD CALLBACK server_thread(LPVOID param)
if (strstr(buffer, "/auth"))
{
if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
{
send(c, okauthmsg, sizeof okauthmsg - 1, 0);
send(c, hello_world, sizeof hello_world - 1, 0);
}
else
{
send(c, noauthmsg, sizeof noauthmsg - 1, 0);
send(c, unauthorized, sizeof unauthorized - 1, 0);
}
}
if (strstr(buffer, "/big"))
{
......@@ -2223,6 +2236,7 @@ static void test_basic_authentication(int port)
static WCHAR pass2W[] = {'p','w','d','2',0};
HINTERNET ses, con, req;
DWORD status, size, error, supported, first, target;
char buffer[32];
BOOL ret;
ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
......@@ -2295,6 +2309,14 @@ static void test_basic_authentication(int port)
ok(ret, "failed to query status code %u\n", GetLastError());
ok(status == HTTP_STATUS_DENIED, "request failed unexpectedly %u\n", status);
size = 0;
ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
ok(ret, "failed to read data %u\n", GetLastError());
todo_wine
ok(size == 12, "expected 12, got %u\n", size);
todo_wine
ok(!memcmp(buffer, unauthorized, 12), "got %s\n", buffer);
supported = first = target = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
......@@ -2356,6 +2378,12 @@ static void test_basic_authentication(int port)
ok(ret, "failed to query status code %u\n", GetLastError());
ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status);
size = 0;
ret = WinHttpReadData(req, buffer, sizeof(buffer), &size);
ok(ret, "failed to read data %u\n", GetLastError());
ok(size == 11, "expected 11, got %u\n", size);
ok(!memcmp(buffer, hello_world, 11), "got %s\n", buffer);
WinHttpCloseHandle(req);
WinHttpCloseHandle(con);
WinHttpCloseHandle(ses);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment