mmctl: allow local bot create

This commit is contained in:
Alce Ops 2026-05-01 05:07:42 -04:00
parent 082f6ba85a
commit 41761eed55
2 changed files with 7 additions and 3 deletions

View file

@ -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),
}

View file

@ -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)