🧪 test: add JWT secret rotation BDD scenarios and step implementations #12

Merged
arcodange merged 72 commits from feature/jwt-secret-rotation into main 2026-04-11 17:56:47 +02:00
6 changed files with 23 additions and 6 deletions
Showing only changes of commit 4df20585b8 - Show all commits

View File

@@ -7,7 +7,7 @@ import (
) )
func TestAuthBDD(t *testing.T) { func TestAuthBDD(t *testing.T) {
config := testsetup.NewFeatureConfig("auth", "progress", true) config := testsetup.NewFeatureConfig("auth", "progress", false)
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Auth Feature") suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Auth Feature")
if suite.Run() != 0 { if suite.Run() != 0 {

View File

@@ -7,7 +7,7 @@ import (
) )
func TestGreetBDD(t *testing.T) { func TestGreetBDD(t *testing.T) {
config := testsetup.NewFeatureConfig("greet", "progress", true) config := testsetup.NewFeatureConfig("greet", "progress", false)
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Greet Feature") suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Greet Feature")
if suite.Run() != 0 { if suite.Run() != 0 {

View File

@@ -7,7 +7,7 @@ import (
) )
func TestHealthBDD(t *testing.T) { func TestHealthBDD(t *testing.T) {
config := testsetup.NewFeatureConfig("health", "progress", true) config := testsetup.NewFeatureConfig("health", "progress", false)
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Health Feature") suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Health Feature")
if suite.Run() != 0 { if suite.Run() != 0 {

View File

@@ -83,7 +83,6 @@ Feature: JWT Secret Retention Policy
And the old token should still be valid during retention period And the old token should still be valid during retention period
And both tokens should work until retention period expires And both tokens should work until retention period expires
@todo
Scenario: Configuration validation Scenario: Configuration validation
Given I set retention factor to 0.5 Given I set retention factor to 0.5
When I try to start the server When I try to start the server

View File

@@ -7,7 +7,7 @@ import (
) )
func TestJWTBDD(t *testing.T) { func TestJWTBDD(t *testing.T) {
config := testsetup.NewFeatureConfig("jwt", "pretty", true) config := testsetup.NewFeatureConfig("jwt", "pretty", false)
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - JWT Feature") suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - JWT Feature")
if suite.Run() != 0 { if suite.Run() != 0 {

View File

@@ -14,6 +14,15 @@ import (
"github.com/cucumber/godog" "github.com/cucumber/godog"
) )
// getWorkingDir returns the current working directory
func getWorkingDir() string {
dir, err := os.Getwd()
if err != nil {
return "unknown"
}
return dir
}
// FeatureConfig holds configuration for a feature test // FeatureConfig holds configuration for a feature test
type FeatureConfig struct { type FeatureConfig struct {
FeatureName string FeatureName string
@@ -141,13 +150,22 @@ func CreateTestSuite(t *testing.T, config *FeatureConfig, suiteName string) godo
stopOnFailure, _ = strconv.ParseBool(envStop) stopOnFailure, _ = strconv.ParseBool(envStop)
} }
// Determine the correct path for feature files
// When running from within a feature directory, use "." to find feature files in current dir
// When running from outside, use the feature name as a relative path
featurePath := "."
if workingDir := getWorkingDir(); !strings.HasSuffix(workingDir, "/"+config.FeatureName) && !strings.HasSuffix(workingDir, "\\"+config.FeatureName) {
// Not running from within the feature directory, use feature name
featurePath = config.FeatureName
}
return godog.TestSuite{ return godog.TestSuite{
Name: suiteName, Name: suiteName,
TestSuiteInitializer: bdd.InitializeTestSuite, TestSuiteInitializer: bdd.InitializeTestSuite,
ScenarioInitializer: bdd.InitializeScenario, ScenarioInitializer: bdd.InitializeScenario,
Options: &godog.Options{ Options: &godog.Options{
Format: config.Format, Format: config.Format,
Paths: []string{"."}, Paths: []string{featurePath},
TestingT: t, TestingT: t,
Strict: true, Strict: true,
Randomize: -1, Randomize: -1,