Files
codex/codex-rs/app-server-daemon/src/update_policy_tests.rs
T
Eric Traut 0f3a4756f9 Let administrators disable Codex daemon updates (#62690)
## Why

The daemon's automatic update preference still permits manual updates.
Administrators need a policy that covers both paths.

## What changed

Set `features.daemon_updates = false` in managed `requirements.toml` or
local MDM policy to block scheduled updates and manual daemon package
replacements. Updates are allowed by default. User configuration cannot
override the policy, and cloud-delivered requirements reject the setting.

When policy blocks updates, the TUI hides update actions in `/daemon`,
suppresses update offers in version notices, and directs users to their
administrator where a newer daemon is required.

## Testing

Add coverage for the default, disabled, and invalid policy cases,
rejection of the setting in cloud requirements, and the TUI with daemon
updates disabled.

GitOrigin-RevId: de9e50c4acc4dc8e83bbd2b9a5e902deb8c6f477
2026-11-20 07:14:27 +00:00

18 lines
744 B
Rust

#![cfg(test)]
use super::*;
#[tokio::test]
async fn managed_policy_controls_daemon_updates_and_rejects_invalid_policy() -> Result<()> {
let home = tempfile::tempdir()?;
let path = home.path().join("requirements.toml");
let mut overrides = LoaderOverrides::without_managed_config_for_tests();
overrides.system_requirements_path = Some(path.clone());
assert!(updates_allowed(home.path(), overrides.clone()).await?);
tokio::fs::write(&path, "[features]\ndaemon_updates = false\n").await?;
assert!(!updates_allowed(home.path(), overrides.clone()).await?);
tokio::fs::write(&path, "[features]\ndaemon_updates = 'invalid'\n").await?;
assert!(updates_allowed(home.path(), overrides).await.is_err());
Ok(())
}