From 1aafb46a1b4a8d019f2181a671e6e79526f58c69 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Sun, 12 Oct 2025 18:19:45 +0200 Subject: [PATCH] Wave 147 Phase 2: Fix .env loading in integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 --- services/integration_tests/Cargo.toml | 3 +++ services/integration_tests/tests/common/auth_helpers.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/services/integration_tests/Cargo.toml b/services/integration_tests/Cargo.toml index e7974ab6d..a45ef27ef 100644 --- a/services/integration_tests/Cargo.toml +++ b/services/integration_tests/Cargo.toml @@ -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 diff --git a/services/integration_tests/tests/common/auth_helpers.rs b/services/integration_tests/tests/common/auth_helpers.rs index 837ecc8eb..7c5ba2d09 100644 --- a/services/integration_tests/tests/common/auth_helpers.rs +++ b/services/integration_tests/tests/common/auth_helpers.rs @@ -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\