mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Enable Cyber access programs for API-key sessions by default (#53717)
## What changed - Default `features.api_key_cyber_access_programs` to `true` and allow `codex exec` to select Daybreak with an OpenAI API key. Select the advertised standard program when `daybreak=false`, while respecting explicit feature opt-outs. - Resolve API-key eligibility for TUI background turns from the target thread's feature settings, including project opt-outs. Omit access-program overrides when the server cannot report those settings. - Preserve automatic server treatment for unlisted models and missing or empty Cyber program metadata in exec and TUI. Continue rejecting Daybreak when a nonempty program list does not offer it. ## Testing Update regression coverage for API-key Daybreak selection, the off override, explicit opt-outs, resumed sessions, target-thread settings, and missing model metadata. GitOrigin-RevId: f3cf7bd95a2754d4b4281bc70b18c7da4b177552
This commit is contained in:
@@ -21,34 +21,52 @@ fn started_thread(output: std::process::Output) -> anyhow::Result<String> {
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn exec_rejects_daybreak_for_api_keys_and_allows_an_override() -> anyhow::Result<()> {
|
||||
async fn exec_resolves_daybreak_for_api_keys_and_allows_an_off_override() -> anyhow::Result<()> {
|
||||
let (test, server) = configured_daybreak_exec().await?;
|
||||
std::fs::remove_file(test.home_path().join("auth.json"))?;
|
||||
let response = responses::mount_sse_once(&server, responses::sse_completed("response")).await;
|
||||
|
||||
for (args, expected) in [
|
||||
(vec![], Some("daybreak_blue")),
|
||||
(vec!["-c", "daybreak=false"], Some("standard")),
|
||||
(vec!["-m", "unlisted-model"], None),
|
||||
(
|
||||
vec![
|
||||
"-c",
|
||||
"daybreak=false",
|
||||
"-c",
|
||||
"features.api_key_cyber_access_programs=false",
|
||||
],
|
||||
None,
|
||||
),
|
||||
] {
|
||||
let response =
|
||||
responses::mount_sse_once(&server, responses::sse_completed("response")).await;
|
||||
test.cmd_with_server(&server)
|
||||
.env_remove("CODEX_ACCESS_TOKEN")
|
||||
.arg("--skip-git-repo-check")
|
||||
.args(args)
|
||||
.arg("hello")
|
||||
.assert()
|
||||
.success();
|
||||
assert_eq!(
|
||||
response.single_request().body_json().get("access_programs"),
|
||||
expected.map(|program| json!({"cyber": program})).as_ref()
|
||||
);
|
||||
}
|
||||
let response = responses::mount_sse_once(&server, responses::sse_completed("unexpected")).await;
|
||||
test.cmd_with_server(&server)
|
||||
.env_remove("CODEX_ACCESS_TOKEN")
|
||||
.arg("--skip-git-repo-check")
|
||||
.arg("hello")
|
||||
.args([
|
||||
"--skip-git-repo-check",
|
||||
"-c",
|
||||
"features.api_key_cyber_access_programs=false",
|
||||
"hello",
|
||||
])
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(predicate::str::contains(
|
||||
"Daybreak requires a signed-in ChatGPT account",
|
||||
"Cyber access programs are disabled for this API-key session.",
|
||||
));
|
||||
assert!(response.requests().is_empty());
|
||||
|
||||
test.cmd_with_server(&server)
|
||||
.env_remove("CODEX_ACCESS_TOKEN")
|
||||
.arg("--skip-git-repo-check")
|
||||
.arg("-c")
|
||||
.arg("daybreak=false")
|
||||
.arg("hello")
|
||||
.assert()
|
||||
.success();
|
||||
assert_eq!(
|
||||
response.single_request().body_json().get("access_programs"),
|
||||
None
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user