🧪 test: add JWT secret rotation BDD scenarios and step implementations #12
@@ -20,6 +20,26 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// getDatabaseHost returns the database host from environment variable or defaults to localhost
|
||||
func getDatabaseHost() string {
|
||||
host := os.Getenv("DLC_DATABASE_HOST")
|
||||
if host == "" {
|
||||
return "localhost"
|
||||
}
|
||||
return host
|
||||
}
|
||||
|
||||
// getDatabasePort returns the database port from environment variable or defaults to 5432
|
||||
func getDatabasePort() int {
|
||||
port := 5432
|
||||
if portEnv := os.Getenv("DLC_DATABASE_PORT"); portEnv != "" {
|
||||
if parsedPort, err := strconv.Atoi(portEnv); err == nil {
|
||||
port = parsedPort
|
||||
}
|
||||
}
|
||||
return port
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
httpServer *http.Server
|
||||
port int
|
||||
@@ -523,8 +543,8 @@ func createTestConfig(port int) *config.Config {
|
||||
AdminMasterPassword: "admin123",
|
||||
},
|
||||
Database: config.DatabaseConfig{
|
||||
Host: "localhost", // Fallback if env vars not set
|
||||
Port: 5432,
|
||||
Host: getDatabaseHost(), // Use env var if set, otherwise localhost
|
||||
Port: getDatabasePort(), // Use env var if set, otherwise 5432
|
||||
User: "postgres",
|
||||
Password: "postgres",
|
||||
Name: "dance_lessons_coach_bdd_test", // Separate BDD test database
|
||||
|
||||
Reference in New Issue
Block a user