mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
## What changed - Accept `windows.sandbox = "mxc"` and preserve the selected backend through environment configuration, command execution, patch writes, and sandbox metadata. - Treat MXC as enabled in the TUI and report Windows sandbox readiness as `ready`, avoiding legacy setup prompts. - Keep `allowed_sandbox_implementations` scoped to the legacy elevated and unelevated backends without restricting MXC. - Default `windows.sandbox_private_desktop` to `false` for MXC while retaining `true` for legacy sandboxes. ## Testing Add coverage for MXC configuration precedence, legacy requirement handling, sandbox selection, and TUI state. Add a Wine integration test that verifies command and patch routing fails when native MXC is unavailable and reports `windows_mxc` in turn metadata. GitOrigin-RevId: e2162447d0750f60753864c92a20e02a7f297bca
93 lines
2.9 KiB
Rust
93 lines
2.9 KiB
Rust
use super::*;
|
|
use codex_app_server_protocol::WindowsSandboxSetupMode::Elevated;
|
|
use codex_app_server_protocol::WindowsSandboxSetupMode::Unelevated;
|
|
use pretty_assertions::assert_eq;
|
|
use serde_json::json;
|
|
|
|
#[test]
|
|
fn windows_sandbox_server_policy_controls_setup_choices() {
|
|
for (configured, allowed, mode, expected) in [
|
|
(
|
|
Some("unelevated"),
|
|
serde_json::Value::Null,
|
|
Some(Unelevated),
|
|
(true, true, false, true),
|
|
),
|
|
(
|
|
Some("unelevated"),
|
|
json!(["elevated"]),
|
|
Some(Elevated),
|
|
(true, false, true, true),
|
|
),
|
|
(
|
|
None,
|
|
json!(["unelevated", "elevated"]),
|
|
Some(Elevated),
|
|
(true, true, true, true),
|
|
),
|
|
(
|
|
None,
|
|
json!(["unelevated"]),
|
|
Some(Unelevated),
|
|
(false, true, false, true),
|
|
),
|
|
(
|
|
Some("unelevated"),
|
|
json!([]),
|
|
None,
|
|
(false, false, false, false),
|
|
),
|
|
(
|
|
Some("mxc"),
|
|
json!(["elevated"]),
|
|
None,
|
|
(true, false, false, true),
|
|
),
|
|
] {
|
|
let config = serde_json::from_value(json!({
|
|
"config": {
|
|
"windows": {"sandbox": configured},
|
|
"features": {"elevated_windows_sandbox": configured == Some("mxc")}
|
|
},
|
|
"origins": {}
|
|
}))
|
|
.unwrap();
|
|
let requirements = serde_json::from_value(json!({
|
|
"requirements": {"allowedWindowsSandboxImplementations": allowed}
|
|
}))
|
|
.unwrap();
|
|
let state = WindowsSandboxConfig::from_responses(&config, requirements);
|
|
assert_eq!(state.mode, mode);
|
|
assert_eq!(
|
|
(
|
|
state.allows(Elevated),
|
|
state.allows(Unelevated),
|
|
state.requires_elevated(),
|
|
state.is_enabled(),
|
|
),
|
|
expected
|
|
);
|
|
}
|
|
for (key, mode) in [
|
|
("elevated_windows_sandbox", Elevated),
|
|
("experimental_windows_sandbox", Unelevated),
|
|
("enable_experimental_windows_sandbox", Unelevated),
|
|
] {
|
|
for (explicit, expected) in [(None, mode), (Some("elevated"), Elevated)] {
|
|
let config = serde_json::from_value(json!({
|
|
"config": {"windows": {"sandbox": explicit}, "features": {key: true}},
|
|
"origins": {}
|
|
}))
|
|
.unwrap();
|
|
let requirements = serde_json::from_value(json!({"requirements": null})).unwrap();
|
|
assert_eq!(
|
|
WindowsSandboxConfig::from_responses(&config, requirements).mode,
|
|
Some(expected)
|
|
);
|
|
}
|
|
}
|
|
let unknown = WindowsSandboxConfig::default();
|
|
assert!(!unknown.allows(Elevated));
|
|
assert!(!unknown.allows(Unelevated));
|
|
}
|