From 2ed9701ab95c455efe1d3483b45e23ef03383f44 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 22 Sep 2021 12:44:14 +0200 Subject: [PATCH] winhttp: Use ws.ifelse.io for websocket tests. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51631 Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard (cherry picked from commit 9f6e39e8b945466180080d470e1272ba4f807b3a) Signed-off-by: Michael Stefaniuc --- dlls/winhttp/tests/notification.c | 16 ++++++++++++++-- dlls/winhttp/tests/winhttp.c | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index 98e4024867f..e567ed758ee 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -644,6 +644,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 }, @@ -699,7 +700,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 ); @@ -769,7 +770,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") ); diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 5379640d5fc..6bae45ce6da 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -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);