Files
codex/codex-rs/config/src/test_support.rs
T
joeflorencio-openai d45cd26248 Switch runtime to cloud config bundle (#24622)
## Summary

- Adapts the moved `codex-cloud-config` crate from the legacy cloud
requirements endpoint to the new config bundle endpoint.
- Switches runtime consumers from `CloudRequirementsLoader` to
`CloudConfigBundleLoader` so one shared bundle supplies cloud-delivered
config and requirements.
- Removes the legacy cloud requirements domain loader path.

## Details

This intentionally keeps `codex-cloud-config` monolithic for review
lineage: the previous PR establishes the crate move, and this PR shows
the behavior change against that moved implementation. A follow-up PR
splits the module back into focused files.

The new bundle path preserves the important cloud requirements loader
semantics where intended: account-scoped signed cache, 30 minute TTL, 5
minute refresh cadence, retry/backoff, auth recovery, and fail-closed
startup loading. The cached payload changes from a single requirements
TOML string to the backend-delivered bundle, and validation rejects
malformed config or requirements fragments before cache write/use.
2026-06-02 13:18:59 -07:00

81 lines
2.5 KiB
Rust

//! Test-only helpers exposed for cross-crate integration tests.
//!
//! Production code should not depend on this module.
use crate::CloudConfigBundle;
use crate::CloudConfigBundleLoader;
use crate::CloudConfigFragment;
use crate::CloudRequirementsFragment;
#[derive(Debug, Clone, Default)]
pub struct CloudConfigBundleFixture {
bundle: CloudConfigBundle,
}
impl CloudConfigBundleFixture {
pub fn enterprise_requirement(contents: impl Into<String>) -> Self {
Self::default().add_enterprise_requirement(contents)
}
pub fn enterprise_config(contents: impl Into<String>) -> Self {
Self::default().add_enterprise_config(contents)
}
pub fn loader_with_enterprise_requirement(
contents: impl Into<String>,
) -> CloudConfigBundleLoader {
Self::enterprise_requirement(contents).into_loader()
}
pub fn loader_with_enterprise_config(contents: impl Into<String>) -> CloudConfigBundleLoader {
Self::enterprise_config(contents).into_loader()
}
pub fn add_enterprise_requirement(mut self, contents: impl Into<String>) -> Self {
let index = self.bundle.requirements_toml.enterprise_managed.len() + 1;
self.bundle
.requirements_toml
.enterprise_managed
.push(CloudRequirementsFragment {
id: format!("req_{index}"),
name: if index == 1 {
"Base requirements".to_string()
} else {
format!("Requirements {index}")
},
contents: contents.into(),
});
self
}
pub fn add_enterprise_config(mut self, contents: impl Into<String>) -> Self {
let index = self.bundle.config_toml.enterprise_managed.len() + 1;
self.bundle
.config_toml
.enterprise_managed
.push(CloudConfigFragment {
id: format!("cfg_{index}"),
name: if index == 1 {
"Base config".to_string()
} else {
format!("Config {index}")
},
contents: contents.into(),
});
self
}
pub fn into_bundle(self) -> CloudConfigBundle {
self.bundle
}
pub fn into_loader(self) -> CloudConfigBundleLoader {
let bundle = self.into_bundle();
CloudConfigBundleLoader::new(async move { Ok(Some(bundle)) })
}
}
#[cfg(test)]
#[path = "test_support_tests.rs"]
mod tests;