Harden marketplace listing and debug smoke errors

This commit is contained in:
npc0-hue
2026-08-22 22:31:33 +08:00
parent ebd616c549
commit 4d945eb809
3 changed files with 38 additions and 3 deletions
+7
View File
@@ -1532,6 +1532,13 @@ func (svc *CoreService) ListMarketplacePlugins(filter domain.PluginMarketplaceFi
if filter.Keyword != "" && !marketplacePluginMatchesKeyword(projected, filter.Keyword) {
continue
}
// The registry can outlive a manifest contract. Do not let a historical
// plugin with removed capabilities make the usable marketplace entries
// fail as one invalid response; it is still available through the plugin
// registry for an explicit refresh or migration.
if err := validator.ValidatePluginMarketplacePlugin(projected); err != nil {
continue
}
items = append(items, projected)
}
if err := validator.ValidatePluginMarketplacePlugins(items); err != nil {
+24
View File
@@ -1324,6 +1324,30 @@ func TestCoreServiceMarketplacePluginsAreFilteredSafeAndStateful(t *testing.T) {
}
}
func TestCoreServiceMarketplaceListSkipsHistoricalInvalidCapabilities(t *testing.T) {
svc := newTestCoreService()
if _, err := svc.RegisterGamePluginManifest(validPluginManifestRegistration()); err != nil {
t.Fatalf("register current manifest: %v", err)
}
legacy := gamePluginFromManifestRegistration(validPluginManifestRegistration())
legacy.ID = "game.legacy"
legacy.Name = "Legacy Server"
legacy.RequiredRunCapabilities = append(legacy.RequiredRunCapabilities, "remote.run.protected.sql", "remote.run.protected.rcon")
legacy.RemoteAccess.RunCapabilities = append(legacy.RemoteAccess.RunCapabilities, "remote.run.protected.sql", "remote.run.protected.rcon")
if err := svc.store.GamePlugins().Create(legacy); err != nil {
t.Fatalf("seed historical plugin: %v", err)
}
listed, err := svc.ListMarketplacePlugins(domain.PluginMarketplaceFilter{})
if err != nil {
t.Fatalf("list marketplace plugins with historical record: %v", err)
}
if len(listed) != 1 || listed[0].ID != "game.example" {
t.Fatalf("expected only current marketplace plugin, got %+v", listed)
}
}
func TestCoreServiceAuthorizesPluginBridgeActions(t *testing.T) {
svc := newTestCoreService()
if _, err := svc.RegisterGamePluginManifest(validPluginManifestRegistration()); err != nil {