Enable autobahn testing with deflate support

Based on work by Benjamin Swart <Benjaminswart@email.cz>
This commit is contained in:
Alex Bakon 2025-08-25 11:45:55 -04:00
parent 9e8e06816e
commit bb7bfd3287
7 changed files with 383 additions and 368 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
target
Cargo.lock
.vscode
autobahn/client/
autobahn/server/

View File

@ -114,11 +114,11 @@ required-features = ["handshake"]
[[example]]
name = "autobahn-client"
required-features = ["handshake"]
required-features = ["handshake", "deflate"]
[[example]]
name = "autobahn-server"
required-features = ["handshake"]
required-features = ["handshake", "deflate"]
[[example]]
name = "callback-error"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
use log::*;
use tungstenite::{connect, Error, Message, Result};
use tungstenite::{
client::connect_with_config, connect, extensions::compression::deflate::DeflateConfig,
protocol::WebSocketConfig, Error, Message, Result,
};
const AGENT: &str = "Tungstenite";
@ -20,7 +23,11 @@ fn update_reports() -> Result<()> {
fn run_test(case: u32) -> Result<()> {
info!("Running test case {}", case);
let case_url = format!("ws://localhost:9001/runCase?case={case}&agent={AGENT}");
let (mut socket, _) = connect(case_url)?;
let mut config = WebSocketConfig::default();
config.extensions.permessage_deflate = Some(DeflateConfig::default());
let (mut socket, _) = connect_with_config(case_url, Some(config), 3)?;
loop {
match socket.read()? {
msg @ Message::Text(_) | msg @ Message::Binary(_) => {

View File

@ -4,7 +4,10 @@ use std::{
};
use log::*;
use tungstenite::{accept, handshake::HandshakeRole, Error, HandshakeError, Message, Result};
use tungstenite::{
accept_with_config, extensions::compression::deflate::DeflateConfig, handshake::HandshakeRole,
protocol::WebSocketConfig, Error, HandshakeError, Message, Result,
};
fn must_not_block<Role: HandshakeRole>(err: HandshakeError<Role>) -> Error {
match err {
@ -14,7 +17,10 @@ fn must_not_block<Role: HandshakeRole>(err: HandshakeError<Role>) -> Error {
}
fn handle_client(stream: TcpStream) -> Result<()> {
let mut socket = accept(stream).map_err(must_not_block)?;
let mut config = WebSocketConfig::default();
config.extensions.permessage_deflate = Some(DeflateConfig::default());
let mut socket = accept_with_config(stream, Some(config)).map_err(must_not_block)?;
info!("Running test");
loop {
match socket.read()? {

View File

@ -32,5 +32,5 @@ docker run -d --rm \
wstest -m fuzzingserver -s 'autobahn/fuzzingserver.json'
sleep 3
cargo run --release --example autobahn-client
cargo run --release --example autobahn-client --features=deflate
test_diff

View File

@ -22,7 +22,7 @@ function test_diff() {
fi
}
cargo run --release --example autobahn-server & WSSERVER_PID=$!
cargo run --release --example autobahn-server --features=deflate & WSSERVER_PID=$!
sleep 3
docker run --rm \