mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +03:00
add SMTP support
it will be used in future update to add email sending capabilities
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/drakkan/sftpgo/v2/kms"
|
||||
"github.com/drakkan/sftpgo/v2/mfa"
|
||||
"github.com/drakkan/sftpgo/v2/sftpd"
|
||||
"github.com/drakkan/sftpgo/v2/smtp"
|
||||
"github.com/drakkan/sftpgo/v2/util"
|
||||
)
|
||||
|
||||
@@ -42,6 +43,7 @@ func TestLoadConfigTest(t *testing.T) {
|
||||
assert.NotEqual(t, dataprovider.Config{}, config.GetProviderConf())
|
||||
assert.NotEqual(t, sftpd.Configuration{}, config.GetSFTPDConfig())
|
||||
assert.NotEqual(t, httpclient.Config{}, config.GetHTTPConfig())
|
||||
assert.NotEqual(t, smtp.Config{}, config.GetSMTPConfig())
|
||||
confName := tempConfigName + ".json"
|
||||
configFilePath := filepath.Join(configDir, confName)
|
||||
err = config.LoadConfig(configDir, confName)
|
||||
@@ -340,6 +342,24 @@ func TestSSHCommandsFromEnv(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSMTPFromEnv(t *testing.T) {
|
||||
reset()
|
||||
|
||||
os.Setenv("SFTPGO_SMTP__HOST", "smtp.example.com")
|
||||
os.Setenv("SFTPGO_SMTP__PORT", "587")
|
||||
t.Cleanup(func() {
|
||||
os.Unsetenv("SFTPGO_SMTP__HOST")
|
||||
os.Unsetenv("SFTPGO_SMTP__PORT")
|
||||
})
|
||||
|
||||
configDir := ".."
|
||||
err := config.LoadConfig(configDir, "")
|
||||
assert.NoError(t, err)
|
||||
smtpConfig := config.GetSMTPConfig()
|
||||
assert.Equal(t, "smtp.example.com", smtpConfig.Host)
|
||||
assert.Equal(t, 587, smtpConfig.Port)
|
||||
}
|
||||
|
||||
func TestMFAFromEnv(t *testing.T) {
|
||||
reset()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user