✨ merge: implement JWT secret rotation with BDD scenario isolation - Implement JWT secret rotation mechanism (closes #8) - Add per-scenario state isolation for BDD tests (closes #14) - Validate password reset workflow via BDD tests (closes #7) - Fix port conflicts in test validation - Add state tracer for debugging test execution - Document BDD isolation strategies in ADR 0025 - Fix PostgreSQL configuration environment variables Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-authored-by: Gabriel Radureau <arcodange@gmail.com> Co-committed-by: Gabriel Radureau <arcodange@gmail.com>
68 lines
2.4 KiB
Go
68 lines
2.4 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestJWTConfigurationDefaults(t *testing.T) {
|
|
// Test that JWT configuration has proper defaults
|
|
config, err := LoadConfig()
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, config)
|
|
|
|
// Test JWT TTL default
|
|
expectedTTL := 1 * time.Hour
|
|
actualTTL := config.GetJWTTTL()
|
|
assert.Equal(t, expectedTTL, actualTTL, "JWT TTL should default to 1 hour")
|
|
|
|
// Test JWT retention factor default
|
|
expectedFactor := 2.0
|
|
actualFactor := config.GetJWTSecretRetentionFactor()
|
|
assert.Equal(t, expectedFactor, actualFactor, "JWT retention factor should default to 2.0")
|
|
|
|
// Test JWT max retention default
|
|
expectedMaxRetention := 72 * time.Hour
|
|
actualMaxRetention := config.GetJWTSecretMaxRetention()
|
|
assert.Equal(t, expectedMaxRetention, actualMaxRetention, "JWT max retention should default to 72 hours")
|
|
|
|
// Test JWT cleanup interval default
|
|
expectedCleanupInterval := 1 * time.Hour
|
|
actualCleanupInterval := config.GetJWTSecretCleanupInterval()
|
|
assert.Equal(t, expectedCleanupInterval, actualCleanupInterval, "JWT cleanup interval should default to 1 hour")
|
|
}
|
|
|
|
func TestJWTConfigurationCustomValues(t *testing.T) {
|
|
// Set custom environment variables
|
|
t.Setenv("DLC_AUTH_JWT_TTL", "2h")
|
|
t.Setenv("DLC_AUTH_JWT_SECRET_RETENTION_FACTOR", "3.5")
|
|
t.Setenv("DLC_AUTH_JWT_SECRET_MAX_RETENTION", "120h")
|
|
t.Setenv("DLC_AUTH_JWT_SECRET_CLEANUP_INTERVAL", "30m")
|
|
|
|
config, err := LoadConfig()
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, config)
|
|
|
|
// Test custom JWT TTL
|
|
expectedTTL := 2 * time.Hour
|
|
actualTTL := config.GetJWTTTL()
|
|
assert.Equal(t, expectedTTL, actualTTL, "JWT TTL should be 2 hours from environment variable")
|
|
|
|
// Test custom JWT retention factor
|
|
expectedFactor := 3.5
|
|
actualFactor := config.GetJWTSecretRetentionFactor()
|
|
assert.Equal(t, expectedFactor, actualFactor, "JWT retention factor should be 3.5 from environment variable")
|
|
|
|
// Test custom JWT max retention
|
|
expectedMaxRetention := 120 * time.Hour
|
|
actualMaxRetention := config.GetJWTSecretMaxRetention()
|
|
assert.Equal(t, expectedMaxRetention, actualMaxRetention, "JWT max retention should be 120 hours from environment variable")
|
|
|
|
// Test custom JWT cleanup interval
|
|
expectedCleanupInterval := 30 * time.Minute
|
|
actualCleanupInterval := config.GetJWTSecretCleanupInterval()
|
|
assert.Equal(t, expectedCleanupInterval, actualCleanupInterval, "JWT cleanup interval should be 30 minutes from environment variable")
|
|
}
|