MM-10658 Change config fields to pointers (#9033)
* MM 10658 Change config fields to pointers (#8898) * Change fields of config structs to pointers and set defaults MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix tests that go broken during switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Apply changes of current master while switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix new config pointer uses * Fix app tests * Fix mail test * remove debugging statement * fix TestUpdateConfig * assign config consistently * initialize AmazonS3Region in TestS3TestConnection * initialize fields for TestEmailTest * fix TestCheckMandatoryS3Fields
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0c981aa010
Коммит
2ca222033c
@@ -119,11 +119,11 @@ func ConnectToSMTPServerAdvanced(connectionInfo *SmtpConnectionInfo) (net.Conn,
|
||||
func ConnectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) {
|
||||
return ConnectToSMTPServerAdvanced(
|
||||
&SmtpConnectionInfo{
|
||||
ConnectionSecurity: config.EmailSettings.ConnectionSecurity,
|
||||
ConnectionSecurity: *config.EmailSettings.ConnectionSecurity,
|
||||
SkipCertVerification: *config.EmailSettings.SkipServerCertificateVerification,
|
||||
SmtpServerName: config.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: config.EmailSettings.SMTPServer,
|
||||
SmtpPort: config.EmailSettings.SMTPPort,
|
||||
SmtpServerName: *config.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: *config.EmailSettings.SMTPServer,
|
||||
SmtpPort: *config.EmailSettings.SMTPPort,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -164,20 +164,20 @@ func NewSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
|
||||
conn,
|
||||
utils.GetHostnameFromSiteURL(*config.ServiceSettings.SiteURL),
|
||||
&SmtpConnectionInfo{
|
||||
ConnectionSecurity: config.EmailSettings.ConnectionSecurity,
|
||||
ConnectionSecurity: *config.EmailSettings.ConnectionSecurity,
|
||||
SkipCertVerification: *config.EmailSettings.SkipServerCertificateVerification,
|
||||
SmtpServerName: config.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: config.EmailSettings.SMTPServer,
|
||||
SmtpPort: config.EmailSettings.SMTPPort,
|
||||
SmtpServerName: *config.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: *config.EmailSettings.SMTPServer,
|
||||
SmtpPort: *config.EmailSettings.SMTPPort,
|
||||
Auth: *config.EmailSettings.EnableSMTPAuth,
|
||||
SmtpUsername: config.EmailSettings.SMTPUsername,
|
||||
SmtpPassword: config.EmailSettings.SMTPPassword,
|
||||
SmtpUsername: *config.EmailSettings.SMTPUsername,
|
||||
SmtpPassword: *config.EmailSettings.SMTPPassword,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func TestConnection(config *model.Config) {
|
||||
if !config.EmailSettings.SendEmailNotifications {
|
||||
if !*config.EmailSettings.SendEmailNotifications {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -198,14 +198,14 @@ func TestConnection(config *model.Config) {
|
||||
}
|
||||
|
||||
func SendMailUsingConfig(to, subject, htmlBody string, config *model.Config, enableComplianceFeatures bool) *model.AppError {
|
||||
fromMail := mail.Address{Name: config.EmailSettings.FeedbackName, Address: config.EmailSettings.FeedbackEmail}
|
||||
fromMail := mail.Address{Name: *config.EmailSettings.FeedbackName, Address: *config.EmailSettings.FeedbackEmail}
|
||||
|
||||
return SendMailUsingConfigAdvanced(to, to, fromMail, subject, htmlBody, nil, nil, config, enableComplianceFeatures)
|
||||
}
|
||||
|
||||
// allows for sending an email with attachments and differing MIME/SMTP recipients
|
||||
func SendMailUsingConfigAdvanced(mimeTo, smtpTo string, from mail.Address, subject, htmlBody string, attachments []*model.FileInfo, mimeHeaders map[string]string, config *model.Config, enableComplianceFeatures bool) *model.AppError {
|
||||
if !config.EmailSettings.SendEmailNotifications || len(config.EmailSettings.SMTPServer) == 0 {
|
||||
if !*config.EmailSettings.SendEmailNotifications || len(*config.EmailSettings.SMTPServer) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ func TestMailConnectionFromConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
cfg.EmailSettings.SMTPServer = "wrongServer"
|
||||
cfg.EmailSettings.SMTPPort = "553"
|
||||
*cfg.EmailSettings.SMTPServer = "wrongServer"
|
||||
*cfg.EmailSettings.SMTPPort = "553"
|
||||
|
||||
if _, err := ConnectToSMTPServer(cfg); err == nil {
|
||||
t.Log(err)
|
||||
@@ -48,11 +48,11 @@ func TestMailConnectionAdvanced(t *testing.T) {
|
||||
|
||||
if conn, err := ConnectToSMTPServerAdvanced(
|
||||
&SmtpConnectionInfo{
|
||||
ConnectionSecurity: cfg.EmailSettings.ConnectionSecurity,
|
||||
ConnectionSecurity: *cfg.EmailSettings.ConnectionSecurity,
|
||||
SkipCertVerification: *cfg.EmailSettings.SkipServerCertificateVerification,
|
||||
SmtpServerName: cfg.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: cfg.EmailSettings.SMTPServer,
|
||||
SmtpPort: cfg.EmailSettings.SMTPPort,
|
||||
SmtpServerName: *cfg.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: *cfg.EmailSettings.SMTPServer,
|
||||
SmtpPort: *cfg.EmailSettings.SMTPPort,
|
||||
},
|
||||
); err != nil {
|
||||
t.Log(err)
|
||||
@@ -62,14 +62,14 @@ func TestMailConnectionAdvanced(t *testing.T) {
|
||||
conn,
|
||||
utils.GetHostnameFromSiteURL(*cfg.ServiceSettings.SiteURL),
|
||||
&SmtpConnectionInfo{
|
||||
ConnectionSecurity: cfg.EmailSettings.ConnectionSecurity,
|
||||
ConnectionSecurity: *cfg.EmailSettings.ConnectionSecurity,
|
||||
SkipCertVerification: *cfg.EmailSettings.SkipServerCertificateVerification,
|
||||
SmtpServerName: cfg.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: cfg.EmailSettings.SMTPServer,
|
||||
SmtpPort: cfg.EmailSettings.SMTPPort,
|
||||
SmtpServerName: *cfg.EmailSettings.SMTPServer,
|
||||
SmtpServerHost: *cfg.EmailSettings.SMTPServer,
|
||||
SmtpPort: *cfg.EmailSettings.SMTPPort,
|
||||
Auth: *cfg.EmailSettings.EnableSMTPAuth,
|
||||
SmtpUsername: cfg.EmailSettings.SMTPUsername,
|
||||
SmtpPassword: cfg.EmailSettings.SMTPPassword,
|
||||
SmtpUsername: *cfg.EmailSettings.SMTPUsername,
|
||||
SmtpPassword: *cfg.EmailSettings.SMTPPassword,
|
||||
},
|
||||
); err1 != nil {
|
||||
t.Log(err)
|
||||
@@ -79,7 +79,7 @@ func TestMailConnectionAdvanced(t *testing.T) {
|
||||
|
||||
if _, err := ConnectToSMTPServerAdvanced(
|
||||
&SmtpConnectionInfo{
|
||||
ConnectionSecurity: cfg.EmailSettings.ConnectionSecurity,
|
||||
ConnectionSecurity: *cfg.EmailSettings.ConnectionSecurity,
|
||||
SkipCertVerification: *cfg.EmailSettings.SkipServerCertificateVerification,
|
||||
SmtpServerName: "wrongServer",
|
||||
SmtpServerHost: "wrongServer",
|
||||
|
||||
Ссылка в новой задаче
Block a user