Avoid warning for unset Windows sandbox mode

This commit is contained in:
Abhinav Vedmala
2026-07-06 16:43:18 +00:00
parent bce481fdcb
commit 21c25ab959
2 changed files with 39 additions and 6 deletions
+31
View File
@@ -9540,6 +9540,37 @@ async fn explicit_sandbox_mode_falls_back_when_disallowed_by_requirements() -> s
Ok(())
}
#[tokio::test]
async fn unset_windows_sandbox_mode_uses_requirements_default_without_warning()
-> std::io::Result<()> {
let codex_home = TempDir::new()?;
let config = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"[windows]
allowed_sandbox_implementations = ["elevated"]
"#,
),
)
.build()
.await?;
assert_eq!(
config.permissions.windows_sandbox_mode,
Some(codex_config::types::WindowsSandboxModeToml::Elevated)
);
assert!(
config.startup_warnings.iter().all(|warning| !warning
.contains("Configured value for `windows.sandbox` is disallowed by requirements")),
"{:?}",
config.startup_warnings
);
Ok(())
}
#[tokio::test]
async fn windows_sandbox_mode_falls_back_when_disallowed_by_requirements() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
+8 -6
View File
@@ -3070,12 +3070,14 @@ impl Config {
WindowsSandboxLevel::Disabled => None,
}
});
apply_requirement_constrained_value(
"windows.sandbox",
selected_windows_sandbox_mode,
&mut constrained_windows_sandbox_mode,
&mut startup_warnings,
)?;
if let Some(selected_windows_sandbox_mode) = selected_windows_sandbox_mode {
apply_requirement_constrained_value(
"windows.sandbox",
Some(selected_windows_sandbox_mode),
&mut constrained_windows_sandbox_mode,
&mut startup_warnings,
)?;
}
let effective_windows_sandbox_mode = *constrained_windows_sandbox_mode.get();
let windows_sandbox_mode = if constrained_windows_sandbox_mode.source.is_some() {
effective_windows_sandbox_mode