1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-12-01 22:51:45 +02:00

Add tests for SecretSource validation

This commit is contained in:
Joel Speed
2020-10-24 07:17:01 +01:00
parent 8059a812cd
commit 1dac1419b3
2 changed files with 141 additions and 1 deletions

View File

@@ -8,6 +8,8 @@ import (
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
)
const multipleValuesForSecretSource = "multiple values specified for secret source: specify either value, fromEnv of fromFile"
func validateSecretSource(source options.SecretSource) string {
switch {
case len(source.Value) > 0 && source.FromEnv == "" && source.FromFile == "":
@@ -17,7 +19,7 @@ func validateSecretSource(source options.SecretSource) string {
case len(source.Value) == 0 && source.FromEnv == "" && source.FromFile != "":
return validateSecretSourceFile(source.FromFile)
default:
return "multiple values specified for secret source: specify either value, fromEnv of fromFile"
return multipleValuesForSecretSource
}
}