- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser, device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity, runtime agent instance, backend-client e openapi-models, workspace routing. - Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin remoti (catalogo, sync, share), cyber access program, daybreak, cloud config e requirements (config_server ora fail-closed), attestation, frozen cloud skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/ routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime. - Messaggi d'errore senza link a chatgpt.com. - Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed. - Test: cancellati solo quelli del codice rimosso; test di sicurezza (sandbox estensioni, permessi, redazione, auth storage, requirements) adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents). - Istruzioni di sistema invariate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
194 lines
6.2 KiB
Rust
194 lines
6.2 KiB
Rust
use std::time::Duration;
|
|
|
|
use anyhow::Result;
|
|
use app_test_support::TestAppServer;
|
|
use codex_app_server_protocol::PluginSearchParams;
|
|
use codex_app_server_protocol::PluginSearchResponse;
|
|
use codex_app_server_protocol::PluginSearchScope;
|
|
use codex_config::types::AuthCredentialsStoreMode;
|
|
use codex_login::AuthKeyringBackendKind;
|
|
use codex_login::login_with_api_key;
|
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
use pretty_assertions::assert_eq;
|
|
use serde_json::json;
|
|
use tempfile::TempDir;
|
|
use tokio::time::timeout;
|
|
|
|
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
|
|
|
|
#[tokio::test]
|
|
async fn plugin_search_returns_local_matches_for_api_key_auth() -> Result<()> {
|
|
{
|
|
let codex_home = TempDir::new()?;
|
|
let repo_root = TempDir::new()?;
|
|
let curated_root = codex_home.path().join(".tmp/plugins");
|
|
let bundled_alpha_root = codex_home
|
|
.path()
|
|
.join(".tmp/bundled-marketplaces/openai-bundled-alpha");
|
|
write_local_marketplace(
|
|
&curated_root,
|
|
"openai-api-curated",
|
|
"api_marketplace.json",
|
|
&[LocalPluginFixture {
|
|
name: "calendar-built-in",
|
|
display_name: "Calendar Built In",
|
|
keywords: &[],
|
|
description: "Built-in calendar",
|
|
}],
|
|
)?;
|
|
write_local_marketplace(
|
|
repo_root.path(),
|
|
"personal-tools",
|
|
"marketplace.json",
|
|
&[
|
|
LocalPluginFixture {
|
|
name: "developer-tools",
|
|
display_name: "Developer Tools",
|
|
keywords: &["api-key"],
|
|
description: "Manage credentials",
|
|
},
|
|
LocalPluginFixture {
|
|
name: "japanese-notes",
|
|
display_name: "日本語メモ",
|
|
keywords: &[],
|
|
description: "Japanese notes",
|
|
},
|
|
],
|
|
)?;
|
|
write_local_marketplace(
|
|
&bundled_alpha_root,
|
|
"openai-bundled-alpha",
|
|
"marketplace.json",
|
|
&[LocalPluginFixture {
|
|
name: "alpha-calendar",
|
|
display_name: "Alpha Calendar",
|
|
keywords: &[],
|
|
description: "Built-in alpha calendar",
|
|
}],
|
|
)?;
|
|
std::fs::write(
|
|
codex_home.path().join("config.toml"),
|
|
"[features]\nplugins = true\n",
|
|
)?;
|
|
login_with_api_key(
|
|
codex_home.path(),
|
|
"sk-test-key",
|
|
AuthCredentialsStoreMode::File,
|
|
AuthKeyringBackendKind::default(),
|
|
)?;
|
|
|
|
let mut app_server = TestAppServer::builder()
|
|
.with_codex_home(codex_home.path())
|
|
.without_auto_env()
|
|
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
|
|
.await?;
|
|
|
|
for (scope, search_term, expected_names) in [
|
|
(
|
|
Some(PluginSearchScope::Global),
|
|
"calendar",
|
|
vec!["calendar-built-in", "alpha-calendar"],
|
|
),
|
|
(
|
|
Some(PluginSearchScope::Personal),
|
|
"API key",
|
|
vec!["developer-tools"],
|
|
),
|
|
(
|
|
Some(PluginSearchScope::Personal),
|
|
"日本語",
|
|
vec!["japanese-notes"],
|
|
),
|
|
(Some(PluginSearchScope::Personal), "calendar", Vec::new()),
|
|
(Some(PluginSearchScope::Workspace), "calendar", Vec::new()),
|
|
(
|
|
None,
|
|
"calendar",
|
|
vec!["calendar-built-in", "alpha-calendar"],
|
|
),
|
|
(None, "!!!", Vec::new()),
|
|
] {
|
|
let request_id = app_server
|
|
.send_plugin_search_request(PluginSearchParams {
|
|
search_term: search_term.to_string(),
|
|
scope,
|
|
cwds: Some(vec![
|
|
AbsolutePathBuf::try_from(repo_root.path())?,
|
|
AbsolutePathBuf::try_from(bundled_alpha_root.as_path())?,
|
|
]),
|
|
cursor: None,
|
|
limit: None,
|
|
})
|
|
.await?;
|
|
let response: PluginSearchResponse =
|
|
timeout(DEFAULT_TIMEOUT, app_server.read_response(request_id)).await??;
|
|
|
|
assert_eq!(
|
|
response
|
|
.data
|
|
.iter()
|
|
.map(|result| result.plugin.name.as_str())
|
|
.collect::<Vec<_>>(),
|
|
expected_names
|
|
);
|
|
assert_eq!(response.next_cursor, None);
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
struct LocalPluginFixture<'a> {
|
|
name: &'a str,
|
|
display_name: &'a str,
|
|
keywords: &'a [&'a str],
|
|
description: &'a str,
|
|
}
|
|
|
|
fn write_local_marketplace(
|
|
root: &std::path::Path,
|
|
marketplace_name: &str,
|
|
manifest_name: &str,
|
|
plugins: &[LocalPluginFixture<'_>],
|
|
) -> Result<AbsolutePathBuf> {
|
|
std::fs::create_dir_all(root.join(".git"))?;
|
|
std::fs::create_dir_all(root.join(".agents/plugins"))?;
|
|
let marketplace_path = root.join(".agents/plugins").join(manifest_name);
|
|
let entries = plugins
|
|
.iter()
|
|
.map(|plugin| {
|
|
json!({
|
|
"name": plugin.name,
|
|
"source": {
|
|
"source": "local",
|
|
"path": format!("./plugins/{}", plugin.name),
|
|
},
|
|
})
|
|
})
|
|
.collect::<Vec<_>>();
|
|
std::fs::write(
|
|
&marketplace_path,
|
|
serde_json::to_string(&json!({
|
|
"name": marketplace_name,
|
|
"plugins": entries,
|
|
}))?,
|
|
)?;
|
|
|
|
for plugin in plugins {
|
|
let plugin_manifest = root.join("plugins").join(plugin.name).join(".codex-plugin");
|
|
std::fs::create_dir_all(&plugin_manifest)?;
|
|
std::fs::write(
|
|
plugin_manifest.join("plugin.json"),
|
|
serde_json::to_string(&json!({
|
|
"name": plugin.name,
|
|
"keywords": plugin.keywords,
|
|
"interface": {
|
|
"displayName": plugin.display_name,
|
|
"shortDescription": plugin.description,
|
|
},
|
|
}))?,
|
|
)?;
|
|
}
|
|
|
|
Ok(AbsolutePathBuf::try_from(marketplace_path)?)
|
|
}
|