From 76e32b6032c888f2d0f16ff49494f05232eb142a Mon Sep 17 00:00:00 2001 From: Finesssee <90105158+Finesssee@users.noreply.github.com> Date: Mon, 18 May 2026 19:48:31 +0700 Subject: [PATCH] test: harden Codex auth import --- docs/rust-replatform.md | 13 +++++++++++ rust/proxypilot-rs/src/state.rs | 41 ++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/docs/rust-replatform.md b/docs/rust-replatform.md index 2b708415..8bc6f520 100644 --- a/docs/rust-replatform.md +++ b/docs/rust-replatform.md @@ -58,6 +58,19 @@ The smoke check starts a local mock upstream, saves a temporary Codex account, starts the Rust proxy, and verifies `/healthz`, `/v0/runtime/stats`, `/v1/models`, `/v1/chat/completions`, and `/v1/responses`. +## Current Codex Gaps + +The Rust line is not ready to replace the Go Codex surface yet. These Go routes +and behaviors are still unsupported or intentionally deferred: + +- `/backend-api/codex/responses` +- `/backend-api/codex/responses/{response_id}/compact` +- `/v1/responses/compact` +- Codex websocket streaming +- Codex image generation and image edit handling +- Browser dashboard and `/v0/management/**` routes +- Go model registry and model-mapping behavior + Open the TUI with: ```bash diff --git a/rust/proxypilot-rs/src/state.rs b/rust/proxypilot-rs/src/state.rs index f34c4f18..8a6c39d7 100644 --- a/rust/proxypilot-rs/src/state.rs +++ b/rust/proxypilot-rs/src/state.rs @@ -267,6 +267,8 @@ impl AccountState { #[derive(Debug, Clone, Deserialize)] pub struct ImportedCodexAuth { + #[serde(default)] + pub id_token: String, #[serde(default)] pub access_token: String, #[serde(default)] @@ -307,7 +309,7 @@ impl AccountState { }, api_key: imported.access_token.trim().to_string(), refresh_token: optional_trimmed(imported.refresh_token), - id_token: None, + id_token: optional_trimmed(imported.id_token), email: optional_trimmed(imported.email), account_id: optional_trimmed(imported.account_id), plan_type: None, @@ -430,6 +432,7 @@ mod tests { .add_imported_codex_account( "imported".to_string(), ImportedCodexAuth { + id_token: "id".to_string(), access_token: "imported-token".to_string(), refresh_token: "refresh".to_string(), email: "dev@example.com".to_string(), @@ -449,11 +452,47 @@ mod tests { .unwrap(); assert_eq!(account.email.as_deref(), Some("dev@example.com")); assert_eq!(account.account_id.as_deref(), Some("acct_123")); + assert_eq!(account.id_token.as_deref(), Some("id")); assert_eq!(account.plan_type.as_deref(), None); assert_eq!(account.expires_at.as_deref(), Some("2026-04-06T00:00:00Z")); assert_eq!(account.source.as_deref(), Some("file")); } + #[test] + fn imported_codex_auth_accepts_go_token_storage_shape() { + let imported: ImportedCodexAuth = serde_json::from_str( + r#"{ + "id_token": "go-id-token", + "access_token": "go-access-token", + "refresh_token": "go-refresh-token", + "account_id": "acct_go", + "last_refresh": "2026-04-05T00:00:00Z", + "email": "go@example.com", + "type": "codex", + "expired": "2026-04-06T00:00:00Z" + }"#, + ) + .unwrap(); + + let mut state = AccountState::default(); + state + .add_imported_codex_account( + "go-file".to_string(), + imported, + "fixture".to_string(), + true, + ) + .unwrap(); + + let account = state.active_codex_account().unwrap(); + assert_eq!(account.api_key, "go-access-token"); + assert_eq!(account.refresh_token.as_deref(), Some("go-refresh-token")); + assert_eq!(account.id_token.as_deref(), Some("go-id-token")); + assert_eq!(account.email.as_deref(), Some("go@example.com")); + assert_eq!(account.account_id.as_deref(), Some("acct_go")); + assert_eq!(account.expires_at.as_deref(), Some("2026-04-06T00:00:00Z")); + } + #[test] fn removing_active_account_promotes_next_saved_account() { let mut state = AccountState::default();