[MM-41668] Remove "add support email" admin advisor notifications (#19567)
Automatic Merge
Этот коммит содержится в:
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/app/users"
|
||||
"github.com/mattermost/mattermost-server/v6/config"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/filestore"
|
||||
@@ -706,91 +705,3 @@ func TestSentry(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestAdminAdvisor(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
// creating a system user to whole admin advisor will send post
|
||||
user := model.User{
|
||||
Email: strings.ToLower(model.NewId()) + "success+test@example.com",
|
||||
Nickname: "Darth Vader",
|
||||
Username: "vader" + model.NewId(),
|
||||
Password: "passwd1",
|
||||
AuthService: "",
|
||||
Roles: model.SystemAdminRoleId,
|
||||
}
|
||||
ruser, err := th.App.CreateUser(th.Context, &user)
|
||||
assert.Nil(t, err, "User should be created")
|
||||
defer th.App.PermanentDeleteUser(th.Context, &user)
|
||||
|
||||
t.Run("Should notify admin of un-configured support email", func(t *testing.T) {
|
||||
doCheckAdminSupportStatus(th.App, th.Context)
|
||||
|
||||
bot, err := th.App.GetUserByUsername(model.BotWarnMetricBotUsername)
|
||||
assert.NotNil(t, bot, "Bot should have been created now")
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
|
||||
channel, err := th.App.getDirectChannel(bot.Id, ruser.Id)
|
||||
assert.NotNil(t, channel, "DM channel should exist between Admin Advisor and system admin")
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
})
|
||||
|
||||
t.Run("Should NOT notify admin when support email is configured", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(m *model.Config) {
|
||||
email := "success+test@example.com"
|
||||
m.SupportSettings.SupportEmail = &email
|
||||
})
|
||||
|
||||
bot, err := th.App.GetUserByUsername(model.BotWarnMetricBotUsername)
|
||||
assert.NotNil(t, bot, "Bot should be already created")
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
|
||||
channel, err := th.App.getDirectChannel(bot.Id, ruser.Id)
|
||||
assert.NotNil(t, channel, "DM channel should already exist")
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
|
||||
err = th.App.PermanentDeleteChannel(channel)
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
|
||||
doCheckAdminSupportStatus(th.App, th.Context)
|
||||
|
||||
channel, err = th.App.getDirectChannel(bot.Id, ruser.Id)
|
||||
assert.NotNil(t, channel, "DM channel should exist between Admin Advisor and system admin")
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
|
||||
posts, err := th.App.GetPosts(channel.Id, 0, 100)
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
assert.Equal(t, 0, len(posts.Posts))
|
||||
})
|
||||
|
||||
t.Run("Should not break in case of many sysadmins", func(t *testing.T) {
|
||||
var userList []*model.User
|
||||
for i := 0; i < 50; i++ {
|
||||
user := model.User{
|
||||
Email: strings.ToLower(NewTestId()) + "success+test@example.com",
|
||||
Nickname: "Admin",
|
||||
Username: "admin" + NewTestId(),
|
||||
Password: "password",
|
||||
AuthService: "",
|
||||
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId,
|
||||
}
|
||||
ruser, err := th.App.ch.srv.userService.CreateUser(&user, users.UserCreateOptions{FromImport: true})
|
||||
assert.NoError(t, err, "User should be created")
|
||||
userList = append(userList, ruser)
|
||||
defer th.App.PermanentDeleteUser(th.Context, ruser)
|
||||
}
|
||||
|
||||
th.App.notifyAdminsOfWarnMetricStatus(th.Context, model.SystemMetricSupportEmailNotConfigured, true)
|
||||
|
||||
bot, err := th.App.GetUserByUsername(model.BotWarnMetricBotUsername)
|
||||
assert.NotNil(t, bot, "Bot should have been created now")
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
|
||||
for _, user := range userList {
|
||||
channel, err := th.App.getDirectChannel(bot.Id, user.Id)
|
||||
assert.NotNil(t, channel, "DM channel should exist between Admin Advisor and system admin")
|
||||
assert.Nil(t, err, "No error should be generated")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user