Files
codex/codex-rs/websocket-client/src/lib_tests.rs
T
Dmitriy Kovalenko c227654800 Consolidate Rust unit tests under dedicated test modules (#56247)
## What changed

Move inline crate tests into `lib_tests.rs` and nest related test suites under each crate's `tests` module. Update imports, subprocess test filters, logging targets, and snapshot names to match the new module paths.

Keep test helpers accessible where needed and preserve the schema writer's exact test name used by release tooling.

GitOrigin-RevId: de55eaae66dce4941abb33dd0b2f170093daa8f9
2026-10-22 19:36:47 +00:00

40 lines
971 B
Rust

use tokio_tungstenite::tungstenite::http::Uri;
use super::is_loopback_destination;
#[test]
fn recognizes_loopback_websocket_destinations() {
for destination in [
"ws://localhost:8080",
"ws://LOCALHOST:8080",
"ws://127.0.0.1:8080",
"ws://[::1]:8080",
] {
let uri = destination.parse::<Uri>().unwrap();
assert!(
is_loopback_destination(&uri),
"expected loopback destination: {destination}; parsed host: {:?}",
uri.host()
);
}
}
#[test]
fn rejects_non_loopback_websocket_destinations() {
for destination in [
"ws://relay.example:8080",
"ws://192.0.2.1:8080",
"ws://[2001:db8::1]:8080",
"/missing-host",
] {
assert!(!is_loopback_destination(
&destination.parse::<Uri>().unwrap()
));
}
}
#[path = "cookie_tests.rs"]
mod cookie_tests;
#[path = "network_policy_tests.rs"]
mod network_policy_tests;