From 41761eed55ff1e9d5c948864c09920d34ea2ca0f Mon Sep 17 00:00:00 2001 From: Alce Ops Date: Fri, 1 May 2026 05:07:42 -0400 Subject: [PATCH 1/2] mmctl: allow local bot create --- server/cmd/mmctl/commands/bot.go | 1 - server/cmd/mmctl/commands/bot_e2e_test.go | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/cmd/mmctl/commands/bot.go b/server/cmd/mmctl/commands/bot.go index 75fadfce733..fd005a8d13d 100644 --- a/server/cmd/mmctl/commands/bot.go +++ b/server/cmd/mmctl/commands/bot.go @@ -27,7 +27,6 @@ var CreateBotCmd = &cobra.Command{ Short: "Create bot", Long: "Create bot.", Example: ` bot create testbot`, - PreRun: disableLocalPrecheck, RunE: withClient(botCreateCmdF), Args: cobra.ExactArgs(1), } diff --git a/server/cmd/mmctl/commands/bot_e2e_test.go b/server/cmd/mmctl/commands/bot_e2e_test.go index 6a3627af59d..1ed8fcb34e4 100644 --- a/server/cmd/mmctl/commands/bot_e2e_test.go +++ b/server/cmd/mmctl/commands/bot_e2e_test.go @@ -401,7 +401,7 @@ func (s *MmctlE2ETestSuite) TestBotCreateCmdF() { s.th.App.UpdateConfig(func(c *model.Config) { *c.ServiceSettings.EnableBotAccountCreation = true }) defer s.th.App.UpdateConfig(func(c *model.Config) { *c.ServiceSettings.EnableBotAccountCreation = createBots }) - s.Run("MM-T3941 Create Bot with an access token", func() { + s.Run("Create Bot with an access token without permission", func() { printer.Clean() cmd := &cobra.Command{} @@ -411,10 +411,15 @@ func (s *MmctlE2ETestSuite) TestBotCreateCmdF() { s.Require().Error(err) s.Require().Empty(printer.GetLines()) s.Require().Empty(printer.GetErrorLines()) + }) + s.RunForSystemAdminAndLocal("MM-T3941 Create Bot with an access token", func(c client.Client) { printer.Clean() - err = botCreateCmdF(s.th.SystemAdminClient, cmd, []string{"testbot"}) + cmd := &cobra.Command{} + cmd.Flags().Bool("with-token", true, "") + + err := botCreateCmdF(c, cmd, []string{model.NewUsername()}) s.Require().NoError(err) s.Require().Equal(2, len(printer.GetLines())) bot, ok := printer.GetLines()[0].(*model.Bot) From dd3d863e48e38cb3d6b65af036af9b3161a5d0fc Mon Sep 17 00:00:00 2001 From: Alce Ops Date: Fri, 1 May 2026 05:55:57 -0400 Subject: [PATCH 2/2] test: harden local bot create permission check --- server/cmd/mmctl/commands/bot_e2e_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/cmd/mmctl/commands/bot_e2e_test.go b/server/cmd/mmctl/commands/bot_e2e_test.go index 1ed8fcb34e4..7483ab1b9b5 100644 --- a/server/cmd/mmctl/commands/bot_e2e_test.go +++ b/server/cmd/mmctl/commands/bot_e2e_test.go @@ -407,8 +407,10 @@ func (s *MmctlE2ETestSuite) TestBotCreateCmdF() { cmd := &cobra.Command{} cmd.Flags().Bool("with-token", true, "") - err := botCreateCmdF(s.th.Client, cmd, []string{"testbot"}) + username := model.NewUsername() + err := botCreateCmdF(s.th.Client, cmd, []string{username}) s.Require().Error(err) + s.Require().Contains(err.Error(), "permissions") s.Require().Empty(printer.GetLines()) s.Require().Empty(printer.GetErrorLines()) })