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..7483ab1b9b5 100644 --- a/server/cmd/mmctl/commands/bot_e2e_test.go +++ b/server/cmd/mmctl/commands/bot_e2e_test.go @@ -401,20 +401,27 @@ 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{} 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()) + }) + 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)