mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Fetch remote installed plugins across all scopes (#37210)
## What changed - Fetch the paginated installed-plugin snapshot without a `scope` query instead of issuing separate requests for global, user, and workspace plugins. - Use the combined snapshot for installed-plugin caching and bundle synchronization while continuing to reconcile each scope's marketplace independently. ## Testing - Cover pagination across mixed scopes, request query parameters, marketplace reconciliation, stale cache cleanup, and discoverable-plugin filtering. GitOrigin-RevId: 7428a9db81d7ec04e65cc4b236b652278b200956
This commit is contained in:
1 parent
0a0ebb8535
commit
1ae82ce6a5
8 files changed
+562
-529
No files matched your search
@@ -8,6 +8,8 @@ use wiremock::ResponseTemplate;
|
||||
use wiremock::matchers::header_exists;
|
||||
use wiremock::matchers::method;
|
||||
use wiremock::matchers::path;
|
||||
use wiremock::matchers::query_param;
|
||||
use wiremock::matchers::query_param_is_missing;
|
||||
|
||||
#[tokio::test]
|
||||
async fn remote_plugin_list_routes_the_complete_query_url() {
|
||||
@@ -46,6 +48,84 @@ async fn remote_plugin_list_routes_the_complete_query_url() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn remote_installed_plugins_paginate_across_all_scopes_without_download_urls() {
|
||||
let server = MockServer::start().await;
|
||||
let installed_plugin = |scope: RemotePluginScope, id: &str, name: &str| {
|
||||
let mut plugin = directory_plugin(id, name);
|
||||
plugin.scope = scope;
|
||||
if scope == RemotePluginScope::Workspace {
|
||||
plugin.discoverability = Some(RemotePluginShareDiscoverability::Listed);
|
||||
}
|
||||
let mut plugin = serde_json::to_value(plugin).expect("serialize installed plugin");
|
||||
plugin["enabled"] = serde_json::json!(true);
|
||||
plugin
|
||||
};
|
||||
let global = installed_plugin(RemotePluginScope::Global, "plugin-global", "global-plugin");
|
||||
let user = installed_plugin(RemotePluginScope::User, "plugin-user", "user-plugin");
|
||||
let workspace = installed_plugin(
|
||||
RemotePluginScope::Workspace,
|
||||
"plugin-workspace",
|
||||
"workspace-plugin",
|
||||
);
|
||||
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/backend-api/ps/plugins/installed"))
|
||||
.and(query_param_is_missing("scope"))
|
||||
.and(query_param("limit", "200"))
|
||||
.and(query_param_is_missing("includeDownloadUrls"))
|
||||
.and(query_param_is_missing("pageToken"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"plugins": [user.clone(), workspace.clone()],
|
||||
"pagination": {"next_page_token": "next page/+"},
|
||||
})))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/backend-api/ps/plugins/installed"))
|
||||
.and(query_param_is_missing("scope"))
|
||||
.and(query_param("limit", "200"))
|
||||
.and(query_param_is_missing("includeDownloadUrls"))
|
||||
.and(query_param("pageToken", "next page/+"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"plugins": [global.clone()],
|
||||
"pagination": {"next_page_token": null},
|
||||
})))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
let (config, selected_urls) =
|
||||
recording_remote_plugin_service_config(format!("{}/backend-api", server.uri()));
|
||||
let auth = CodexAuth::create_dummy_chatgpt_auth_for_testing();
|
||||
|
||||
let installed_plugins = fetch_remote_installed_plugins(&config, Some(&auth))
|
||||
.await
|
||||
.expect("all-scopes installed plugin request should succeed");
|
||||
let expected_plugins = [user, global, workspace]
|
||||
.into_iter()
|
||||
.map(|plugin| {
|
||||
let plugin = serde_json::from_value(plugin).expect("deserialize installed plugin");
|
||||
remote_installed_plugin_to_cache_entry(&plugin).expect("valid installed plugin")
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(installed_plugins, expected_plugins);
|
||||
assert_eq!(
|
||||
recorded_http_client_urls(&selected_urls),
|
||||
vec![
|
||||
format!(
|
||||
"{}/backend-api/ps/plugins/installed?limit=200",
|
||||
server.uri()
|
||||
),
|
||||
format!(
|
||||
"{}/backend-api/ps/plugins/installed?limit=200&pageToken=next+page%2F%2B",
|
||||
server.uri()
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cached_remote_plugin_catalog_scopes_returns_existing_scopes() {
|
||||
let codex_home = tempfile::tempdir().expect("create codex home");
|
||||
|
||||
Reference in new issue
Block a user