core: expose permission profile to shell tools

This commit is contained in:
Michael Bolin
2026-06-25 09:35:10 -07:00
parent f15df624a6
commit 5d562c1034
9 changed files with 360 additions and 15 deletions
+53
View File
@@ -10,6 +10,59 @@ fn make_vars(pairs: &[(&str, &str)]) -> Vec<(String, String)> {
.collect()
}
#[test]
fn inject_permission_profile_env_overrides_policy_value() {
let mut env = HashMap::from([(
CODEX_PERMISSION_PROFILE_ENV_VAR.to_string(),
"stale-profile".to_string(),
)]);
inject_permission_profile_env(
&mut env,
Some(&ActivePermissionProfile::new("current-profile")),
);
assert_eq!(
env.get(CODEX_PERMISSION_PROFILE_ENV_VAR)
.map(String::as_str),
Some("current-profile")
);
}
#[test]
fn inject_permission_profile_env_removes_stale_value_without_active_profile() {
let mut env = HashMap::from([(
CODEX_PERMISSION_PROFILE_ENV_VAR.to_string(),
"stale-profile".to_string(),
)]);
inject_permission_profile_env(&mut env, /*active_permission_profile*/ None);
assert_eq!(env.get(CODEX_PERMISSION_PROFILE_ENV_VAR), None);
}
#[cfg(target_os = "windows")]
#[test]
fn inject_permission_profile_env_replaces_differently_cased_windows_key() {
let mut env = HashMap::from([(
"codex_permission_profile".to_string(),
"stale-profile".to_string(),
)]);
inject_permission_profile_env(
&mut env,
Some(&ActivePermissionProfile::new("current-profile")),
);
assert_eq!(
env,
HashMap::from([(
CODEX_PERMISSION_PROFILE_ENV_VAR.to_string(),
"current-profile".to_string(),
)])
);
}
#[test]
fn test_core_inherit_defaults_keep_sensitive_vars() {
let vars = make_vars(&[