curl/tests
Ruocco, Calvin d3594be653
ws: tests and fixes
This started out as regression tests for the `curl_ws_recv()` and
`curl_ws_send()` implementation and ended up with a bugfix, additional
protocol validation and minor logging improvements.

- Fix reset of fragmented message decoder state when a PING/PONG is
  received in between message fragments.

- Fix undefined behavior (applying zero offset to null pointer) in
  curl_ws_send() when the given buffer is NULL.

- Detect invalid overlong PING/PONG/CLOSE frames.
- Detect invalid fragmented PING/PONG/CLOSE frames.
- Detect invalid sequences of fragmented frames.

  - a) A continuation frame (0x80...) is received without any ongoing
    fragmented message.
  - b) A new fragmented message is started (0x81/0x01/0x82/0x02...)
    before the ongoing fragmented message has terminated.

- Made logs for invalid opcodes easier to understand.
- Moved noisy logs to the `CURL_TRC_WS` log level.
- Unified the prefixes for WebSocket log messages: `[WS] ...`

- Add env var `CURL_WS_FORCE_ZERO_MASK` in debug builds.

  - If set, it forces the bit mask applied to outgoing payloads to
    0x00000000, which effectively means the payload is not masked at
    all. This drastically simplifies defining the expected `<protocol>`
    data in test cases.

- 2700: Frame types
- 2701: Invalid opcode 0x3
- 2702: Invalid opcode 0xB
- 2703: Invalid reserved bit RSV1 _(replaces 2310)_
- 2704: Invalid reserved bit RSV2
- 2705: Invalid reserved bit RSV3
- 2706: Invalid masked server message
- 2707: Peculiar frame sizes _(part. replaces 2311)_
- 2708: Automatic PONG
- 2709: No automatic PONG _(replaces 2312)_
- 2710: Unsolicited PONG
- 2711: Empty PING/PONG/CLOSE
- 2712: Max sized PING/PONG/CLOSE
- 2713: Invalid oversized PING _(replaces 2307)_
- 2714: Invalid oversized PONG
- 2715: Invalid oversized CLOSE
- 2716: Invalid fragmented PING
- 2717: Invalid fragmented PONG
- 2718: Invalid fragmented CLOSE
- 2719: Fragmented messages _(part. replaces 2311)_
- 2720: Fragmented messages with empty fragments
- 2721: Fragmented messages with interleaved pong
- 2722: Invalid fragmented message without initial frame
- 2723: Invalid fragmented message without final frame

- 2305: curl_ws_recv() loop reading three larger frames
  - This test involuntarily sent an invalid sequence of opcodes (0x01...,0x01...,0x81...) , but neither libcurl nor the test caught this! The correct sequence was tested in 2311 (0x01...,0x00...,0x80...). See below for 2311.
  - Validation of the opcode sequence was added to libcurl and is now tested in 2723.
  - Superseded by 2719 (fragmented message) and 2707 (large frames).
- 2307: overlong PING payload
  - The tested PING payload length check was actually missing, but the test didn't catch this since it involuntarily sent an invalid opcode (0x19... instead of 0x89...) so that the expected error occurred, but for the wrong reason.
  - Superseded by 2713.
- 2310: unknown reserved bit set in frame header
  - Superseded by 2703 and extended by 2704 and 2705.
- 2311: curl_ws_recv() read fragmented message
  - Superseded by 2719 (fragmented message) and 2707 (large frames).
- 2312: WebSockets no auto ping
  - Superseded by 2709.

- No tests for `CURLOPT_WRITEFUNCTION`.
- No tests for sending of invalid frames/fragments.

Closes #17136
2025-06-02 11:15:38 +02:00
..
certs tests: test mtls also w/ clientAuth EKU only 2025-05-31 15:20:25 +02:00
cmake cmake: test integration with old cmake (v3.11.4 2018-03-28) 2025-05-08 15:11:24 +02:00
data ws: tests and fixes 2025-06-02 11:15:38 +02:00
http ws: tests and fixes 2025-06-02 11:15:38 +02:00
libtest ws: tests and fixes 2025-06-02 11:15:38 +02:00
server spelling: call it null-terminate consistently 2025-05-30 17:29:45 +02:00
tunit checksrc: avoid extra runs in CI, enable more check locally, fix fallouts 2025-05-19 18:59:50 +02:00
unit spelling: 'a' vs 'an' 2025-05-30 11:38:35 +02:00
.gitignore tidy-up: .gitignore lines mostly 2025-01-27 20:59:46 +01:00
allversions.pm VERSIONS: list all past releases 2025-04-03 08:26:33 +02:00
appveyor.pm runtests: fix quoting in Appveyor and Azure test integration 2023-04-22 11:50:03 -07:00
azure.pm runtests: fix quoting in Appveyor and Azure test integration 2023-04-22 11:50:03 -07:00
CMakeLists.txt pytest: enable in 5 GHA jobs, fix fallouts 2025-05-19 15:38:05 +02:00
config.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
configurehelp.pm.in build: use configurehelp.pm.in with autotools and cmake 2024-09-21 12:21:14 +02:00
devtest.pl tests: replace hard-coded /dev/null with variable 2024-10-01 12:07:19 +02:00
dictserver.py tidy-up: align MSYS2/Cygwin codepaths, follow Cygwin MAX_PID bump 2025-02-21 11:58:05 +01:00
directories.pm scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
ech_combos.py tidy-up: whitespace [ci skip] 2024-04-16 09:53:39 +02:00
ech_tests.sh doh: httpsrr fix 2025-04-18 23:03:31 +02:00
ftpserver.pl scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
getpart.pm scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
globalconfig.pm buildinfo: move from tests/server/ to src/, rename to curlinfo 2025-04-28 22:40:10 +02:00
http-server.pl runtests: support multi-target cmake, drop workarounds from CI 2025-02-24 21:00:30 +01:00
http2-server.pl tests: use a more portable null device path 2025-04-04 03:40:47 -04:00
http3-server.pl tests: use a more portable null device path 2025-04-04 03:40:47 -04:00
Makefile.am tests: move test docs into /docs 2025-05-28 15:00:03 +02:00
memanalyze.pl memanalyze.pl: fix getaddrinfo/freeaddrinfo checks 2025-06-01 10:24:31 +02:00
mk-bundle-hints.sh tests: speed up builds with single-binary test bundles 2024-09-22 09:51:15 +02:00
mk-bundle.pl checksrc: avoid extra runs in CI, enable more check locally, fix fallouts 2025-05-19 18:59:50 +02:00
negtelnetserver.py tidy-up: align MSYS2/Cygwin codepaths, follow Cygwin MAX_PID bump 2025-02-21 11:58:05 +01:00
nghttpx.conf copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
pathhelp.pm runtests: fix SSH server not starting in cases, re-ignore failing vcpkg CI jobs 2025-03-09 23:28:07 +01:00
processhelp.pm tests: improve server start reliability 2025-06-02 11:03:10 +02:00
requirements.txt tests/http: more tests with specific clients 2023-04-26 23:24:46 +02:00
rtspserver.pl runtests: support multi-target cmake, drop workarounds from CI 2025-02-24 21:00:30 +01:00
runner.pm runtests: fix indentation [ci skip] 2025-04-22 21:11:37 +02:00
runtests.pl buildinfo: move from tests/server/ to src/, rename to curlinfo 2025-04-28 22:40:10 +02:00
secureserver.pl tests: Add https-mtls server to force client auth 2025-04-07 08:46:56 +02:00
serverhelp.pm tests/server/dnsd: basic DNS server for test suite 2025-04-17 09:13:24 +02:00
servers.pm tests: improve server start reliability 2025-06-02 11:03:10 +02:00
smbserver.py tidy-up: align MSYS2/Cygwin codepaths, follow Cygwin MAX_PID bump 2025-02-21 11:58:05 +01:00
sshhelp.pm runtests: fix test key format for libssh2 WinCNG (and others) 2025-03-23 20:26:26 +01:00
sshserver.pl sshserver.pl: use Perl chmod 2025-03-29 12:35:34 +01:00
test745.pl typecheck-gcc.h: fix the typechecks 2025-04-24 13:23:49 +02:00
test971.pl VERSIONS: list all past releases 2025-04-03 08:26:33 +02:00
test1119.pl cmake: fix clang-tidy builds to verify tests, fix fallouts 2025-03-24 10:14:58 +01:00
test1132.pl tests: rename tests scripts to the test number 2023-12-08 12:53:17 +01:00
test1135.pl tests: Remove unused variables 2025-03-22 11:12:29 -07:00
test1139.pl tool_getparam: add "TLS required" flag for each such option 2025-02-06 11:39:35 +01:00
test1140.pl tests/scripts: call it 'manpage' (single word) 2024-07-18 15:12:09 +02:00
test1165.pl buildinfo: move from tests/server/ to src/, rename to curlinfo 2025-04-28 22:40:10 +02:00
test1167.pl tests: Remove unused variables 2025-03-22 11:12:29 -07:00
test1173.pl test1173.pl: whitelist some option-looking names that aren't options 2025-05-15 22:43:54 +02:00
test1175.pl test1175: scan libcurl-errors.md, not the generated .3 version 2024-07-09 23:13:40 +02:00
test1177.pl NTLM_WB: drop support 2024-04-08 13:58:58 +02:00
test1222.pl scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
test1275.pl docs: improve cipher options documentation 2024-08-17 11:14:21 +02:00
test1276.pl tests: rename tests scripts to the test number 2023-12-08 12:53:17 +01:00
test1477.pl cmake: fix clang-tidy builds to verify tests, fix fallouts 2025-03-24 10:14:58 +01:00
test1486.pl write-out.md: add 'header' and 'output' to the variable list 2025-02-12 17:49:37 -05:00
test1488.pl VERSIONS: list all past releases 2025-04-03 08:26:33 +02:00
test1544.pl scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
test1707.pl test1707: output diff more for debugging differences in CI outputs 2024-08-16 08:57:19 +02:00
testcurl.pl scripts: fix perl indentation, whitespace, semicolons 2025-04-29 19:35:55 +02:00
testutil.pm runtests: support running tests under wine or qemu 2025-03-23 20:26:38 +01:00
tftpserver.pl tests: Remove unused variables 2025-03-22 11:12:29 -07:00
util.py tests: enable additional ruff Python lint options 2024-10-04 14:03:17 -07:00
valgrind.pm tests/valgrind.pm: fix warnings with no valgrind report to show 2024-09-20 15:40:07 +02:00
valgrind.supp hyper: drop support 2024-12-21 11:33:05 +01:00