MM-14723: Add config flag for creating bots (#10795)
* MM-14723 add config flag for creating bots * MM-14723 - update i18n to handle new config flag * MM-14723 - change API tests to allow bots by default * Update i18n/en.json Co-Authored-By: andresoro <ao15@my.fsu.edu> * MM-14723: add config flag for enabling/disabling bot creation * undo changes to apitestlib.go to explicitly change config in each test * add unit tests for config changes * MM-14723 update test cases * MM-14723 update test cases to use UpdateConfig method
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
b3aa3d4567
Коммит
30061df036
@@ -36,6 +36,11 @@ func createBot(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if !*c.App.Config().ServiceSettings.CreateBotAccounts {
|
||||
c.Err = model.NewAppError("createBot", "api.bot.create_disabled", nil, "", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
createdBot, err := c.App.CreateBot(bot)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
|
||||
@@ -17,6 +17,10 @@ func TestCreateBot(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
_, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
DisplayName: "a bot",
|
||||
@@ -26,6 +30,23 @@ func TestCreateBot(t *testing.T) {
|
||||
CheckErrorMessage(t, resp, "api.context.permissions.app_error")
|
||||
})
|
||||
|
||||
t.Run("create bot without config permissions", func(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.Config().ServiceSettings.CreateBotAccounts = model.NewBool(false)
|
||||
|
||||
_, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
DisplayName: "a bot",
|
||||
Description: "bot",
|
||||
})
|
||||
|
||||
CheckErrorMessage(t, resp, "api.bot.create_disabled")
|
||||
})
|
||||
|
||||
t.Run("create bot with permissions", func(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
@@ -33,6 +54,9 @@ func TestCreateBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -55,6 +79,9 @@ func TestCreateBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
_, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: "username",
|
||||
@@ -81,6 +108,10 @@ func TestPatchBot(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
defer th.RestoreDefaultRolePermissions(th.SaveDefaultRolePermissions())
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
DisplayName: "a bot",
|
||||
@@ -100,6 +131,9 @@ func TestPatchBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_OTHERS_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -120,6 +154,9 @@ func TestPatchBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OTHERS_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -150,6 +187,9 @@ func TestPatchBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -177,6 +217,9 @@ func TestPatchBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -204,6 +247,9 @@ func TestPatchBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -235,6 +281,9 @@ func TestPatchBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -266,6 +315,9 @@ func TestPatchBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -293,6 +345,10 @@ func TestGetBot(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot1, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
DisplayName: "a bot",
|
||||
@@ -320,6 +376,10 @@ func TestGetBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
myBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
DisplayName: "my bot",
|
||||
@@ -429,6 +489,10 @@ func TestGetBots(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot1, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
DisplayName: "a bot",
|
||||
@@ -661,6 +725,9 @@ func TestDisableBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -683,6 +750,9 @@ func TestDisableBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -705,6 +775,9 @@ func TestDisableBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -730,7 +803,6 @@ func TestDisableBot(t *testing.T) {
|
||||
require.Equal(t, bot, enabledBot2)
|
||||
})
|
||||
}
|
||||
|
||||
func TestEnableBot(t *testing.T) {
|
||||
t.Run("enable non-existent bot", func(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
@@ -747,6 +819,9 @@ func TestEnableBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -772,6 +847,9 @@ func TestEnableBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -797,6 +875,9 @@ func TestEnableBot(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -840,6 +921,9 @@ func TestAssignBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_BOTS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -879,6 +963,9 @@ func TestAssignBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_BOTS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -907,6 +994,9 @@ func TestAssignBot(t *testing.T) {
|
||||
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_BOTS.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
|
||||
@@ -527,6 +527,10 @@ func TestGetBotUser(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.SYSTEM_USER_ROLE_ID+" "+model.TEAM_USER_ROLE_ID, false)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
bot := &model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
DisplayName: "a bot",
|
||||
@@ -2640,6 +2644,10 @@ func TestLogin(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
th.Client.Logout()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
t.Run("missing password", func(t *testing.T) {
|
||||
_, resp := th.Client.Login(th.BasicUser.Email, "")
|
||||
CheckErrorMessage(t, resp, "api.user.login.blank_pwd.app_error")
|
||||
@@ -2730,6 +2738,10 @@ func TestCBALogin(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
th.App.SetLicense(model.NewTestLicense("saml"))
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ExperimentalSettings.ClientSideCertEnable = true
|
||||
*cfg.ExperimentalSettings.ClientSideCertCheck = model.CLIENT_SIDE_CERT_CHECK_PRIMARY_AUTH
|
||||
@@ -2784,6 +2796,10 @@ func TestCBALogin(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
th.App.SetLicense(model.NewTestLicense("saml"))
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
th.Client.HttpHeader["X-SSL-Client-Cert"] = "valid_cert_fake"
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
@@ -3088,6 +3104,9 @@ func TestCreateUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_BOT.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3125,6 +3144,9 @@ func TestCreateUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_BOTS.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3223,6 +3245,9 @@ func TestGetUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3266,6 +3291,9 @@ func TestGetUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_READ_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3510,6 +3538,9 @@ func TestRevokeUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3550,6 +3581,9 @@ func TestRevokeUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3622,6 +3656,9 @@ func TestDisableUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3662,6 +3699,9 @@ func TestDisableUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3744,6 +3784,9 @@ func TestEnableUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.Client.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
@@ -3788,6 +3831,9 @@ func TestEnableUserAccessToken(t *testing.T) {
|
||||
th.AddPermissionToRole(model.PERMISSION_CREATE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.AddPermissionToRole(model.PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id, model.TEAM_USER_ROLE_ID)
|
||||
th.App.UpdateUserRoles(th.BasicUser.Id, model.TEAM_USER_ROLE_ID, false)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CreateBotAccounts = true
|
||||
})
|
||||
|
||||
createdBot, resp := th.SystemAdminClient.CreateBot(&model.Bot{
|
||||
Username: GenerateTestUsername(),
|
||||
|
||||
@@ -131,6 +131,10 @@
|
||||
"id": "api.admin.upload_brand_image.too_large.app_error",
|
||||
"translation": "Unable to upload file. File is too large."
|
||||
},
|
||||
{
|
||||
"id": "api.bot.create_disabled",
|
||||
"translation": "Bot creation has been disabled."
|
||||
},
|
||||
{
|
||||
"id": "api.channel.add_member.added",
|
||||
"translation": "%v added to the channel by %v."
|
||||
|
||||
@@ -293,6 +293,7 @@ type ServiceSettings struct {
|
||||
EnableEmailInvitations *bool
|
||||
ExperimentalLdapGroupSync *bool
|
||||
DisableBotsWhenOwnerIsDeactivated *bool `restricted:"true"`
|
||||
CreateBotAccounts *bool
|
||||
}
|
||||
|
||||
func (s *ServiceSettings) SetDefaults() {
|
||||
@@ -635,6 +636,10 @@ func (s *ServiceSettings) SetDefaults() {
|
||||
if s.DisableBotsWhenOwnerIsDeactivated == nil {
|
||||
s.DisableBotsWhenOwnerIsDeactivated = NewBool(true)
|
||||
}
|
||||
|
||||
if s.CreateBotAccounts == nil {
|
||||
s.CreateBotAccounts = NewBool(false)
|
||||
}
|
||||
}
|
||||
|
||||
type ClusterSettings struct {
|
||||
|
||||
Ссылка в новой задаче
Block a user