Files
zeekay 8feb24ea1f One name for this fork, and it is ours
The server module named github.com/hanzoai/team/server/v8 — a path that
resolves to the retired workspace's repository, not this one — while
server/public still published github.com/mattermost/mattermost/server/public.
Both are github.com/hanzoteam/server/... now, which is where this code
actually lives.

That second half is what made the binary unbootable. Upstream's public path
stayed claimed by upstream, mattermost-plugin-ai imported it, and the build
linked public/model twice; public/plugin's gob.Register then ran twice under
one name and panicked at init, before main. Reverting the rename traded the
brand for a working binary. Rebranding the plugin alongside it needs no such
trade: the agents fork is github.com/hanzoteam/agents/v2 against our public
module, so no module named mattermost/mattermost is in the graph at all.

Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and
it is ours.
2026-08-28 23:35:36 -07:00

612 lines
21 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package commands
import (
"fmt"
"net/http"
"net/http/httptest"
"path/filepath"
"github.com/hashicorp/go-multierror"
"github.com/hanzoteam/server/server/public/model"
"github.com/hanzoteam/server/server/v8"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/hanzoteam/server/server/v8/cmd/mmctl/client"
"github.com/hanzoteam/server/server/v8/cmd/mmctl/printer"
)
func (s *MmctlE2ETestSuite) TestPluginAddCmd() {
s.SetupTestHelper().InitBasic(s.T())
pluginPath := filepath.Join(server.GetPackagePath(), "tests", "testplugin.tar.gz")
s.RunForSystemAdminAndLocal("add an already installed plugin without force", func(c client.Client) {
printer.Clean()
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
*cfg.PluginSettings.EnableUploads = false
})
err := pluginAddCmdF(c, &cobra.Command{}, []string{pluginPath})
s.Require().Nil(err)
s.Require().Equal(1, len(printer.GetLines()))
s.Require().Contains(printer.GetLines()[0], "Added plugin: ")
printer.Clean()
err = pluginAddCmdF(c, &cobra.Command{}, []string{pluginPath})
s.Require().ErrorContains(err, "Unable to install plugin. A plugin with the same ID is already installed.")
s.Require().Equal(0, len(printer.GetLines()))
s.Require().Equal(1, len(printer.GetErrorLines()))
s.Require().Contains(printer.GetErrorLines()[0], "Unable to install plugin. A plugin with the same ID is already installed.")
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
// teardown
pInfo := plugins.Inactive[0]
err = pluginDeleteCmdF(c, &cobra.Command{}, []string{pInfo.Id})
s.Require().Nil(err)
})
s.RunForSystemAdminAndLocal("add an already installed plugin with force", func(c client.Client) {
printer.Clean()
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
*cfg.PluginSettings.EnableUploads = false
})
err := pluginAddCmdF(c, &cobra.Command{}, []string{pluginPath})
s.Require().Nil(err)
s.Require().Equal(1, len(printer.GetLines()))
s.Require().Contains(printer.GetLines()[0], "Added plugin: ")
printer.Clean()
cmd := &cobra.Command{}
cmd.Flags().Bool("force", true, "")
err = pluginAddCmdF(c, cmd, []string{pluginPath})
s.Require().Nil(err)
s.Require().Equal(1, len(printer.GetLines()))
s.Require().Equal(0, len(printer.GetErrorLines()))
s.Require().Contains(printer.GetLines()[0], "Added plugin: ")
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
// teardown
pInfo := plugins.Inactive[0]
err = pluginDeleteCmdF(c, &cobra.Command{}, []string{pInfo.Id})
s.Require().Nil(err)
})
s.RunForSystemAdminAndLocal("admin and local can't add plugins if the config doesn't allow it", func(c client.Client) {
printer.Clean()
err := pluginAddCmdF(c, &cobra.Command{}, []string{pluginPath})
s.Require().ErrorContains(err, "Plugins and/or plugin uploads have been disabled.")
s.Require().Equal(1, len(printer.GetErrorLines()))
s.Require().Contains(printer.GetErrorLines()[0], "Plugins and/or plugin uploads have been disabled.")
})
s.RunForSystemAdminAndLocal("admin and local can add a plugin if the config allows it", func(c client.Client) {
printer.Clean()
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
*cfg.PluginSettings.EnableUploads = false
})
err := pluginAddCmdF(c, &cobra.Command{}, []string{pluginPath})
s.Require().Nil(err)
s.Require().Equal(1, len(printer.GetLines()))
s.Require().Contains(printer.GetLines()[0], "Added plugin: ")
res, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Equal(1, len(res.Inactive))
// teardown
pInfo := res.Inactive[0]
err = pluginDeleteCmdF(c, &cobra.Command{}, []string{pInfo.Id})
s.Require().Nil(err)
})
s.Run("normal user can't add plugin", func() {
printer.Clean()
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
*cfg.PluginSettings.EnableUploads = false
})
err := pluginAddCmdF(s.th.Client, &cobra.Command{}, []string{pluginPath})
s.Require().ErrorContains(err, "You do not have the appropriate permissions")
s.Require().Equal(1, len(printer.GetErrorLines()))
s.Require().Contains(printer.GetErrorLines()[0], "You do not have the appropriate permissions")
})
}
func (s *MmctlE2ETestSuite) TestPluginInstallURLCmd() {
s.SetupTestHelper().InitBasic(s.T())
testsDir := filepath.Join(server.GetPackagePath(), "tests")
fileServer := httptest.NewServer(http.FileServer(http.Dir(testsDir)))
defer fileServer.Close()
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
*cfg.PluginSettings.AllowInsecureDownloadURL = true
})
const (
plugin1ID = "testplugin"
plugin2ID = "testplugin2"
)
plugin1URL := fileServer.URL + "/testplugin.tar.gz"
plugin2URL := fileServer.URL + "/testplugin2.tar.gz"
s.RunForSystemAdminAndLocal("install new plugins", func(c client.Client) {
printer.Clean()
defer removePluginIfInstalled(c, s, plugin1ID)
defer removePluginIfInstalled(c, s, plugin2ID)
err := pluginInstallURLCmdF(c, &cobra.Command{}, []string{plugin1URL, plugin2URL})
s.Require().Nil(err)
s.Require().Len(printer.GetLines(), 2)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Equal(plugin1ID, printer.GetLines()[0].(*model.Manifest).Id)
s.Require().Equal(plugin2ID, printer.GetLines()[1].(*model.Manifest).Id)
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 2)
})
s.Run("install a plugin without permissions", func() {
printer.Clean()
defer removePluginIfInstalled(s.th.Client, s, plugin1ID)
var expected error
expected = multierror.Append(expected, errors.New("You do not have the appropriate permissions.")) //nolint:revive
err := pluginInstallURLCmdF(s.th.Client, &cobra.Command{}, []string{plugin1URL})
s.Require().ErrorContains(err, expected.Error())
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Contains(printer.GetErrorLines()[0], fmt.Sprintf("Unable to install plugin from URL \"%s\".", plugin1URL))
s.Require().Contains(printer.GetErrorLines()[0], "You do not have the appropriate permissions.")
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 0)
})
s.RunForSystemAdminAndLocal("install a nonexistent plugin", func(c client.Client) {
printer.Clean()
nonexistentURL := fileServer.URL + "/nonexistent-plugin.tar.gz"
var expected error
expected = multierror.Append(expected, errors.New("An error occurred while downloading the plugin.")) //nolint:revive
err := pluginInstallURLCmdF(c, &cobra.Command{}, []string{nonexistentURL})
s.Require().ErrorContains(err, expected.Error())
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Contains(printer.GetErrorLines()[0], fmt.Sprintf("Unable to install plugin from URL \"%s\".", nonexistentURL))
s.Require().Contains(printer.GetErrorLines()[0], "An error occurred while downloading the plugin.")
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 0)
})
s.RunForSystemAdminAndLocal("install an already installed plugin without force", func(c client.Client) {
printer.Clean()
defer removePluginIfInstalled(c, s, plugin1ID)
err := pluginInstallURLCmdF(c, &cobra.Command{}, []string{plugin1URL})
s.Require().Nil(err)
s.Require().Len(printer.GetLines(), 1)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Equal(plugin1ID, printer.GetLines()[0].(*model.Manifest).Id)
var expected error
expected = multierror.Append(expected, errors.New("Unable to install plugin. A plugin with the same ID is already installed.")) //nolint:revive
err = pluginInstallURLCmdF(c, &cobra.Command{}, []string{plugin1URL})
s.Require().ErrorContains(err, expected.Error())
s.Require().Len(printer.GetLines(), 1)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Contains(printer.GetErrorLines()[0], fmt.Sprintf("Unable to install plugin from URL \"%s\".", plugin1URL))
s.Require().Contains(printer.GetErrorLines()[0], "Unable to install plugin. A plugin with the same ID is already installed.")
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
})
s.RunForSystemAdminAndLocal("install an already installed plugin with force", func(c client.Client) {
printer.Clean()
defer removePluginIfInstalled(c, s, plugin1ID)
err := pluginInstallURLCmdF(c, &cobra.Command{}, []string{plugin1URL})
s.Require().Nil(err)
s.Require().Len(printer.GetLines(), 1)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Equal(plugin1ID, printer.GetLines()[0].(*model.Manifest).Id)
cmd := &cobra.Command{}
cmd.Flags().Bool("force", true, "")
err = pluginInstallURLCmdF(c, cmd, []string{plugin1URL})
s.Require().Nil(err)
s.Require().Len(printer.GetLines(), 2)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Equal(plugin1ID, printer.GetLines()[1].(*model.Manifest).Id)
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
})
}
func (s *MmctlE2ETestSuite) TestPluginDeleteCmd() {
s.SetupTestHelper().InitBasic(s.T())
testsDir := filepath.Join(server.GetPackagePath(), "tests")
fileServer := httptest.NewServer(http.FileServer(http.Dir(testsDir)))
defer fileServer.Close()
const (
pluginID = "testplugin"
dummyPluginID = "randompluginxz"
)
pluginURL := fileServer.URL + "/testplugin.tar.gz"
s.RunForSystemAdminAndLocal("Delete Plugin", func(c client.Client) {
printer.Clean()
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
*cfg.PluginSettings.AllowInsecureDownloadURL = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
*cfg.PluginSettings.EnableUploads = false
*cfg.PluginSettings.AllowInsecureDownloadURL = false
})
errInstall := pluginInstallURLCmdF(c, &cobra.Command{}, []string{pluginURL})
s.Require().Nil(errInstall)
s.Require().Len(printer.GetLines(), 1)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Equal(pluginID, printer.GetLines()[0].(*model.Manifest).Id)
pluginsAvail, appErrInstall := s.th.App.GetPlugins()
s.Require().Nil(appErrInstall)
s.Require().Len(pluginsAvail.Active, 0)
s.Require().Len(pluginsAvail.Inactive, 1)
err := pluginDeleteCmdF(c, &cobra.Command{}, []string{pluginID})
s.Require().Nil(err)
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 0)
})
s.RunForSystemAdminAndLocal("Delete Unknown Plugin", func(c client.Client) {
printer.Clean()
err := pluginDeleteCmdF(c, &cobra.Command{}, []string{dummyPluginID})
s.Require().ErrorContains(err, "Plugins have been disabled.")
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Contains(printer.GetErrorLines()[0], fmt.Sprintf("Unable to delete plugin: %s.", dummyPluginID))
s.Require().Contains(printer.GetErrorLines()[0], "Plugins have been disabled.")
})
s.Run("Delete a Plugin without permissions", func() {
printer.Clean()
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
*cfg.PluginSettings.AllowInsecureDownloadURL = true
})
defer func() {
errDelete := pluginDeleteCmdF(s.th.SystemAdminClient, &cobra.Command{}, []string{pluginID})
s.Require().Nil(errDelete)
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
*cfg.PluginSettings.EnableUploads = false
*cfg.PluginSettings.AllowInsecureDownloadURL = false
})
}()
errInstall := pluginInstallURLCmdF(s.th.SystemAdminClient, &cobra.Command{}, []string{pluginURL})
s.Require().Nil(errInstall)
s.Require().Len(printer.GetLines(), 1)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Equal(pluginID, printer.GetLines()[0].(*model.Manifest).Id)
pluginsAvail, appErrInstall := s.th.App.GetPlugins()
s.Require().Nil(appErrInstall)
s.Require().Len(pluginsAvail.Active, 0)
s.Require().Len(pluginsAvail.Inactive, 1)
err := pluginDeleteCmdF(s.th.Client, &cobra.Command{}, []string{pluginID})
s.Require().ErrorContains(err, "You do not have the appropriate permissions.")
s.Require().Len(printer.GetLines(), 1)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Contains(printer.GetErrorLines()[0], fmt.Sprintf("Unable to delete plugin: %s.", pluginID))
s.Require().Contains(printer.GetErrorLines()[0], "You do not have the appropriate permissions.")
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
})
}
func (s *MmctlE2ETestSuite) TestPluginListCmdF() {
s.SetupTestHelper().InitBasic(s.T())
s.Run("Error when appropriate permissions are not available", func() {
printer.Clean()
enablePlugin := *s.th.App.Config().PluginSettings.Enable
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = enablePlugin
})
cmd := &cobra.Command{}
err := pluginListCmdF(s.th.Client, cmd, []string{})
s.Require().Error(err)
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 0)
s.Equal("Unable to list plugins. Error: You do not have the appropriate permissions.", err.Error())
})
s.RunForSystemAdminAndLocal("Error when plugins are disabled", func(c client.Client) {
printer.Clean()
enablePlugin := *s.th.App.Config().PluginSettings.Enable
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = enablePlugin
})
cmd := &cobra.Command{}
err := pluginListCmdF(c, cmd, []string{})
s.Require().Error(err)
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 0)
s.Equal("Unable to list plugins. Error: Plugins have been disabled. Please check your logs for details.", err.Error())
})
s.RunForSystemAdminAndLocal("Success when appropriate permissions are available", func(c client.Client) {
printer.Clean()
enablePlugin := *s.th.App.Config().PluginSettings.Enable
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = enablePlugin
})
cmd := &cobra.Command{}
err := pluginListCmdF(c, cmd, []string{})
s.Require().Nil(err)
s.Require().Len(printer.GetLines(), 3)
s.Require().Len(printer.GetErrorLines(), 0)
})
s.RunForSystemAdminAndLocal("Success when appropriate permissions are available but prints json plugins", func(c client.Client) {
printer.Clean()
enablePlugin := *s.th.App.Config().PluginSettings.Enable
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
})
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = enablePlugin
})
cmd := &cobra.Command{}
cmd.Flags().String("format", "json", "")
err := pluginListCmdF(c, cmd, []string{})
s.Require().Nil(err)
s.Require().Len(printer.GetLines(), 1)
s.Require().Len(printer.GetErrorLines(), 0)
})
}
func (s *MmctlE2ETestSuite) TestPluginDisableCmd() {
s.SetupTestHelper().InitBasic(s.T())
pluginID := "testplugin"
pluginURL := filepath.Join(server.GetPackagePath(), "tests", "testplugin.tar.gz")
nonExistentPluginID := "nonExistentPluginID"
enablePlugin := *s.th.App.Config().PluginSettings.Enable
enableUploads := *s.th.App.Config().PluginSettings.EnableUploads
defer func() {
appErr := s.th.App.Channels().RemovePlugin(pluginID)
if appErr != nil {
s.Require().Contains(appErr.Error(), "Plugin is not installed.")
}
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 0)
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = enablePlugin
*cfg.PluginSettings.EnableUploads = enableUploads
})
}()
// Enable plugin uploads
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = true
*cfg.PluginSettings.EnableUploads = true
})
// Install plugin first
err := pluginAddCmdF(s.th.SystemAdminClient, &cobra.Command{}, []string{pluginURL})
s.Require().Nil(err)
s.RunForSystemAdminAndLocal("Successful disable plugin", func(c client.Client) {
printer.Clean()
appErr := s.th.App.EnablePlugin(pluginID)
s.Require().Nil(appErr)
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 1)
s.Require().Len(plugins.Inactive, 0)
cmd := &cobra.Command{}
err := pluginDisableCmdF(c, cmd, []string{pluginID})
s.Require().Nil(err)
plugins, appErr = s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
s.Require().Len(printer.GetLines(), 1)
s.Require().Equal(printer.GetLines()[0], "Disabled plugin: "+pluginID)
})
s.Run("error for disable plugin due insufficient permissions", func() {
printer.Clean()
appErr := s.th.App.EnablePlugin(pluginID)
s.Require().Nil(appErr)
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 1)
s.Require().Len(plugins.Inactive, 0)
cmd := &cobra.Command{}
err := pluginDisableCmdF(s.th.Client, cmd, []string{pluginID})
s.Require().NotNil(err)
s.Require().ErrorContains(err, "You do not have the appropriate permissions.")
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Equal(printer.GetErrorLines()[0], "Unable to disable plugin: "+pluginID+". Error: You do not have the appropriate permissions.")
plugins, appErr = s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 1)
s.Require().Len(plugins.Inactive, 0)
appErr = s.th.App.DisablePlugin(pluginID)
s.Require().Nil(appErr)
})
s.RunForSystemAdminAndLocal("error for disabling non existent plugin", func(c client.Client) {
printer.Clean()
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
cmd := &cobra.Command{}
err := pluginDisableCmdF(c, cmd, []string{nonExistentPluginID})
s.Require().NotNil(err)
s.Require().ErrorContains(err, "Plugin is not installed.")
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Equal(printer.GetErrorLines()[0], "Unable to disable plugin: "+nonExistentPluginID+". Error: Plugin is not installed.")
plugins, appErr = s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
})
s.RunForSystemAdminAndLocal("error when plugin configs are disabled", func(c client.Client) {
printer.Clean()
appErr := s.th.App.EnablePlugin(pluginID)
s.Require().Nil(appErr)
plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 1)
s.Require().Len(plugins.Inactive, 0)
enablePlugin2 := *s.th.App.Config().PluginSettings.Enable
defer s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = enablePlugin2
})
s.th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.PluginSettings.Enable = false
})
cmd := &cobra.Command{}
err := pluginDisableCmdF(c, cmd, []string{pluginID})
s.Require().NotNil(err)
s.Require().ErrorContains(err, "Plugins have been disabled. Please check your logs for details.")
s.Require().Len(printer.GetLines(), 0)
s.Require().Len(printer.GetErrorLines(), 1)
s.Require().Equal(printer.GetErrorLines()[0], "Unable to disable plugin: "+pluginID+". Error: Plugins have been disabled. Please check your logs for details.")
})
}