diff --git a/app/bot_test.go b/app/bot_test.go index 2b35ff4a9f..b8a563047a 100644 --- a/app/bot_test.go +++ b/app/bot_test.go @@ -45,6 +45,20 @@ func TestCreateBot(t *testing.T) { require.NotNil(t, err) require.Equal(t, "model.bot.is_valid.description.app_error", err.Id) }) + + t.Run("username contains . character", func(t *testing.T) { + th := Setup(t).InitBasic() + defer th.TearDown() + + bot, err := th.App.CreateBot(&model.Bot{ + Username: "username.", + Description: "a bot", + OwnerId: th.BasicUser.Id, + }) + require.NotNil(t, err) + require.Nil(t, bot) + require.Equal(t, "model.user.is_valid.email.app_error", err.Id) + }) }) t.Run("create bot", func(t *testing.T) { diff --git a/model/bot.go b/model/bot.go index 079e1b157b..18d64fec53 100644 --- a/model/bot.go +++ b/model/bot.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "net/http" - "strings" "unicode/utf8" ) @@ -167,7 +166,7 @@ func UserFromBot(b *Bot) *User { return &User{ Id: b.UserId, Username: b.Username, - Email: fmt.Sprintf("%s@localhost", strings.ToLower(b.Username)), + Email: NormalizeEmail(fmt.Sprintf("%s@localhost", b.Username)), FirstName: b.DisplayName, Roles: SYSTEM_USER_ROLE_ID, }