73 Commits (ea01d687b546108b6baf0bc27d16e085739b3b6d)

Author SHA1 Message Date
Jessie Murray ea01d687b5
Apply ACL rules to WebSocket commands
ACLs were not considered when processing commands coming over WebSocket
connections. WS commands that are disabled with ACLs are now rejected
with a custom message for JSON and raw WS clients, the two supported
formats for this protocol. For JSON an equivalent HTTP status code is
included in the response, although this is only an indication of how
Webdis would have responded if it came from a regular HTTP request.

Tests are added to validate that DEBUG commands are rejected by Webdis
without even making it to Redis, for both JSON and raw WS clients.

Add DEBUG OBJECT demo to websocket.html: DEBUG is disabled with ACLs
by default in webdis.json. A DEBUG button is added to the WebSocket
HTML demo to show what kind of response is produced when WebSocket
clients attempt to send such a command.

The error responses are documented in the README in the ACL section.

Fixes #240.
12 months ago
Nicolas Favre-Felix 6057a162f7
Minor cleanup of bench.sh
* Check for `ab` and `curl` dependencies at the start
* Replace backticks with $() in bench()
* Print number of requests with thousands sep in info()
1 year ago
Nicolas Favre-Felix 032e5152c6
Add test for etag header on GET
Previous tests only used If-None-Match
1 year ago
Jessie Murray 055363df46
Add test with curl for empty header (#217) 3 years ago
Nicolas Favre-Felix 73f29055c1
Improvements to ws_peek_data (by @majklik)
Better handling of WS client frames, contributed in the comments of #212:
* Reject unmasked frames as per RFC 6455
* Avoid unnecessary data copy from/to evbuffer
* Remove conditions on has_mask

2 new tests cover this change:
* minimal ping-pong with masked client frame, unmasked response
* rejected unmasked client frame
3 years ago
Jessie Murray 7d495e30c2
Add test for issue #209, Webdis crashing after receiving FIN frame
Connect, handshake, send FIN frame, disconnect. Webdis shouldn't crash.
3 years ago
Jessie Murray 3be189b527
Use macro for htonll/ntohll for portability
I realized that these functions are not standard, so this is bringing
macros back for the 64-bit transforms.
3 years ago
Jessie Murray e213af3226
Fix for WebSocket payload length using 8 bytes
The 8-byte conversion macros were incorrect, and could be replaced with
standard methods instead. This also adds a test to cover this case.
3 years ago
Jessie Murray 7f09680c86
Fix ResourceWarning in limits.py 3 years ago
Jessie Murray 1cbffb63c9
Re-enable pub/sub test in ws-tests 3 years ago
Jessie Murray bb02c1dd04
Formatting only: make ws-tests.py PEP8 compliant. 3 years ago
Jessie Murray 71223ae005
Address review comments (tests) 3 years ago
Jessie Murray d48353cec3
Rename self_cmd to reused_cmd 3 years ago
Jessie Murray d7703b97b3
Add pub/sub test in HTML demo
1. Add publish button with channel and message
2. Add subscribe button with channel
3. Change "Clear logs" button to appear when logs are visible
3 years ago
Jessie Murray 6b090b4ede
Large refactoring of WS code
1. Introduce ws_client struct
2. Handle all communications from websocket.c for WS clients
3. Always use a dedicated Redis connection for WS clients
4. Add rbuf & wbuf evbuffers for incoming & outgoing WS data
5. Use event_base_once to control R/W events
6. WS test: make sure to read complete HTTP response
3 years ago
Jessie Murray 6383cd48dd
Add pub-sub test using WebSockets (disabled)
Add new pub-sub test using WebSockets, disabled by default due to
message ordering not matching what is expected.
Enable the test with `PUBSUB=1 ./ws-tests.py`
3 years ago
Jessie Murray f86bad3bc8
Add Python-based WebSockets tests
1. Create WS tests with the same structure as basic.py
2. Add JSON tests
3. Add "raw" tests
3 years ago
Jessie Murray 8d1b6c40f8
Fix instant vs overall rate in websocket C test
The overall rate was incorrect when using non-default intervals. Also
simplify the code using plain nanosecond values, and fix the rate for
the last event which was based on the number of sleeps instead of the
actual time elapsed.
3 years ago
Nicolas Favre-Felix 5c223e7869
Merge pull request #198 from jessie-murray/websocket-fixes 3 years ago
Jessie Murray 1204f66ec1
Add progress thread w/ custom interval for WS test
* Start progress thread that reports once a second by default
* Customizable rate with [--interval|-i]
* Portable semaphore tested on Linux & macOS
3 years ago
Jessie Murray 69be409b87
PR review: unused code, comment style 3 years ago
Jessie Murray 4c0d3f4032
Refactor websocket.html to remove duplicate HTML 3 years ago
Jessie Murray 05a90b7b7a
Add "PING" button to HTML demo 3 years ago
Nicolas Favre-Felix 4471b71074
Disable pub/sub tests for now, rename curl-tests function 3 years ago
Jessie Murray 3984fb968f
Validate Sec-WebSocket-Accept in WS test
1. Generate random WS connection key
2. Read headers returned in WS connection (upgrade) response
3. Validate Sec-WebSocket-Accept return value from webdis

Tested by introducing an artificial error in webdis, reported as
expected.
3 years ago
Jessie Murray 657197f737
websocket test: make WS mask configurable 3 years ago
Jessie Murray fd8f0b16e0
websocket test: remove special single-threaded mode 3 years ago
Jessie Murray 9a758c6bcf
websocket test: make client sockets non-blocking 3 years ago
Jessie Murray 8141c00ab7
websocket test: formatting/indentation 3 years ago
Jessie Murray e97056f4cf
Add DEBUG=1 logic in tests/Makefile 3 years ago
Nicolas Favre-Felix cf0f77907e
Clean up curl test 3 years ago
Nicolas Favre-Felix 2b69ead0a3
Add pub-sub test in basic.py 3 years ago
Jessie Murray b5b76c9c8f
Reduce default number of websocket messages to test for
2,500 per client with 4 clients: 10,000 total
3 years ago
Jessie Murray 665fc19126
Add max execution time to tests/websocket.c
* Add --max-time in seconds
* Break client loop when elapsed
3 years ago
Jessie Murray 2576a1606d
Websocket test: clean up usage(), exit code
* Better usage() help page
* Do not submit another frame once we've sent all we needed
3 years ago
Jessie Murray a15fb4e28e
Modernize websocket.html web page
* Use pure.css for a basic grid
* Detect disconnections, update UI accordingly
* Make GET/SET commands configurable and interactive
* Add button to clear logs
* Test with current branch
3 years ago
Jessie Murray b0740d0c87
Major update of websocket test
1. Switch to evbuffer for correct handling of partial writes
2. Implement WS state machine in each worker
3. Clean up debug logging
4. Add detailed network log messages to help find WS issues
5. Switch to getopt_long
3 years ago
Jessie Murray 0a27fc7e10
More progress on evbuffer-based WS client test 3 years ago
Jessie Murray c46b85ab7a
First attempt at fixing the websocket test 3 years ago
Jessie Murray 6556039e05
Only process `Connection: close` header if full request was read (fixes #194) (#195) 3 years ago
Nicolas Favre-Felix 1589b77da9
Clean up empty indented lines 4 years ago
Andrii Senkovych 2496fb2515
Pass tests with python-msgpack >= 0.3
Current test suite pass with python-msgpack v0.2 but fails with python-msgpack
v0.3 and later due to changes in the library. Modern distributions ship
python-msgpack > 0.3 for very long time ago.
4 years ago
Nicolas Favre-Felix f22a2953b9 Convert tests to Python3
Contribution from Sandro Tosi at https://github.com/nicolasff/webdis/issues/173
5 years ago
Andriy Senkovych 3156b530af Allow test programs use custom port using environment variable or command-line argument 11 years ago
Nicolas Favre-Felix 2c634fa071 Remove BSON support 12 years ago
Nicolas Favre-Felix b7fb7324f8 Remove deprecated test for DB number. 12 years ago
Nicolas Favre-Felix b7607a0381 Test separate databases. 12 years ago
Nicolas Favre-Felix 66e4e19f6a Fix tests Makefile 12 years ago
Nicolas Favre-Felix 85d242f63a Add HTTP limits (security feature).
* Limit the total HTTP request size.
* Fail early, as soon as invalid characters are found.
* Fixes issue #33.
13 years ago
Nicolas Favre-Felix a26a8681ac Removed obsolete unit test 13 years ago