From 801022672e63a70788b60e271f8835bc920b0cc5 Mon Sep 17 00:00:00 2001 From: viyatb-oai Date: Tue, 7 Apr 2026 10:59:27 -0700 Subject: [PATCH] test: normalize project trust fixtures Use the production project trust key helper in hook trust tests and normalize the migrated project expectation so Windows canonical path handling matches runtime behavior. Co-authored-by: Codex --- codex-rs/core/src/codex_tests.rs | 3 ++- codex-rs/core/src/config/config_tests.rs | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/src/codex_tests.rs b/codex-rs/core/src/codex_tests.rs index 6fe3055140..11864628de 100644 --- a/codex-rs/core/src/codex_tests.rs +++ b/codex-rs/core/src/codex_tests.rs @@ -8,6 +8,7 @@ use crate::config_loader::NetworkDomainPermissionToml; use crate::config_loader::NetworkDomainPermissionsToml; use crate::config_loader::RequirementSource; use crate::config_loader::Sourced; +use crate::config_loader::project_trust_key; use crate::exec::ExecCapturePolicy; use crate::function_tool::FunctionCallError; use crate::shell::default_user_shell; @@ -335,7 +336,7 @@ async fn write_project_trust_config( .iter() .map(|(project, trust_level)| { ( - project.to_string_lossy().to_string(), + project_trust_key(project), ProjectConfig { trust_level: Some(*trust_level), }, diff --git a/codex-rs/core/src/config/config_tests.rs b/codex-rs/core/src/config/config_tests.rs index deba8a47b3..29dfdc9a34 100644 --- a/codex-rs/core/src/config/config_tests.rs +++ b/codex-rs/core/src/config/config_tests.rs @@ -2,6 +2,7 @@ use crate::config::edit::ConfigEdit; use crate::config::edit::ConfigEditsBuilder; use crate::config::edit::apply_blocking; use crate::config_loader::RequirementSource; +use crate::config_loader::project_trust_key; use crate::plugins::PluginsManager; use assert_matches::assert_matches; use codex_config::CONFIG_TOML_FILE; @@ -5110,7 +5111,9 @@ model = "foo""#; // Since we created the [projects] table as part of migration, it is kept implicit. // Expect explicit per-project tables, preserving prior entries and appending the new one. - let expected = r#"toplevel = "baz" + let new_project_key = project_trust_key(new_project); + let expected = format!( + r#"toplevel = "baz" model = "foo" [projects."/Users/mbolin/code/codex4"] @@ -5120,9 +5123,10 @@ foo = "bar" [projects."/Users/mbolin/code/codex3"] trust_level = "trusted" -[projects."/Users/mbolin/code/codex2"] +[projects."{new_project_key}"] trust_level = "trusted" -"#; +"# + ); assert_eq!(contents, expected); Ok(())