mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
VAULT-18160: Audit - options and defaults (#22295)
* options for syslog * fix bug in default value for HMACAccessor * backend device cleanup * socket backend options update * options: prefix removed check, added default file mode * fix option setting for elision * fix test for prefix and whitespace
This commit is contained in:
@@ -32,12 +32,15 @@ type options struct {
|
||||
|
||||
// getDefaultOptions returns Options with their default values.
|
||||
func getDefaultOptions() options {
|
||||
fileMode := os.FileMode(0o600)
|
||||
|
||||
return options{
|
||||
withNow: time.Now(),
|
||||
withFacility: "AUTH",
|
||||
withTag: "vault",
|
||||
withSocketType: "tcp",
|
||||
withMaxDuration: 2 * time.Second,
|
||||
withFileMode: &fileMode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +113,7 @@ func WithNow(now time.Time) Option {
|
||||
// WithFacility provides an Option to represent a 'facility' for a syslog sink.
|
||||
func WithFacility(facility string) Option {
|
||||
return func(o *options) error {
|
||||
facility = strings.TrimSpace(facility)
|
||||
|
||||
if facility != "" {
|
||||
o.withFacility = facility
|
||||
}
|
||||
o.withFacility = facility
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -123,11 +122,7 @@ func WithFacility(facility string) Option {
|
||||
// WithTag provides an Option to represent a 'tag' for a syslog sink.
|
||||
func WithTag(tag string) Option {
|
||||
return func(o *options) error {
|
||||
tag = strings.TrimSpace(tag)
|
||||
|
||||
if tag != "" {
|
||||
o.withTag = tag
|
||||
}
|
||||
o.withTag = tag
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ func TestOptions_WithFacility(t *testing.T) {
|
||||
},
|
||||
"whitespace": {
|
||||
Value: " ",
|
||||
ExpectedValue: "",
|
||||
ExpectedValue: " ",
|
||||
},
|
||||
"value": {
|
||||
Value: "juan",
|
||||
@@ -213,7 +213,7 @@ func TestOptions_WithFacility(t *testing.T) {
|
||||
},
|
||||
"spacey-value": {
|
||||
Value: " juan ",
|
||||
ExpectedValue: "juan",
|
||||
ExpectedValue: " juan ",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ func TestOptions_WithTag(t *testing.T) {
|
||||
},
|
||||
"whitespace": {
|
||||
Value: " ",
|
||||
ExpectedValue: "",
|
||||
ExpectedValue: " ",
|
||||
},
|
||||
"value": {
|
||||
Value: "juan",
|
||||
@@ -251,7 +251,7 @@ func TestOptions_WithTag(t *testing.T) {
|
||||
},
|
||||
"spacey-value": {
|
||||
Value: " juan ",
|
||||
ExpectedValue: "juan",
|
||||
ExpectedValue: " juan ",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user