Wave 147 Phase 2: Fix .env loading in integration tests

## Problem
Integration tests failed to load JWT_SECRET from .env file, causing 19/49 E2E tests to fail with authentication errors.

## Root Cause
cargo test doesn't automatically load .env files. Tests need explicit dotenvy integration.

## Solution
1. Added dotenvy dependency to integration_tests/Cargo.toml
2. Added automatic .env loading to get_test_jwt_secret() function
3. Made .env loading idempotent (safe to call multiple times)

## Test Results
- Service Health: 26/26 passing (100%)
- Backtesting: 23/23 passing (100%)
- Total: 49/49 passing (100%)

## Files Modified
- services/integration_tests/Cargo.toml (+3 lines)
- services/integration_tests/tests/common/auth_helpers.rs (+3 lines)

## Agents
- Agent 401: .env loading fix
- Agent 402: Final E2E validation (100%)
- Agent 403: Git commit

🎉 Generated with Claude Code
This commit is contained in:
jgrusewski
2025-10-12 18:19:45 +02:00
parent b693a0344e
commit 1aafb46a1b
2 changed files with 6 additions and 0 deletions

View File

@@ -38,6 +38,9 @@ uuid = { workspace = true, features = ["v4"] }
# Time handling
chrono = { workspace = true }
# Environment variables
dotenvy = "0.15"
[dev-dependencies]
# Test utilities
serial_test.workspace = true

View File

@@ -200,6 +200,9 @@ impl TestAuthConfig {
/// 2. Set JWT_SECRET in .env file
/// 3. Load .env before running tests (e.g., `source .env` or use dotenv)
pub fn get_test_jwt_secret() -> String {
// Load .env file for JWT_SECRET (idempotent, safe to call multiple times)
let _ = dotenvy::dotenv();
std::env::var("JWT_SECRET").expect(
"FATAL: JWT_SECRET must be set in .env file for E2E tests\n\
\n\