mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
## What changed - Honor `RuntimeAgentInstances` and the configured runtime auth mode for Analytics plan discovery and report requests to OpenAI endpoints. - Share installation ID resolution and Codex runtime registration setup through `codex-runtime-agent-instance`. - Preserve typed runtime authentication errors so expired credentials retain the “Sign in again to load Analytics” guidance. ## Testing Add coverage for both runtime auth modes across regional and staging endpoints, fresh assertions for each request, sign-in guidance after bootstrap failure, redirect rejection, and invalid organization/project selectors. GitOrigin-RevId: 50e0d959b3abd81ebe7a6a584e272f14cf52e504
58 lines
2.0 KiB
Rust
58 lines
2.0 KiB
Rust
//! Verifies the supported destinations and environment boundaries for Realtime auth.
|
|
|
|
#![cfg(test)]
|
|
|
|
use super::*;
|
|
use codex_model_provider::validate_runtime_environment;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn realtime_auth_accepts_only_secure_first_party_destinations() {
|
|
for url in [
|
|
"https://api.openai.com/v1",
|
|
"https://api.openai.org/v1",
|
|
"wss://api.openai.com/v1",
|
|
"wss://chatgpt.com/backend-api",
|
|
] {
|
|
assert!(is_openai_realtime_url(url).unwrap(), "{url}");
|
|
}
|
|
for url in [
|
|
"ws://api.openai.com/v1",
|
|
"http://api.openai.com/v1",
|
|
"wss://unknown.openai.com/v1",
|
|
"wss://api.openai.com:8443/v1",
|
|
"wss://user:secret@api.openai.com/v1",
|
|
] {
|
|
assert!(is_openai_realtime_url(url).is_err(), "{url}");
|
|
}
|
|
assert!(!is_openai_realtime_url("wss://voice.example.com").unwrap());
|
|
}
|
|
|
|
#[test]
|
|
fn realtime_rejects_a_different_registration_environment() {
|
|
for (chatgpt_base_url, expected_staging) in [
|
|
("https://chatgpt.com/backend-api", false),
|
|
("https://chatgpt-staging.com/backend-api", true),
|
|
] {
|
|
let runtime = RuntimeAuthManager::for_codex(
|
|
AuthManager::from_auth_for_testing(codex_login::CodexAuth::from_api_key("test-key")),
|
|
chatgpt_base_url,
|
|
&uuid::Uuid::nil().to_string(),
|
|
);
|
|
for (destination, staging) in [
|
|
("wss://api.openai.com/v1", false),
|
|
("https://chatgpt.com/backend-api", false),
|
|
("wss://api.openai-staging.com/v1", true),
|
|
("https://api.openai.org/v1", true),
|
|
("https://workspace.chatgpt-staging.com/backend-api", true),
|
|
("https://chatgpt-staging.com/backend-api", true),
|
|
] {
|
|
assert_eq!(
|
|
validate_runtime_environment(&runtime, Some(destination)).is_ok(),
|
|
staging == expected_staging,
|
|
"{chatgpt_base_url} -> {destination}",
|
|
);
|
|
}
|
|
}
|
|
}
|