mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
fix: auth.json leak in tests (#18657)
Before this some tests were leaking an auth.json file into `codex-rs/core`. This just fixes it
This commit is contained in:
1 parent
19e2f21827
commit
e53e6bc48f
2 files changed
+35
-1
No files matched your search
@@ -230,6 +230,33 @@ fn chatgpt_auth_persists_agent_identity_for_workspace() {
|
||||
assert_eq!(auth.get_agent_identity("account-123"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dummy_chatgpt_auth_does_not_create_cwd_auth_json_when_identity_is_set() {
|
||||
let cwd_auth = std::env::current_dir()
|
||||
.expect("current dir")
|
||||
.join("auth.json");
|
||||
let had_auth_json_before_test = cwd_auth.exists();
|
||||
let auth = CodexAuth::create_dummy_chatgpt_auth_for_testing();
|
||||
let record = AgentIdentityAuthRecord {
|
||||
workspace_id: "account_id".to_string(),
|
||||
chatgpt_user_id: None,
|
||||
agent_runtime_id: "agent_123".to_string(),
|
||||
agent_private_key: "pkcs8-base64".to_string(),
|
||||
registered_at: "2026-04-13T12:00:00Z".to_string(),
|
||||
};
|
||||
|
||||
auth.set_agent_identity(record.clone())
|
||||
.expect("set agent identity");
|
||||
|
||||
assert_eq!(auth.get_agent_identity("account_id"), Some(record));
|
||||
if !had_auth_json_before_test {
|
||||
assert!(
|
||||
!cwd_auth.exists(),
|
||||
"dummy ChatGPT auth must not write auth.json in the test process cwd"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unauthorized_recovery_reports_mode_and_step_names() {
|
||||
let dir = tempdir().unwrap();
|
||||
|
||||
Reference in new issue
Block a user