Fixed issue where some values may not be getting assigned or validated if a config file was not being used.

This commit is contained in:
Jeromy Streets 2021-12-03 10:20:31 -08:00
parent 81e8ebadd3
commit 562f95e8ea
2 changed files with 16 additions and 1 deletions

View File

@ -83,7 +83,7 @@ func Load(filename string) (err error) {
// If no filename provided, assign envvars. // If no filename provided, assign envvars.
if filename == "" { if filename == "" {
overrideWithEnvVars() overrideWithEnvVars()
return return validate()
} }
// Read contents from configuration file. // Read contents from configuration file.
@ -161,6 +161,19 @@ func validate() error {
return err return err
} }
} }
// For logging minimum TLS version being used while debugging, backfill
// the TLSMinVersStr field.
switch Get.TLSMinVers {
case tls.VersionTLS10:
Get.TLSMinVersStr = "TLS1.0"
case tls.VersionTLS11:
Get.TLSMinVersStr = "TLS1.1"
case tls.VersionTLS12:
Get.TLSMinVersStr = "TLS1.2"
case tls.VersionTLS13:
Get.TLSMinVersStr = "TLS1.3"
}
} else { } else {
if 0 < len(Get.TLSMinVersStr) { if 0 < len(Get.TLSMinVersStr) {
msg := "value for 'TLS_MIN_VERS' is set but 'TLS_CERT' and 'TLS_KEY' are not" msg := "value for 'TLS_MIN_VERS' is set but 'TLS_CERT' and 'TLS_KEY' are not"

View File

@ -178,6 +178,8 @@ func TestValidate(t *testing.T) {
{"Prefix missing leading /", empty, empty, "my/prefix", "", true}, {"Prefix missing leading /", empty, empty, "my/prefix", "", true},
{"Prefix with trailing /", empty, empty, "/my/prefix/", "", true}, {"Prefix with trailing /", empty, empty, "/my/prefix/", "", true},
{"Valid paths w/min ok TLS", validPath, validPath, prefix, "tls11", false}, {"Valid paths w/min ok TLS", validPath, validPath, prefix, "tls11", false},
{"Valid paths w/min ok TLS", validPath, validPath, prefix, "tls12", false},
{"Valid paths w/min ok TLS", validPath, validPath, prefix, "tls13", false},
{"Valid paths w/min bad TLS", validPath, validPath, prefix, "bad", true}, {"Valid paths w/min bad TLS", validPath, validPath, prefix, "bad", true},
{"Empty paths w/min ok TLS", empty, empty, prefix, "tls11", true}, {"Empty paths w/min ok TLS", empty, empty, prefix, "tls11", true},
{"Empty paths w/min bad TLS", empty, empty, prefix, "bad", true}, {"Empty paths w/min bad TLS", empty, empty, prefix, "bad", true},