MCPcopy
hub / github.com/mattermost/mattermost / TestUpdateActiveBotsSideEffect

Function TestUpdateActiveBotsSideEffect

server/channels/app/user_test.go:429–479  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

427}
428
429func TestUpdateActiveBotsSideEffect(t *testing.T) {
430 mainHelper.Parallel(t)
431 th := Setup(t).InitBasic(t)
432
433 bot, err := th.App.CreateBot(th.Context, &model.Bot{
434 Username: "username",
435 Description: "a bot",
436 OwnerId: th.BasicUser.Id,
437 })
438 require.Nil(t, err)
439 defer func() {
440 appErr := th.App.PermanentDeleteBot(th.Context, bot.UserId)
441 require.Nil(t, appErr)
442 }()
443
444 // Automatic deactivation disabled
445 th.App.UpdateConfig(func(cfg *model.Config) {
446 *cfg.ServiceSettings.DisableBotsWhenOwnerIsDeactivated = false
447 })
448
449 _, appErr := th.App.UpdateActive(th.Context, th.BasicUser, false)
450 require.Nil(t, appErr)
451
452 retbot1, err := th.App.GetBot(th.Context, bot.UserId, true)
453 require.Nil(t, err)
454 require.Zero(t, retbot1.DeleteAt)
455 user1, err := th.App.GetUser(bot.UserId)
456 require.Nil(t, err)
457 require.Zero(t, user1.DeleteAt)
458
459 _, appErr = th.App.UpdateActive(th.Context, th.BasicUser, true)
460 require.Nil(t, appErr)
461
462 // Automatic deactivation enabled
463 th.App.UpdateConfig(func(cfg *model.Config) {
464 *cfg.ServiceSettings.DisableBotsWhenOwnerIsDeactivated = true
465 })
466
467 _, appErr = th.App.UpdateActive(th.Context, th.BasicUser, false)
468 require.Nil(t, appErr)
469
470 retbot2, err := th.App.GetBot(th.Context, bot.UserId, true)
471 require.Nil(t, err)
472 require.NotZero(t, retbot2.DeleteAt)
473 user2, err := th.App.GetUser(bot.UserId)
474 require.Nil(t, err)
475 require.NotZero(t, user2.DeleteAt)
476
477 _, appErr = th.App.UpdateActive(th.Context, th.BasicUser, true)
478 require.Nil(t, appErr)
479}
480
481func TestUserDeactivationRevokesOAuthAccessTokens(t *testing.T) {
482 mainHelper.Parallel(t)

Callers

nothing calls this directly

Calls 9

SetupFunction · 0.70
CreateBotMethod · 0.65
PermanentDeleteBotMethod · 0.65
UpdateConfigMethod · 0.65
GetBotMethod · 0.65
GetUserMethod · 0.65
ParallelMethod · 0.45
InitBasicMethod · 0.45
UpdateActiveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…