mirror of
https://github.com/openai/codex.git
synced 2026-12-01 00:20:48 +00:00
Accept wsl2 alias for Windows sandbox config
This commit is contained in:
@@ -111,13 +111,31 @@ pub enum OAuthCredentialsStoreMode {
|
||||
Keyring,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[derive(Serialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema)]
|
||||
pub enum WindowsSandboxModeToml {
|
||||
Elevated,
|
||||
Unelevated,
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for WindowsSandboxModeToml {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let raw = String::deserialize(deserializer)?;
|
||||
match raw.to_ascii_lowercase().as_str() {
|
||||
"elevated" => Ok(Self::Elevated),
|
||||
// Accept the legacy/common WSL2 label as a compatibility alias for the
|
||||
// non-admin Windows sandbox mode instead of hard-failing startup.
|
||||
"unelevated" | "wsl2" => Ok(Self::Unelevated),
|
||||
_ => Err(serde::de::Error::unknown_variant(
|
||||
&raw,
|
||||
&["elevated", "unelevated", "wsl2"],
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct WindowsToml {
|
||||
|
||||
@@ -1,6 +1,30 @@
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn windows_sandbox_mode_accepts_wsl2_alias() {
|
||||
let cfg: WindowsToml = toml::from_str(
|
||||
r#"
|
||||
sandbox = "wsl2"
|
||||
"#,
|
||||
)
|
||||
.expect("should deserialize wsl2 as a windows sandbox alias");
|
||||
|
||||
assert_eq!(cfg.sandbox, Some(WindowsSandboxModeToml::Unelevated));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_sandbox_mode_accepts_mixed_case_wsl2_alias() {
|
||||
let cfg: WindowsToml = toml::from_str(
|
||||
r#"
|
||||
sandbox = "wsL2"
|
||||
"#,
|
||||
)
|
||||
.expect("should deserialize mixed-case wsl2 alias");
|
||||
|
||||
assert_eq!(cfg.sandbox, Some(WindowsSandboxModeToml::Unelevated));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_skill_config_with_name_selector() {
|
||||
let cfg: SkillConfig = toml::from_str(
|
||||
|
||||
Reference in New Issue
Block a user