mirror of
https://github.com/navidrome/navidrome.git
synced 2025-12-23 15:08:04 -05:00
* Rename external auth options ReverseProxyWhitelist was regularly confusing users that enabled it for non-authenticating reverse proxy setups. The new option name makes it clear that it's related to authentication, not just reverse proxies. * small refactor Signed-off-by: Deluan <deluan@navidrome.org> * add test Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org> Co-authored-by: Deluan Quintão <deluan@navidrome.org>
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package conf_test
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/navidrome/navidrome/conf"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func TestConfiguration(t *testing.T) {
|
|
RegisterFailHandler(Fail)
|
|
RunSpecs(t, "Configuration Suite")
|
|
}
|
|
|
|
var _ = Describe("Configuration", func() {
|
|
BeforeEach(func() {
|
|
// Reset viper configuration
|
|
viper.Reset()
|
|
conf.SetViperDefaults()
|
|
viper.SetDefault("datafolder", GinkgoT().TempDir())
|
|
viper.SetDefault("loglevel", "error")
|
|
conf.ResetConf()
|
|
})
|
|
|
|
DescribeTable("should load configuration from",
|
|
func(format string) {
|
|
filename := filepath.Join("testdata", "cfg."+format)
|
|
|
|
// Initialize config with the test file
|
|
conf.InitConfig(filename, false)
|
|
// Load the configuration (with noConfigDump=true)
|
|
conf.Load(true)
|
|
|
|
// Execute the format-specific assertions
|
|
Expect(conf.Server.MusicFolder).To(Equal(fmt.Sprintf("/%s/music", format)))
|
|
Expect(conf.Server.UIWelcomeMessage).To(Equal("Welcome " + format))
|
|
Expect(conf.Server.Tags["custom"].Aliases).To(Equal([]string{format, "test"}))
|
|
Expect(conf.Server.Tags["artist"].Split).To(Equal([]string{";"}))
|
|
|
|
// Check deprecated option mapping
|
|
Expect(conf.Server.ExtAuth.UserHeader).To(Equal("X-Auth-User"))
|
|
|
|
// The config file used should be the one we created
|
|
Expect(conf.Server.ConfigFile).To(Equal(filename))
|
|
},
|
|
Entry("TOML format", "toml"),
|
|
Entry("YAML format", "yaml"),
|
|
Entry("INI format", "ini"),
|
|
Entry("JSON format", "json"),
|
|
)
|
|
})
|