mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-2976 Adding checkout for missing SMTP server when testing email connection (#3115)
* PLT-2976 Adding checkout for missing SMTP server when testing email connection * Fixing unit test
This commit is contained in:
committed by
Joram Wilander
parent
7b2538fc6c
commit
56cca6be7c
@@ -184,6 +184,11 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(utils.Cfg.EmailSettings.SMTPServer) == 0 {
|
||||
c.Err = model.NewLocAppError("testEmail", "api.admin.test_email.missing_server", nil, utils.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}))
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
|
||||
@@ -138,8 +138,13 @@ func TestEmailTest(t *testing.T) {
|
||||
t.Fatal("Shouldn't have permissions")
|
||||
}
|
||||
|
||||
if _, err := th.SystemAdminClient.TestEmail(utils.Cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
if _, err := th.SystemAdminClient.TestEmail(utils.Cfg); err == nil {
|
||||
t.Fatal("should have errored")
|
||||
} else {
|
||||
println(err.Id)
|
||||
if err.Id != "api.admin.test_email.missing_server" {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,10 @@
|
||||
"id": "api.admin.test_email.subject",
|
||||
"translation": "Mattermost - Testing Email Settings"
|
||||
},
|
||||
{
|
||||
"id": "api.admin.test_email.missing_server",
|
||||
"translation": "SMTP Server is required"
|
||||
},
|
||||
{
|
||||
"id": "api.admin.upload_brand_image.array.app_error",
|
||||
"translation": "Empty array under 'image' in request"
|
||||
|
||||
Reference in New Issue
Block a user