chore: move CAOS_OIDC_DEV to const (and ensure TestValidateIssuer runs (even on machines with env set))
This commit is contained in:
parent
b311610d06
commit
d6203fb0d5
2 changed files with 6 additions and 2 deletions
|
@ -7,6 +7,8 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const OidcDevMode = "CAOS_OIDC_DEV"
|
||||
|
||||
type Configuration interface {
|
||||
Issuer() string
|
||||
AuthorizationEndpoint() Endpoint
|
||||
|
@ -42,7 +44,7 @@ func ValidateIssuer(issuer string) error {
|
|||
}
|
||||
|
||||
func devLocalAllowed(url *url.URL) bool {
|
||||
_, b := os.LookupEnv("CAOS_OIDC_DEV")
|
||||
_, b := os.LookupEnv(OidcDevMode)
|
||||
if !b {
|
||||
return b
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ func TestValidateIssuer(t *testing.T) {
|
|||
true,
|
||||
},
|
||||
}
|
||||
//ensure env is not set
|
||||
os.Unsetenv(OidcDevMode)
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := ValidateIssuer(tt.args.issuer); (err != nil) != tt.wantErr {
|
||||
|
@ -84,7 +86,7 @@ func TestValidateIssuerDevLocalAllowed(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
}
|
||||
os.Setenv("CAOS_OIDC_DEV", "")
|
||||
os.Setenv(OidcDevMode, "true")
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := ValidateIssuer(tt.args.issuer); (err != nil) != tt.wantErr {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue