Skip to content

Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy

Rust

keep tests away from codex credentials

Raine Virtaf3bffb19ae99
diff --git a/src/providers/codex/mod.rs b/src/providers/codex/mod.rs
index 7af605b..f93aa3c 100644
--- a/src/providers/codex/mod.rs
+++ b/src/providers/codex/mod.rs
@@ -929,9 +929,6 @@ fn format_auth_saved_output(auth_path: &str, account_id: Option<&str>) -> String
#[cfg(test)]
mod tests {
use super::*;
- use std::sync::{Mutex, OnceLock};
-
- static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new();
fn request_with_tools(tools: serde_json::Value) -> MessagesRequest {
serde_json::from_value(serde_json::json!({
@@ -977,39 +974,6 @@ mod tests {
}
}
- fn env_lock() -> std::sync::MutexGuard<'static, ()> {
- ENV_LOCK
- .get_or_init(|| Mutex::new(()))
- .lock()
- .unwrap_or_else(|poisoned| poisoned.into_inner())
- }
-
- struct EnvGuard {
- key: &'static str,
- previous: Option<std::ffi::OsString>,
- }
-
- impl EnvGuard {
- fn set(key: &'static str, value: impl AsRef<std::ffi::OsStr>) -> Self {
- let previous = std::env::var_os(key);
- unsafe {
- std::env::set_var(key, value);
- }
- Self { key, previous }
- }
- }
-
- impl Drop for EnvGuard {
- fn drop(&mut self) {
- unsafe {
- match self.previous.take() {
- Some(value) => std::env::set_var(self.key, value),
- None => std::env::remove_var(self.key),
- }
- }
- }
- }
-
#[test]
fn live_stream_progress_records_terminal_usage() {
let monitor = crate::monitor::MonitorHandle::new(10);
@@ -1048,32 +1012,6 @@ mod tests {
assert!(models.contains(&"gpt-5.4-mini".to_string()));
}
- #[test]
- fn codex_cli_status_unauthenticated() {
- let _lock = env_lock();
- let config = tempfile::TempDir::new().unwrap();
- let _config_env = EnvGuard::set("CCP_CONFIG_DIR", config.path());
- // Without stored auth, status should fail
- let result = CODEX_CLI.status();
- assert!(result.is_err());
- assert!(
- result
- .unwrap_err()
- .to_string()
- .contains("Not authenticated")
- );
- }
-
- #[test]
- fn codex_cli_logout_does_not_error() {
- let _lock = env_lock();
- let config = tempfile::TempDir::new().unwrap();
- let _config_env = EnvGuard::set("CCP_CONFIG_DIR", config.path());
- // Logout without auth should succeed
- let result = CODEX_CLI.logout();
- assert!(result.is_ok());
- }
-
#[test]
fn format_auth_saved_output_with_account() {
assert_eq!(
diff --git a/tests/cli.rs b/tests/cli.rs
index ca5e122..5525373 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -42,24 +42,6 @@ fn invalid_command_exits_two() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
-#[test]
-fn provider_auth_status_unauthenticated_and_logout() -> Result<(), Box<dyn std::error::Error>> {
- let temp = TempDir::new()?;
- let mut cmd = Command::cargo_bin("claude-code-proxy")?;
- cmd.args(["codex", "auth", "status"]);
- cmd.env("CCP_CONFIG_DIR", temp.path());
- let output = cmd.output()?;
- assert_eq!(output.status.code(), Some(1));
- assert!(String::from_utf8(output.stdout)?.contains("Not authenticated"));
-
- let mut cmd = Command::cargo_bin("claude-code-proxy")?;
- cmd.args(["codex", "auth", "logout"]);
- cmd.env("CCP_CONFIG_DIR", temp.path());
- let output = cmd.output()?;
- assert!(output.status.success());
- Ok(())
-}
-
#[test]
fn unsupported_provider_auth_command_exits_two() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("claude-code-proxy")?;