winhttp: Use ws.ifelse.io for websocket tests.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51631
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2021-09-22 12:44:14 +02:00 committed by Alexandre Julliard
parent f738af16fb
commit 9f6e39e8b9
2 changed files with 28 additions and 7 deletions

View File

@ -660,6 +660,7 @@ static const struct notification websocket_test[] =
{ winhttp_websocket_complete_upgrade, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, NF_SIGNAL },
{ winhttp_websocket_send, WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_receive, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_receive, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_shutdown, WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE, NF_SIGNAL },
{ winhttp_websocket_close, WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE, NF_SIGNAL },
{ winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING },
@ -715,7 +716,7 @@ static void test_websocket(void)
setup_test( &info, winhttp_connect, __LINE__ );
SetLastError( 0xdeadbeef );
connection = WinHttpConnect( session, L"echo.websocket.org", 0, 0 );
connection = WinHttpConnect( session, L"ws.ifelse.io", 0, 0 );
err = GetLastError();
ok( connection != NULL, "got %u\n", err);
ok( err == ERROR_SUCCESS || broken(err == WSAEINVAL) /* < win7 */, "got %u\n", err );
@ -785,7 +786,18 @@ static void test_websocket(void)
WaitForSingleObject( info.wait, INFINITE );
ok( size == 0xdeadbeef, "got %u\n", size );
ok( type == 0xdeadbeef, "got %u\n", type );
ok( buffer[0], "unexpected data\n" );
ok( buffer[0] == 'R', "unexpected data\n" );
setup_test( &info, winhttp_websocket_receive, __LINE__ );
buffer[0] = 0;
size = 0xdeadbeef;
type = 0xdeadbeef;
err = pWinHttpWebSocketReceive( socket, buffer, sizeof(buffer), &size, &type );
ok( err == ERROR_SUCCESS, "got %u\n", err );
WaitForSingleObject( info.wait, INFINITE );
ok( size == 0xdeadbeef, "got %u\n", size );
ok( type == 0xdeadbeef, "got %u\n", type );
ok( buffer[0] == 'h', "unexpected data\n" );
setup_test( &info, winhttp_websocket_shutdown, __LINE__ );
err = pWinHttpWebSocketShutdown( socket, 1000, (void *)"success", sizeof("success") );

View File

@ -3291,7 +3291,7 @@ static void test_websocket(int port)
session = WinHttpOpen(L"winetest", 0, NULL, NULL, 0);
ok(session != NULL, "got %u\n", GetLastError());
connection = WinHttpConnect(session, L"echo.websocket.org", 0, 0);
connection = WinHttpConnect(session, L"ws.ifelse.io", 0, 0);
ok(connection != NULL, "got %u\n", GetLastError());
request = WinHttpOpenRequest(connection, L"GET", L"/", NULL, NULL, NULL, 0);
@ -3316,6 +3316,15 @@ static void test_websocket(int port)
socket = pWinHttpWebSocketCompleteUpgrade(request, 0);
ok(socket != NULL, "got %u\n", GetLastError());
buf[0] = 0;
count = 0;
type = 0xdeadbeef;
error = pWinHttpWebSocketReceive(socket, buf, sizeof(buf), &count, &type);
ok(!error, "got %u\n", error);
ok(buf[0] == 'R', "got %c\n", buf[0]);
ok(count == 26, "got %u\n", count);
ok(type == WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE, "got %u\n", type);
error = pWinHttpWebSocketSend(socket, WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE, NULL, 1);
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
@ -3388,10 +3397,10 @@ static void test_websocket(int port)
error = pWinHttpWebSocketQueryCloseStatus(socket, NULL, NULL, 0, &len);
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
len = 0;
len = 0xdeadbeef;
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 0, &len);
ok(error == ERROR_INSUFFICIENT_BUFFER, "got %u\n", error);
ok(len, "len not set\n");
ok(!error, "got %u\n", error);
ok(!len, "got %u\n", len);
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, NULL, 1, &len);
ok(error == ERROR_INVALID_PARAMETER, "got %u\n", error);
@ -3402,7 +3411,7 @@ static void test_websocket(int port)
error = pWinHttpWebSocketQueryCloseStatus(socket, &close_status, buf, sizeof(buf), &len);
ok(!error, "got %u\n", error);
ok(close_status == 1000, "got %08x\n", close_status);
ok(len == sizeof("success"), "got %u\n", len);
ok(!len, "got %u\n", len);
WinHttpCloseHandle(socket);
WinHttpCloseHandle(request);