On Tue, 2017-04-11 at 02:08 +0000, Alistair Leslie-Hughes wrote:
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index a5eff11..0761c2e 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -2059,6 +2059,16 @@ static const char multiauth[] = "Content-Type: text/plain\r\n" "\r\n";
+static const char largeauth[] = +"HTTP/1.1 401 Unauthorized\r\n" +"Server: winetest\r\n" +"WWW-Authenticate: Bearer\r\n" +"WWW-Authenticate: Basic realm="placebo"\r\n" +"WWW-Authenticate: NTLM\r\n" +"Content-Length: 10240\r\n" +"Content-Type: text/plain\r\n" +"\r\n";
Please try to be minimal. You're only using NTLM so the other two authenticate headers are not needed.
@@ -2172,6 +2182,20 @@ static DWORD CALLBACK server_thread(LPVOID param) { send(c, multiauth, sizeof multiauth - 1, 0); }
if(strstr(buffer, "GET /largeauth"))
{
if (strstr(buffer, "Authorization: NTLM"))
send(c, okmsg, sizeof(okmsg) - 1, 0);
else
{
void *data = malloc(10240);
send(c, largeauth, sizeof largeauth - 1, 0);
memset(data, 'A', 10240);
send(c, data, 10240, 0);
free(data);
continue;
You can avoid the allocation e.g. by sending 1 byte in a loop.
+static void test_large_data_authentication(int port) +{
- static const WCHAR largeauthW[] = {'/','l','a','r','g','e','a','u','t','h',0};
- static const WCHAR getW[] = {'G','E','T',0};
- static WCHAR userW[] = {'u','s','e','r',0};
- static WCHAR passW[] = {'p','w','d',0};
- HINTERNET ses, con, req;
- DWORD supported, first, target, status, size;
- BOOL ret;
- ses = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
- ok(ses != NULL, "failed to open session %u\n", GetLastError());
- con = WinHttpConnect(ses, localhostW, port, 0);
- ok(con != NULL, "failed to open a connection %u\n", GetLastError());
- req = WinHttpOpenRequest(con, getW, largeauthW, NULL, NULL, NULL, 0);
- ok(req != NULL, "failed to open a request %u\n", GetLastError());
- ret = WinHttpSendRequest(req, WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA,0, 0, 0 );
- ok(ret, "expected success\n");
- ret = WinHttpReceiveResponse(req, NULL);
- ok(ret, "expected success\n");
- size = sizeof(status);
- ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL,
&status, &size, NULL );
- ok(ret, "expected success\n");
- ok(status == HTTP_STATUS_DENIED, "got %d\n", status);
- supported = first = target = 0xdeadbeef;
- ret = WinHttpQueryAuthSchemes(req, &supported, &first, &target);
- ok(ret, "expected success\n");
- ok(supported == (WINHTTP_AUTH_SCHEME_BASIC | WINHTTP_AUTH_SCHEME_NTLM), "got %x\n", supported);
- ok(target == WINHTTP_AUTH_TARGET_SERVER, "got %x\n", target);
- ok(first == WINHTTP_AUTH_SCHEME_BASIC, "got %x\n", first);
This is also copied from another test and not strictly needed. You can hardcode scheme and target. WinHttpQueryAuthSchemes is already tested elsewhere.