mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
df016be29e
* fix(notification): incorrect date header format The date header in the email envelopes was incorrectly formatted missing a space between the `Date:` header and the value of this header. This also refactors the notification templates system allowing people to manually override the envelope itself. * test: fix tests and linting issues * fix: misc issues * refactor: misc refactoring * docs: add example for envelope with message id * refactor: organize smtp notifier * refactor: move subject interpolation * refactor: include additional placeholders * docs: fix missing link * docs: gravity * fix: rcpt to command * refactor: remove mid * refactor: apply suggestions Co-authored-by: Amir Zarrinkafsh <nightah@me.com> * refactor: include pid Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package notification
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
"github.com/authelia/authelia/v4/internal/templates"
|
|
)
|
|
|
|
func TestShouldConfigureSMTPNotifierWithTLS11(t *testing.T) {
|
|
config := &schema.NotifierConfiguration{
|
|
DisableStartupCheck: true,
|
|
SMTP: &schema.SMTPNotifierConfiguration{
|
|
Host: "smtp.example.com",
|
|
Port: 25,
|
|
TLS: &schema.TLSConfig{
|
|
ServerName: "smtp.example.com",
|
|
MinimumVersion: "TLS1.1",
|
|
},
|
|
},
|
|
}
|
|
|
|
notifier := NewSMTPNotifier(config.SMTP, nil, &templates.Provider{})
|
|
|
|
assert.Equal(t, "smtp.example.com", notifier.tlsConfig.ServerName)
|
|
assert.Equal(t, uint16(tls.VersionTLS11), notifier.tlsConfig.MinVersion)
|
|
assert.False(t, notifier.tlsConfig.InsecureSkipVerify)
|
|
}
|
|
|
|
func TestShouldConfigureSMTPNotifierWithServerNameOverrideAndDefaultTLS12(t *testing.T) {
|
|
config := &schema.NotifierConfiguration{
|
|
DisableStartupCheck: true,
|
|
SMTP: &schema.SMTPNotifierConfiguration{
|
|
Host: "smtp.example.com",
|
|
Port: 25,
|
|
TLS: &schema.TLSConfig{
|
|
ServerName: "smtp.golang.org",
|
|
},
|
|
},
|
|
}
|
|
|
|
notifier := NewSMTPNotifier(config.SMTP, nil, &templates.Provider{})
|
|
|
|
assert.Equal(t, "smtp.golang.org", notifier.tlsConfig.ServerName)
|
|
assert.Equal(t, uint16(tls.VersionTLS12), notifier.tlsConfig.MinVersion)
|
|
assert.False(t, notifier.tlsConfig.InsecureSkipVerify)
|
|
}
|