mirror of
https://github.com/openai/codex.git
synced 2026-09-13 11:47:17 +00:00
codex: fix follow-up PR blockers (#15106)
This commit is contained in:
@@ -335,14 +335,6 @@ impl ChatgptAuthRefreshContext {
|
||||
"local ChatGPT auth must use workspace {expected_workspace}, but found {chatgpt_account_id:?}"
|
||||
));
|
||||
}
|
||||
if let Some(previous_account_id) = params.previous_account_id.as_deref()
|
||||
&& previous_account_id != chatgpt_account_id
|
||||
{
|
||||
return Err(format!(
|
||||
"local ChatGPT auth refresh account mismatch: expected `{previous_account_id}`, got `{chatgpt_account_id}`"
|
||||
));
|
||||
}
|
||||
|
||||
Ok(ChatgptAuthTokensRefreshResponse {
|
||||
access_token,
|
||||
chatgpt_account_id,
|
||||
@@ -1702,6 +1694,28 @@ mod tests {
|
||||
assert!(!response.access_token.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chatgpt_auth_refresh_context_ignores_previous_workspace_mismatch() {
|
||||
let codex_home = TestCodexHome::new();
|
||||
write_local_chatgpt_auth(&codex_home.path);
|
||||
let context = ChatgptAuthRefreshContext {
|
||||
codex_home: codex_home.path.clone(),
|
||||
auth_credentials_store_mode: AuthCredentialsStoreMode::File,
|
||||
forced_chatgpt_workspace_id: Some("workspace-1".to_string()),
|
||||
};
|
||||
|
||||
let response = context
|
||||
.resolve_refresh_response(&ChatgptAuthTokensRefreshParams {
|
||||
reason: ChatgptAuthTokensRefreshReason::Unauthorized,
|
||||
previous_account_id: Some("workspace-2".to_string()),
|
||||
})
|
||||
.expect("stale previous workspace should not fail local auth refresh");
|
||||
|
||||
assert_eq!(response.chatgpt_account_id, "workspace-1");
|
||||
assert_eq!(response.chatgpt_plan_type.as_deref(), Some("business"));
|
||||
assert!(!response.access_token.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chatgpt_auth_refresh_context_rejects_workspace_mismatch() {
|
||||
let codex_home = TestCodexHome::new();
|
||||
|
||||
@@ -1012,7 +1012,6 @@ fn all_thread_source_kinds() -> Vec<ThreadSourceKind> {
|
||||
ThreadSourceKind::VsCode,
|
||||
ThreadSourceKind::Exec,
|
||||
ThreadSourceKind::AppServer,
|
||||
ThreadSourceKind::Custom,
|
||||
ThreadSourceKind::SubAgent,
|
||||
ThreadSourceKind::SubAgentReview,
|
||||
ThreadSourceKind::SubAgentCompact,
|
||||
|
||||
@@ -975,7 +975,6 @@ fn split_command_string(command: &str) -> Vec<String> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn app_server_web_search_action_to_core(
|
||||
action: codex_app_server_protocol::WebSearchAction,
|
||||
) -> Option<codex_protocol::models::WebSearchAction> {
|
||||
@@ -1025,6 +1024,10 @@ mod tests {
|
||||
use codex_app_server_protocol::TurnCompletedNotification;
|
||||
use codex_app_server_protocol::TurnError;
|
||||
use codex_app_server_protocol::TurnStatus;
|
||||
use codex_core::auth::AuthCredentialsStoreMode;
|
||||
use codex_core::auth::AuthDotJson;
|
||||
use codex_core::auth::save_auth;
|
||||
use codex_core::token_data::TokenData;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::items::AgentMessageContent;
|
||||
use codex_protocol::items::AgentMessageItem;
|
||||
|
||||
Reference in New Issue
Block a user