🧪 test: add JWT secret rotation BDD scenarios and step implementations #12
@@ -31,7 +31,6 @@ Feature: User Authentication
|
|||||||
And I should receive a valid JWT token
|
And I should receive a valid JWT token
|
||||||
And the token should contain admin claims
|
And the token should contain admin claims
|
||||||
|
|
||||||
@flaky
|
|
||||||
Scenario: User registration
|
Scenario: User registration
|
||||||
Given the server is running
|
Given the server is running
|
||||||
When I register a new user "newuser_" with password "newpass123"
|
When I register a new user "newuser_" with password "newpass123"
|
||||||
@@ -46,7 +45,6 @@ Feature: User Authentication
|
|||||||
Then the password reset should be allowed
|
Then the password reset should be allowed
|
||||||
And the user should be flagged for password reset
|
And the user should be flagged for password reset
|
||||||
|
|
||||||
@flaky
|
|
||||||
Scenario: User completes password reset
|
Scenario: User completes password reset
|
||||||
Given the server is running
|
Given the server is running
|
||||||
And a user "resetuser" exists and is flagged for password reset
|
And a user "resetuser" exists and is flagged for password reset
|
||||||
@@ -111,7 +109,6 @@ Feature: User Authentication
|
|||||||
Then the authentication should fail
|
Then the authentication should fail
|
||||||
And the response should contain error "invalid_credentials"
|
And the response should contain error "invalid_credentials"
|
||||||
|
|
||||||
@flaky
|
|
||||||
Scenario: Multiple consecutive authentications
|
Scenario: Multiple consecutive authentications
|
||||||
Given the server is running
|
Given the server is running
|
||||||
And a user "multiuser" exists with password "testpass123"
|
And a user "multiuser" exists with password "testpass123"
|
||||||
@@ -132,7 +129,6 @@ Feature: User Authentication
|
|||||||
Then the token should be valid
|
Then the token should be valid
|
||||||
And it should contain the correct user ID
|
And it should contain the correct user ID
|
||||||
|
|
||||||
@flaky
|
|
||||||
Scenario: Authentication with expired JWT token
|
Scenario: Authentication with expired JWT token
|
||||||
Given the server is running
|
Given the server is running
|
||||||
And a user "expireduser" exists with password "testpass123"
|
And a user "expireduser" exists with password "testpass123"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ Feature: JWT Secret Rotation
|
|||||||
Then the authentication should be successful
|
Then the authentication should be successful
|
||||||
And I should receive a valid JWT token signed with the primary secret
|
And I should receive a valid JWT token signed with the primary secret
|
||||||
|
|
||||||
@flaky
|
|
||||||
Scenario: Token validation with multiple valid secrets
|
Scenario: Token validation with multiple valid secrets
|
||||||
Given the server is running with multiple JWT secrets
|
Given the server is running with multiple JWT secrets
|
||||||
And a user "tokenuser" exists with password "testpass123"
|
And a user "tokenuser" exists with password "testpass123"
|
||||||
@@ -22,7 +21,6 @@ Feature: JWT Secret Rotation
|
|||||||
Then the token should be valid
|
Then the token should be valid
|
||||||
And it should contain the correct user ID
|
And it should contain the correct user ID
|
||||||
|
|
||||||
@flaky
|
|
||||||
Scenario: Secret rotation - adding new secret while keeping old one valid
|
Scenario: Secret rotation - adding new secret while keeping old one valid
|
||||||
Given the server is running with primary JWT secret
|
Given the server is running with primary JWT secret
|
||||||
And a user "rotateuser" exists with password "testpass123"
|
And a user "rotateuser" exists with password "testpass123"
|
||||||
@@ -42,7 +40,6 @@ Feature: JWT Secret Rotation
|
|||||||
Then the authentication should fail
|
Then the authentication should fail
|
||||||
And the response should contain error "invalid_token"
|
And the response should contain error "invalid_token"
|
||||||
|
|
||||||
@flaky
|
|
||||||
Scenario: Graceful secret rotation with user continuity
|
Scenario: Graceful secret rotation with user continuity
|
||||||
Given the server is running with primary JWT secret
|
Given the server is running with primary JWT secret
|
||||||
And a user "gracefuluser" exists with password "testpass123"
|
And a user "gracefuluser" exists with password "testpass123"
|
||||||
|
|||||||
@@ -81,8 +81,6 @@ for (( run=1; run<=$RUN_COUNT; run++ )); do
|
|||||||
go clean -testcache > /dev/null 2>&1
|
go clean -testcache > /dev/null 2>&1
|
||||||
|
|
||||||
# Set environment variables for consistent BDD test behavior
|
# Set environment variables for consistent BDD test behavior
|
||||||
export FIXED_TEST_PORT=true
|
|
||||||
export BDD_SCHEMA_ISOLATION=true
|
|
||||||
export DLC_DATABASE_HOST=localhost
|
export DLC_DATABASE_HOST=localhost
|
||||||
export DLC_DATABASE_PORT=5432
|
export DLC_DATABASE_PORT=5432
|
||||||
export DLC_DATABASE_USER=postgres
|
export DLC_DATABASE_USER=postgres
|
||||||
@@ -90,7 +88,7 @@ for (( run=1; run<=$RUN_COUNT; run++ )); do
|
|||||||
export DLC_DATABASE_NAME=dance_lessons_coach_test
|
export DLC_DATABASE_NAME=dance_lessons_coach_test
|
||||||
|
|
||||||
set +e # Temporarily disable exit on error
|
set +e # Temporarily disable exit on error
|
||||||
BDD_OUTPUT=$(go test ./features/... -v 2>&1)
|
BDD_OUTPUT=$(go test ./features -v 2>&1)
|
||||||
BDD_EXIT_CODE=$?
|
BDD_EXIT_CODE=$?
|
||||||
set -e # Re-enable exit on error
|
set -e # Re-enable exit on error
|
||||||
|
|
||||||
@@ -187,10 +185,10 @@ else
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Recommendations:"
|
echo "Recommendations:"
|
||||||
echo " 1. Mark flaky BDD tests with @flaky tag"
|
echo " 1. Investigate unit test failures first (faster to fix)"
|
||||||
echo " 2. Investigate unit test failures first (faster to fix)"
|
echo " 2. Check for race conditions in failing tests"
|
||||||
echo " 3. Check for race conditions in failing tests"
|
echo " 3. Review test dependencies and isolation (schema/database isolation)"
|
||||||
echo " 4. Run with FIXED_TEST_PORT=true for debugging"
|
echo " 4. Run individual failing tests with: FIXED_TEST_PORT=true go test ./features -v -run TestBDD/Name"
|
||||||
echo " 5. Use ./scripts/run-bdd-tests.sh list-tags to see available tags"
|
echo " 5. Use ./scripts/run-bdd-tests.sh list-tags to see available tags"
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user