🧪 test: add JWT secret rotation BDD scenarios and step implementations #12
@@ -73,6 +73,24 @@ func getDatabasePort() int {
|
|||||||
return port
|
return port
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getDatabaseName returns the database name from environment variable or defaults to dance_lessons_coach
|
||||||
|
func getDatabaseName() string {
|
||||||
|
name := os.Getenv("DLC_DATABASE_NAME")
|
||||||
|
if name == "" {
|
||||||
|
return "dance_lessons_coach"
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
// getDatabaseSSLMode returns the SSL mode from environment variable or defaults to disable
|
||||||
|
func getDatabaseSSLMode() string {
|
||||||
|
sslMode := os.Getenv("DLC_DATABASE_SSL_MODE")
|
||||||
|
if sslMode == "" {
|
||||||
|
return "disable"
|
||||||
|
}
|
||||||
|
return sslMode
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Seed the random number generator for random port selection
|
// Seed the random number generator for random port selection
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
@@ -298,8 +316,8 @@ func (s *Server) loadConfigFromFile() (*config.Config, error) {
|
|||||||
cfg.Database.Port = getDatabasePort()
|
cfg.Database.Port = getDatabasePort()
|
||||||
cfg.Database.User = "postgres"
|
cfg.Database.User = "postgres"
|
||||||
cfg.Database.Password = "postgres"
|
cfg.Database.Password = "postgres"
|
||||||
cfg.Database.Name = "dance_lessons_coach"
|
cfg.Database.Name = getDatabaseName()
|
||||||
cfg.Database.SSLMode = "disable"
|
cfg.Database.SSLMode = getDatabaseSSLMode()
|
||||||
|
|
||||||
// Ensure auth defaults
|
// Ensure auth defaults
|
||||||
if cfg.Auth.JWTSecret == "" {
|
if cfg.Auth.JWTSecret == "" {
|
||||||
@@ -668,8 +686,8 @@ func createTestConfig(port int, v2Enabled bool) *config.Config {
|
|||||||
Port: getDatabasePort(),
|
Port: getDatabasePort(),
|
||||||
User: "postgres",
|
User: "postgres",
|
||||||
Password: "postgres",
|
Password: "postgres",
|
||||||
Name: "dance_lessons_coach",
|
Name: getDatabaseName(),
|
||||||
SSLMode: "disable",
|
SSLMode: getDatabaseSSLMode(),
|
||||||
},
|
},
|
||||||
Auth: config.AuthConfig{
|
Auth: config.AuthConfig{
|
||||||
JWTSecret: "test-secret-key-for-bdd-tests",
|
JWTSecret: "test-secret-key-for-bdd-tests",
|
||||||
|
|||||||
Reference in New Issue
Block a user