servewaf's and rproxy's settings are read through viper, bound to the same environment variable names as before, in place of the os.LookupEnv function Main passed down. NewViper turns AutomaticEnv and AllowEmptyEnv on, so a setting that is set but empty reads as set, as it did. The _FILE forms, their errors, and rproxy reading no file form are unchanged, and the settings tests pass set into a viper instead of a lookup function. Model: deepseek-v4-pro
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"sneak.berlin/go/smallwebwaf/internal/config"
|
||||
)
|
||||
|
||||
@@ -32,11 +34,12 @@ const (
|
||||
|
||||
// rproxyConfig reads rproxy's settings from env.
|
||||
func rproxyConfig(env map[string]string) (*config.RProxy, error) {
|
||||
return config.RProxyFromEnvironment(func(name string) (string, bool) {
|
||||
value, ok := env[name]
|
||||
v := viper.New()
|
||||
for name, value := range env {
|
||||
v.Set(name, value)
|
||||
}
|
||||
|
||||
return value, ok
|
||||
})
|
||||
return config.RProxyFromEnvironment(v)
|
||||
}
|
||||
|
||||
func TestRProxyDefaults(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user