mirror of
https://github.com/openai/codex.git
synced 2026-09-08 15:50:34 +00:00
## What changed - Accept only `http://` and `https://` gRPC endpoints for app server `--code-mode-host` connections. - Limit the standalone code-mode host to stdio and gRPC listeners. - Remove the WebSocket session provider, dual-WebSocket negotiation, transport lanes, and related dependencies and tests. - Keep coverage for shared and prewarmed gRPC hosts and reject WebSocket host URLs in CLI parsing tests. GitOrigin-RevId: 8792604e79ffd54ce776074a4dc3f7d55e63752a
75 lines
2.1 KiB
Rust
75 lines
2.1 KiB
Rust
use super::AppServerCodeModeHostArgs;
|
|
use super::CodeModeHostTransport;
|
|
use super::parse_host_url;
|
|
use pretty_assertions::assert_eq;
|
|
use url::Url;
|
|
|
|
#[test]
|
|
fn grpc_host_accepts_local_and_secure_endpoints() {
|
|
for endpoint in ["http://127.0.0.1:8765", "https://example.test"] {
|
|
assert_eq!(
|
|
parse_host_url(endpoint),
|
|
Ok(Url::parse(endpoint).expect("test endpoint should parse"))
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn grpc_host_rejects_credentials_without_disclosing_them() {
|
|
for endpoint in [
|
|
"http://alice:secret@example.test",
|
|
"https://alice:secret@example.test",
|
|
"https://alice@example.test",
|
|
"https://:secret@example.test",
|
|
] {
|
|
let error = parse_host_url(endpoint).expect_err("gRPC credentials should be rejected");
|
|
|
|
assert!(error.contains("must not contain credentials"));
|
|
assert!(!error.contains("alice"));
|
|
assert!(!error.contains("secret"));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn code_mode_host_rejects_invalid_endpoints() {
|
|
for endpoint in [
|
|
"ftp://127.0.0.1:8765",
|
|
"ws://",
|
|
"ws://127.0.0.1:8765",
|
|
"wss://example.test/code-mode",
|
|
"ws://alice:secret@example.test/code-mode",
|
|
"wss://alice:secret@example.test/code-mode",
|
|
"wss://example.test/code-mode#fragment",
|
|
"http://",
|
|
"not a host endpoint",
|
|
"https://example.test/code-mode#fragment",
|
|
"https://example.test/code-mode",
|
|
"http://example.test/?token=secret",
|
|
] {
|
|
assert!(
|
|
parse_host_url(endpoint).is_err(),
|
|
"invalid code-mode host endpoint should be rejected: {endpoint}"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn omitted_host_selects_local_transport() {
|
|
assert_eq!(
|
|
CodeModeHostTransport::from(AppServerCodeModeHostArgs::default()),
|
|
CodeModeHostTransport::Local
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn explicit_grpc_host_selects_remote_transport() {
|
|
let url = Url::parse("https://example.test").expect("test endpoint should parse");
|
|
|
|
assert_eq!(
|
|
CodeModeHostTransport::from(AppServerCodeModeHostArgs {
|
|
code_mode_host: Some(url.clone()),
|
|
}),
|
|
CodeModeHostTransport::Grpc(url)
|
|
);
|
|
}
|