feat(config): app-config registry, env-var renames, wire session.duration from DB
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,6 @@ package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func setRequiredEnv(t *testing.T) {
|
||||
@@ -30,9 +29,6 @@ func TestLoad_DerivesOIDCSettingsFromBackendURL(t *testing.T) {
|
||||
if cfg.OIDCRequiredRole != "geniusrun-user" {
|
||||
t.Errorf("OIDCRequiredRole = %q, want default", cfg.OIDCRequiredRole)
|
||||
}
|
||||
if cfg.SessionDuration != 720*time.Hour {
|
||||
t.Errorf("SessionDuration = %v, want default 720h", cfg.SessionDuration)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoad_HTTPBaseURLYieldsInsecureCookies(t *testing.T) {
|
||||
@@ -80,7 +76,7 @@ func TestLoad_SessionSecretTooShort(t *testing.T) {
|
||||
|
||||
func TestLoad_GarminTokenStoreRootDefaultsIndependentlyOfDBPath(t *testing.T) {
|
||||
setRequiredEnv(t)
|
||||
t.Setenv("GARMIN_TOKENSTORE", "")
|
||||
t.Setenv("GENIUSRUN_TOKENSTORE_PATH", "")
|
||||
t.Setenv("GENIUSRUN_DB_PATH", "/var/lib/geniusrun/geniusrun.db")
|
||||
|
||||
cfg, err := Load()
|
||||
@@ -94,7 +90,7 @@ func TestLoad_GarminTokenStoreRootDefaultsIndependentlyOfDBPath(t *testing.T) {
|
||||
|
||||
func TestLoad_GarminTokenStoreRootExplicitOverridesDefault(t *testing.T) {
|
||||
setRequiredEnv(t)
|
||||
t.Setenv("GARMIN_TOKENSTORE", "/custom/tokenstores")
|
||||
t.Setenv("GENIUSRUN_TOKENSTORE_PATH", "/custom/tokenstores")
|
||||
t.Setenv("GENIUSRUN_DB_PATH", "/var/lib/geniusrun/geniusrun.db")
|
||||
|
||||
cfg, err := Load()
|
||||
@@ -134,7 +130,7 @@ func TestLoad_LogLevelExplicitOverridesDefault(t *testing.T) {
|
||||
|
||||
func TestLoad_GarminPythonPathDefaultsToPython3(t *testing.T) {
|
||||
setRequiredEnv(t)
|
||||
t.Setenv("GARMIN_WRAPPER_PYTHON", "")
|
||||
t.Setenv("GENIUSRUN_PYTHON_PATH", "")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
@@ -147,7 +143,7 @@ func TestLoad_GarminPythonPathDefaultsToPython3(t *testing.T) {
|
||||
|
||||
func TestLoad_GarminPythonPathExplicitOverridesDefault(t *testing.T) {
|
||||
setRequiredEnv(t)
|
||||
t.Setenv("GARMIN_WRAPPER_PYTHON", "/opt/venv/bin/python3")
|
||||
t.Setenv("GENIUSRUN_PYTHON_PATH", "/opt/venv/bin/python3")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
@@ -184,10 +180,9 @@ func TestLoad_FrontendURLExplicitOverridesDefault(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoad_CustomRoleAndDuration(t *testing.T) {
|
||||
func TestLoad_CustomRole(t *testing.T) {
|
||||
setRequiredEnv(t)
|
||||
t.Setenv("GENIUSRUN_OIDC_REQUIRED_ROLE", "admin")
|
||||
t.Setenv("GENIUSRUN_SESSION_DURATION", "24h")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
@@ -196,7 +191,4 @@ func TestLoad_CustomRoleAndDuration(t *testing.T) {
|
||||
if cfg.OIDCRequiredRole != "admin" {
|
||||
t.Errorf("OIDCRequiredRole = %q", cfg.OIDCRequiredRole)
|
||||
}
|
||||
if cfg.SessionDuration != 24*time.Hour {
|
||||
t.Errorf("SessionDuration = %v", cfg.SessionDuration)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user