mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-07-21 11:38:59 +02:00
🔧 Add support for logLevel in any case (#231)
This commit is contained in:
@@ -268,8 +268,8 @@ func ValidateParams(config *Config) error {
|
||||
}
|
||||
|
||||
// Check logging configuration
|
||||
|
||||
if !contains([]string{LogERROR, LogDEBUG, LogINFO}, config.LogLevel) {
|
||||
// to upper allow of anycase of log level
|
||||
if !contains([]string{LogERROR, LogDEBUG, LogINFO}, strings.ToUpper(config.LogLevel)) {
|
||||
return fmt.Errorf("LogLevel should be one of (%s,%s,%s)", LogDEBUG, LogINFO, LogERROR)
|
||||
}
|
||||
if config.LogFilePath != "" {
|
||||
|
||||
@@ -85,8 +85,14 @@ func Test_ValidateParams(t *testing.T) {
|
||||
cfg6 := getMinimalConfig()
|
||||
cfg6.CrowdsecLapiScheme = HTTPS
|
||||
cfg6.CrowdsecLapiTLSInsecureVerify = true
|
||||
cfg7 := getMinimalConfig()
|
||||
cfg7.CrowdsecLapiScheme = HTTPS
|
||||
cfg8 := getMinimalConfig()
|
||||
cfg8.CrowdsecLapiScheme = HTTPS
|
||||
cfg8.LogLevel = LogINFO
|
||||
cfg9 := getMinimalConfig()
|
||||
cfg9.LogLevel = "info"
|
||||
cfg10 := getMinimalConfig()
|
||||
cfg10.LogLevel = "Warning"
|
||||
type args struct {
|
||||
config *Config
|
||||
}
|
||||
@@ -104,7 +110,10 @@ func Test_ValidateParams(t *testing.T) {
|
||||
{name: "Not validate a bad clients ips", args: args{config: cfg5}, wantErr: true},
|
||||
// HTTPS enabled
|
||||
{name: "Validate https config with insecure verify", args: args{config: cfg6}, wantErr: false},
|
||||
{name: "Not validate https without cert authority", args: args{config: cfg8}, wantErr: true},
|
||||
{name: "Not validate https without cert authority", args: args{config: cfg7}, wantErr: true},
|
||||
{name: "Valid log level uppercase INFO", args: args{config: cfg8}, wantErr: false},
|
||||
{name: "Valid log level lowercase info", args: args{config: cfg9}, wantErr: false},
|
||||
{name: "Invalid log level Warning", args: args{config: cfg10}, wantErr: true},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user