mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
document the new banner configuration
use SFTPGo as default banner and ensure that the banner is not empty
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package config_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drakkan/sftpgo/api"
|
||||
@@ -45,3 +47,25 @@ func TestLoadConfigTest(t *testing.T) {
|
||||
}
|
||||
os.Remove(configFilePath)
|
||||
}
|
||||
|
||||
func TestEmptyBanner(t *testing.T) {
|
||||
configDir := ".."
|
||||
confName := "temp.conf"
|
||||
configFilePath := filepath.Join(configDir, confName)
|
||||
config.LoadConfig(configFilePath)
|
||||
sftpdConf := config.GetSFTPDConfig()
|
||||
sftpdConf.Banner = " "
|
||||
c := make(map[string]sftpd.Configuration)
|
||||
c["sftpd"] = sftpdConf
|
||||
jsonConf, _ := json.Marshal(c)
|
||||
err := ioutil.WriteFile(configFilePath, jsonConf, 0666)
|
||||
if err != nil {
|
||||
t.Errorf("error saving temporary configuration")
|
||||
}
|
||||
config.LoadConfig(configFilePath)
|
||||
sftpdConf = config.GetSFTPDConfig()
|
||||
if strings.TrimSpace(sftpdConf.Banner) == "" {
|
||||
t.Errorf("SFTPD banner cannot be empty")
|
||||
}
|
||||
os.Remove(configFilePath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user