Test: ultimi adattamenti ai campi e agli strumenti rimossi (B)
Tolti i campi api_key dei provider nei letterali dei test, il test del tool function di apply_patch (funzione F non portata) e i test di login --provider; i test di core, tui, cli, exec, mcp e app-server compilano di nuovo (cargo check --tests). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -576,7 +576,6 @@ mod thread_processor_behavior_tests {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
|
|||||||
@@ -164,70 +164,3 @@ fn legacy_chatgpt_auth_is_reported_as_not_logged_in_and_logout_removes_it() -> R
|
|||||||
assert!(!codex_home.path().join("auth.json").exists());
|
assert!(!codex_home.path().join("auth.json").exists());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn provider_api_key_login_uses_private_file_store_and_never_prints_the_key() -> Result<()> {
|
|
||||||
let codex_home = TempDir::new()?;
|
|
||||||
std::fs::write(
|
|
||||||
codex_home.path().join("config.toml"),
|
|
||||||
"provider_api_key_store = \"file\"\n\
|
|
||||||
model_provider = \"imeai\"\n\
|
|
||||||
[model_providers.imeai]\n\
|
|
||||||
name = \"imeAI\"\n\
|
|
||||||
base_url = \"http://127.0.0.1:9/v1\"\n\
|
|
||||||
api_key = \"keyring\"\n",
|
|
||||||
)?;
|
|
||||||
let secret = "sk-provider-secret-0123456789";
|
|
||||||
|
|
||||||
let login = codex_command(codex_home.path())?
|
|
||||||
.args(["login", "--provider", "imeai", "--with-api-key"])
|
|
||||||
.write_stdin(format!("{secret}\n"))
|
|
||||||
.assert()
|
|
||||||
.success();
|
|
||||||
let stderr = String::from_utf8_lossy(&login.get_output().stderr).to_string();
|
|
||||||
assert!(
|
|
||||||
stderr.contains("API key for `imeai` saved in file"),
|
|
||||||
"{stderr}"
|
|
||||||
);
|
|
||||||
assert!(!stderr.contains(secret), "{stderr}");
|
|
||||||
|
|
||||||
let path = codex_home.path().join("provider_api_keys.json");
|
|
||||||
let stored: Value = serde_json::from_str(&std::fs::read_to_string(&path)?)?;
|
|
||||||
assert_eq!(stored, json!({ "imeai": secret }));
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
use std::os::unix::fs::PermissionsExt;
|
|
||||||
assert_eq!(
|
|
||||||
std::fs::metadata(&path)?.permissions().mode() & 0o777,
|
|
||||||
0o600
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// The shared stored key is untouched.
|
|
||||||
assert!(!codex_home.path().join("auth.json").exists());
|
|
||||||
|
|
||||||
let status = codex_command(codex_home.path())?
|
|
||||||
.args(["login", "status"])
|
|
||||||
.assert()
|
|
||||||
.success();
|
|
||||||
let stderr = String::from_utf8_lossy(&status.get_output().stderr).to_string();
|
|
||||||
assert!(
|
|
||||||
stderr.contains("Provider `imeai`: API key stored in file"),
|
|
||||||
"{stderr}"
|
|
||||||
);
|
|
||||||
assert!(!stderr.contains(secret), "{stderr}");
|
|
||||||
|
|
||||||
codex_command(codex_home.path())?
|
|
||||||
.args(["logout", "--provider", "imeai"])
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stderr(contains("Removed the stored API key for `imeai`"));
|
|
||||||
assert!(!path.exists());
|
|
||||||
codex_command(codex_home.path())?
|
|
||||||
.args(["login", "status"])
|
|
||||||
.assert()
|
|
||||||
.failure()
|
|
||||||
.stderr(contains(
|
|
||||||
"Provider `imeai`: no API key stored (akode login --provider imeai --with-api-key)",
|
|
||||||
));
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
use anyhow::Result;
|
|
||||||
use predicates::str::contains;
|
|
||||||
use std::path::Path;
|
|
||||||
use tempfile::TempDir;
|
|
||||||
|
|
||||||
fn codex_command(codex_home: &Path) -> Result<assert_cmd::Command> {
|
|
||||||
let mut cmd = assert_cmd::Command::new(akode_utils_cargo_bin::cargo_bin("akode")?);
|
|
||||||
cmd.env("AKODE_HOME", codex_home);
|
|
||||||
Ok(cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
#[tokio::test]
|
|
||||||
async fn update_does_not_start_interactive_prompt() -> Result<()> {
|
|
||||||
let akode_home = TempDir::new()?;
|
|
||||||
|
|
||||||
codex_command(codex_home.path())?
|
|
||||||
.arg("update")
|
|
||||||
.assert()
|
|
||||||
.failure()
|
|
||||||
.stderr(contains("`akode update` is not available in debug builds"));
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
@@ -35,36 +35,3 @@ fn create_apply_patch_freeform_tool_includes_environment_id_when_requested() {
|
|||||||
.contains("\"*** Environment ID: \" filename LF")
|
.contains("\"*** Environment ID: \" filename LF")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn create_apply_patch_function_tool_takes_a_single_input_string() {
|
|
||||||
let ToolSpec::Function(tool) =
|
|
||||||
create_apply_patch_function_tool(/*include_environment_id*/ false)
|
|
||||||
else {
|
|
||||||
panic!("expected function tool");
|
|
||||||
};
|
|
||||||
assert_eq!(tool.name, "apply_patch");
|
|
||||||
assert!(tool.description.contains("*** Begin Patch"));
|
|
||||||
assert!(tool.description.contains(APPLY_PATCH_LARK_GRAMMAR));
|
|
||||||
assert!(!tool.description.contains("Environment ID"));
|
|
||||||
assert_eq!(
|
|
||||||
serde_json::to_value(&tool.parameters).expect("schema serializes"),
|
|
||||||
serde_json::json!({
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"input": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The entire contents of the apply_patch command",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["input"],
|
|
||||||
"additionalProperties": false,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
let ToolSpec::Function(multi_env) =
|
|
||||||
create_apply_patch_function_tool(/*include_environment_id*/ true)
|
|
||||||
else {
|
|
||||||
panic!("expected function tool");
|
|
||||||
};
|
|
||||||
assert!(multi_env.description.contains("*** Environment ID: <id>"));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ async fn responses_stream_includes_subagent_header_on_review() {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
@@ -223,7 +222,6 @@ async fn responses_stream_includes_subagent_header_on_other() {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
@@ -347,7 +345,6 @@ async fn responses_respects_model_info_overrides_from_config() {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
|
|||||||
@@ -1677,7 +1677,6 @@ async fn send_provider_auth_request(server: &MockServer, auth: ModelProviderAuth
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: Some(auth),
|
auth: Some(auth),
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
@@ -2908,7 +2907,6 @@ async fn azure_responses_request_does_not_store_and_preserves_prefixed_item_ids(
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
@@ -3746,7 +3744,6 @@ async fn azure_overrides_assign_properties_used_for_responses_url() {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
query_params: Some(std::collections::HashMap::from([(
|
query_params: Some(std::collections::HashMap::from([(
|
||||||
"api-version".to_string(),
|
"api-version".to_string(),
|
||||||
"2025-04-01-preview".into(),
|
"2025-04-01-preview".into(),
|
||||||
@@ -3839,7 +3836,6 @@ async fn env_var_overrides_loaded_auth() {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
http_headers: Some(std::collections::HashMap::from([(
|
http_headers: Some(std::collections::HashMap::from([(
|
||||||
"Custom-Header".to_string(),
|
"Custom-Header".to_string(),
|
||||||
|
|||||||
@@ -2787,7 +2787,6 @@ fn websocket_provider_with_connect_timeout(
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ async fn continue_after_stream_error() {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ async fn retries_on_early_close() {
|
|||||||
experimental_bearer_token: None,
|
experimental_bearer_token: None,
|
||||||
auth: None,
|
auth: None,
|
||||||
gateway_oauth: None,
|
gateway_oauth: None,
|
||||||
api_key: None,
|
|
||||||
wire_api: WireApi::Responses,
|
wire_api: WireApi::Responses,
|
||||||
query_params: None,
|
query_params: None,
|
||||||
http_headers: None,
|
http_headers: None,
|
||||||
|
|||||||
Reference in New Issue
Block a user