From 38958d9ac4f415d9ae99dfcdb53bfdc355d96764 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Mon, 13 Mar 2017 16:09:00 +0100 Subject: Add implementation for POST /email/test apiV4 - Send Test Email (#5716) --- api4/system_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'api4/system_test.go') diff --git a/api4/system_test.go b/api4/system_test.go index 2e8b8f70f..ae133183b 100644 --- a/api4/system_test.go +++ b/api4/system_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" ) func TestGetPing(t *testing.T) { @@ -64,3 +65,32 @@ func TestGetConfig(t *testing.T) { t.Fatal("did not sanitize properly") } } + +func TestEmailTest(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + + SendEmailNotifications := utils.Cfg.EmailSettings.SendEmailNotifications + SMTPServer := utils.Cfg.EmailSettings.SMTPServer + SMTPPort := utils.Cfg.EmailSettings.SMTPPort + FeedbackEmail := utils.Cfg.EmailSettings.FeedbackEmail + defer func() { + utils.Cfg.EmailSettings.SendEmailNotifications = SendEmailNotifications + utils.Cfg.EmailSettings.SMTPServer = SMTPServer + utils.Cfg.EmailSettings.SMTPPort = SMTPPort + utils.Cfg.EmailSettings.FeedbackEmail = FeedbackEmail + }() + + utils.Cfg.EmailSettings.SendEmailNotifications = false + utils.Cfg.EmailSettings.SMTPServer = "" + utils.Cfg.EmailSettings.SMTPPort = "" + utils.Cfg.EmailSettings.FeedbackEmail = "" + + _, resp := Client.TestEmail() + CheckForbiddenStatus(t, resp) + + _, resp = th.SystemAdminClient.TestEmail() + CheckErrorMessage(t, resp, "api.admin.test_email.missing_server") + CheckInternalErrorStatus(t, resp) +} -- cgit v1.2.3-1-g7c22