fix(plugins): PR #493 - 合并分类修复并保留本地插件删减
This commit is contained in:
commit
f1c7c00f05
7 files changed
+134
-13
No files matched your search
@@ -14,6 +14,7 @@ const (
|
||||
PluginPortraitClearance = "portrait-clearance"
|
||||
PluginAIArtCritique = "ai-art-critique"
|
||||
PluginMediaConversion = "media-conversion"
|
||||
PluginEditorShell = "editor-shell"
|
||||
|
||||
PluginOriginOfficial = "official"
|
||||
PluginOriginSystem = "system"
|
||||
@@ -81,6 +82,10 @@ var officialApplicationPolicies = map[string]PluginManagementView{
|
||||
Origin: PluginOriginOfficial, Kind: PluginKindApplication,
|
||||
ActivationScope: PluginScopeUser, ConfigurationScope: PluginConfigurationNone,
|
||||
},
|
||||
PluginEditorShell: {
|
||||
Origin: PluginOriginOfficial, Kind: PluginKindApplication,
|
||||
ActivationScope: PluginScopeUser, ConfigurationScope: PluginConfigurationNone,
|
||||
},
|
||||
}
|
||||
|
||||
var systemPaymentPolicies = map[string]PluginManagementView{
|
||||
|
||||
@@ -76,3 +76,44 @@ func TestArtCritiqueIsUserToggleableApplication(t *testing.T) {
|
||||
t.Fatalf("AI art critique policy = %#v", policy)
|
||||
}
|
||||
}
|
||||
|
||||
// Regression: editor-shell was missing from officialApplicationPolicies, so the
|
||||
// backend classified it as a system protocol and reported it to the admin page
|
||||
// as "管理员已停用该插件" even though nothing disabled it.
|
||||
func TestEditorShellIsUserToggleableApplication(t *testing.T) {
|
||||
policy := pluginManagement(PluginEditorShell, "bundled")
|
||||
if policy.Origin != PluginOriginOfficial || policy.Kind != PluginKindApplication || policy.ActivationScope != PluginScopeUser || policy.ConfigurationScope != PluginConfigurationNone {
|
||||
t.Fatalf("editor shell policy = %#v", policy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEditorShellReportsPlatformAvailableWithoutPlatformState(t *testing.T) {
|
||||
db, err := gorm.Open(sqlite.Open("file:"+newID()+"?mode=memory&cache=shared"), &gorm.Config{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := db.AutoMigrate(&model.PluginPlatformState{}, &model.UserPluginState{}, &model.AdminAuditEvent{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
center, err := newPluginRuntime(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
svc := &Service{repo: repository.New(db), pluginRuntime: center}
|
||||
user := &model.User{ID: "user-1", Role: model.UserRoleUser}
|
||||
|
||||
states, err := svc.PluginStatesForUser(user)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
state, ok := states[PluginEditorShell]
|
||||
if !ok {
|
||||
t.Fatalf("editor shell missing from plugin states: %#v", states)
|
||||
}
|
||||
if !state.PlatformAvailable || !state.CanToggle {
|
||||
t.Fatalf("editor shell should be a user-toggleable application, got %#v", state)
|
||||
}
|
||||
if state.BlockedReason == "管理员已停用该插件" {
|
||||
t.Fatalf("editor shell reported as admin-disabled: %#v", state)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user