Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Apply app routing policy to unauthenticated plugin reads (#41230)

willwang-openaie9a6d731b783
diff --git a/codex-rs/app-server/tests/suite/v2/plugin_read.rs b/codex-rs/app-server/tests/suite/v2/plugin_read.rs
index 73098ae5c7..9883ce79b2 100644
--- a/codex-rs/app-server/tests/suite/v2/plugin_read.rs
+++ b/codex-rs/app-server/tests/suite/v2/plugin_read.rs
@@ -1425,6 +1425,14 @@ async fn plugin_read_agent_plugin_excludes_nested_skills() -> Result<()> {
#[tokio::test]
async fn plugin_read_returns_plugin_details_with_bundle_contents() -> Result<()> {
let codex_home = TempDir::new()?;
+ write_chatgpt_auth(
+ codex_home.path(),
+ ChatGptAuthFixture::new("chatgpt-token")
+ .account_id("account-123")
+ .chatgpt_user_id("user-123")
+ .chatgpt_account_id("account-123"),
+ AuthCredentialsStoreMode::File,
+ )?;
let repo_root = TempDir::new()?;
let plugin_root = repo_root.path().join("plugins/demo-plugin");
std::fs::create_dir_all(repo_root.path().join(".git"))?;
diff --git a/codex-rs/core-plugins/src/manager.rs b/codex-rs/core-plugins/src/manager.rs
index b6a50170bf..a47f6f50bc 100644
--- a/codex-rs/core-plugins/src/manager.rs
+++ b/codex-rs/core-plugins/src/manager.rs
@@ -2543,7 +2543,7 @@ impl PluginsManager {
manifest_format,
)
.await;
- if manifest_format == PluginManifestFormat::Legacy && auth_mode.is_some() {
+ if manifest_format == PluginManifestFormat::Legacy {
apply_app_mcp_routing_policy(
&mut app_declarations,
&mut mcp_servers,
diff --git a/codex-rs/core-plugins/src/manager_tests.rs b/codex-rs/core-plugins/src/manager_tests.rs
index 0b8413a4fd..123dfb9f4d 100644
--- a/codex-rs/core-plugins/src/manager_tests.rs
+++ b/codex-rs/core-plugins/src/manager_tests.rs
@@ -4127,6 +4127,20 @@ plugins = true
vec!["other-mcp".to_string(), "sample-mcp".to_string()]
);
assert!(api_key_outcome.plugin.apps.is_empty());
+
+ let no_auth_outcome = test_plugins_manager_with_options(
+ tmp.path().to_path_buf(),
+ Some(Product::Codex),
+ /*auth_mode*/ None,
+ )
+ .read_plugin_for_config(&config, &request)
+ .await
+ .unwrap();
+ assert_eq!(
+ no_auth_outcome.plugin.mcp_server_names,
+ vec!["other-mcp".to_string(), "sample-mcp".to_string()]
+ );
+ assert!(no_auth_outcome.plugin.apps.is_empty());
}
#[tokio::test]
@@ -4166,7 +4180,11 @@ plugins = true
);
let config = load_config(tmp.path(), &repo_root).await;
- let manager = test_plugins_manager(tmp.path().to_path_buf());
+ let manager = test_plugins_manager_with_options(
+ tmp.path().to_path_buf(),
+ Some(Product::Codex),
+ Some(AuthMode::Chatgpt),
+ );
let outcome = manager
.read_plugin_for_config(
&config,
@@ -4606,19 +4624,23 @@ enabled = false
);
let config = load_config(tmp.path(), &repo_root).await;
- let outcome = test_plugins_manager(tmp.path().to_path_buf())
- .read_plugin_for_config(
- &config,
- &PluginReadRequest {
- plugin_name: "toolkit".to_string(),
- marketplace_path: AbsolutePathBuf::try_from(
- repo_root.join(".agents/plugins/marketplace.json"),
- )
- .unwrap(),
- },
- )
- .await
- .unwrap();
+ let outcome = test_plugins_manager_with_options(
+ tmp.path().to_path_buf(),
+ Some(Product::Codex),
+ Some(AuthMode::Chatgpt),
+ )
+ .read_plugin_for_config(
+ &config,
+ &PluginReadRequest {
+ plugin_name: "toolkit".to_string(),
+ marketplace_path: AbsolutePathBuf::try_from(
+ repo_root.join(".agents/plugins/marketplace.json"),
+ )
+ .unwrap(),
+ },
+ )
+ .await
+ .unwrap();
assert_eq!(outcome.plugin.details_unavailable_reason, None);
assert_eq!(