🧪 test: add JWT edge case scenarios with validation endpoint
- Add expired JWT token scenario - Add wrong secret JWT token scenario - Add malformed JWT token scenario - Implement /api/v1/auth/validate endpoint - Add JWT parsing and validation to BDD steps Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -8,6 +8,56 @@ set -e
|
||||
echo "🧪 Running BDD Tests..."
|
||||
cd /Users/gabrielradureau/Work/Vibe/DanceLessonsCoach
|
||||
|
||||
# Check if PostgreSQL container is running, start it if not
|
||||
echo "🐋 Checking PostgreSQL container..."
|
||||
if ! docker ps --format '{{.Names}}' | grep -q "^dance-lessons-coach-postgres$"; then
|
||||
echo "🐋 Starting PostgreSQL container..."
|
||||
docker compose up -d postgres
|
||||
|
||||
# Wait for PostgreSQL to be ready
|
||||
echo "⏳ Waiting for PostgreSQL to be ready..."
|
||||
max_attempts=30
|
||||
attempt=0
|
||||
while [ $attempt -lt $max_attempts ]; do
|
||||
if docker exec dance-lessons-coach-postgres pg_isready -U postgres 2>/dev/null; then
|
||||
echo "✅ PostgreSQL is ready!"
|
||||
break
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ $attempt -eq $max_attempts ]; then
|
||||
echo "❌ PostgreSQL failed to start"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create BDD test database (separate from development database)
|
||||
echo "📦 Creating BDD test database..."
|
||||
if docker exec dance-lessons-coach-postgres createdb -U postgres dance_lessons_coach_bdd_test; then
|
||||
echo "✅ BDD test database created successfully!"
|
||||
else
|
||||
echo "❌ Failed to create BDD test database"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "✅ PostgreSQL container is already running"
|
||||
|
||||
# Check if BDD test database exists, create if not
|
||||
echo "📦 Checking BDD test database..."
|
||||
if docker exec dance-lessons-coach-postgres psql -U postgres -lqt | cut -d \| -f 1 | grep -qw "dance_lessons_coach_bdd_test"; then
|
||||
echo "✅ BDD test database already exists"
|
||||
else
|
||||
echo "📦 Creating BDD test database..."
|
||||
if docker exec dance-lessons-coach-postgres createdb -U postgres dance_lessons_coach_bdd_test; then
|
||||
echo "✅ BDD test database created successfully!"
|
||||
else
|
||||
echo "❌ Failed to create BDD test database"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run the BDD tests
|
||||
test_output=$(go test ./features/... -v 2>&1)
|
||||
test_exit_code=$?
|
||||
|
||||
Reference in New Issue
Block a user