- fix_api_gateway_mfa.sh: MFA compilation fixes - fix_audit_compliance_part2.sh: Audit compliance fixes - fix_mfa_compilation.sh: MFA-specific compilation fixes - fix_unsafe_blocks.sh: Unsafe code analysis - fix_wave112_compilation.sh: Main compilation fix script - Test management utilities (mark_tests_ignored.sh, stub_ignored_tests.sh)
79 lines
3.1 KiB
Bash
Executable File
79 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
||
# WAVE 112 AGENT 25: Automatic Compilation Fix Script
|
||
# Fixes all 18 compilation errors in api_gateway tests
|
||
|
||
set -e
|
||
|
||
echo "🔧 WAVE 112 AGENT 25: Applying Compilation Fixes"
|
||
echo "================================================"
|
||
echo ""
|
||
|
||
# Fix 1: Add MFA module export (2 errors)
|
||
echo "📝 Fix 1: Adding MFA module export..."
|
||
if ! grep -q "^pub mod mfa;" /home/jgrusewski/Work/foxhunt/services/api_gateway/src/auth/mod.rs; then
|
||
sed -i '20a pub mod mfa;' /home/jgrusewski/Work/foxhunt/services/api_gateway/src/auth/mod.rs
|
||
echo " ✅ Added 'pub mod mfa;' to auth/mod.rs"
|
||
else
|
||
echo " ℹ️ MFA module already exported"
|
||
fi
|
||
|
||
# Fix 2: SecretString boxing (2 errors)
|
||
echo ""
|
||
echo "📝 Fix 2: Fixing SecretString type mismatches..."
|
||
sed -i 's/SecretString::new("JBSWY3DPEHPK3PXP"\.to_string())/SecretString::new("JBSWY3DPEHPK3PXP".to_string().into())/g' \
|
||
/home/jgrusewski/Work/foxhunt/services/api_gateway/tests/mfa_comprehensive.rs
|
||
echo " ✅ Fixed SecretString boxing (2 occurrences)"
|
||
|
||
# Fix 3: RateLimiter Result unwrapping in auth_flow_tests (1 error)
|
||
echo ""
|
||
echo "📝 Fix 3: Fixing RateLimiter in auth_flow_tests.rs..."
|
||
sed -i 's/let rate_limiter = RateLimiter::new(/let rate_limiter = RateLimiter::new(/g' \
|
||
/home/jgrusewski/Work/foxhunt/services/api_gateway/tests/auth_flow_tests.rs
|
||
sed -i '/let rate_limiter = RateLimiter::new(/,/;/s/;/?;/' \
|
||
/home/jgrusewski/Work/foxhunt/services/api_gateway/tests/auth_flow_tests.rs
|
||
sed -i 's/rate_limiter,/rate_limiter?,/g' \
|
||
/home/jgrusewski/Work/foxhunt/services/api_gateway/tests/auth_flow_tests.rs
|
||
echo " ✅ Fixed RateLimiter Result unwrapping"
|
||
|
||
# Fix 4: RateLimiter Result unwrapping in rate_limiter_stress_test (13 errors)
|
||
echo ""
|
||
echo "📝 Fix 4: Fixing RateLimiter in rate_limiter_stress_test.rs..."
|
||
|
||
# Create a comprehensive sed script
|
||
cat > /tmp/fix_rate_limiter.sed << 'SED'
|
||
# Unwrap RateLimiter::new() calls
|
||
s/let rate_limiter = RateLimiter::new(\([^)]*\));/let rate_limiter = RateLimiter::new(\1)?;/g
|
||
s/let limiter1 = RateLimiter::new(\([^)]*\));/let limiter1 = RateLimiter::new(\1)?;/g
|
||
s/let limiter2 = RateLimiter::new(\([^)]*\));/let limiter2 = RateLimiter::new(\1)?;/g
|
||
s/let limiter3 = RateLimiter::new(\([^)]*\));/let limiter3 = RateLimiter::new(\1)?;/g
|
||
|
||
# Unwrap Arc<RateLimiter::new()> calls
|
||
s/Arc::new(RateLimiter::new(\([^)]*\)))/Arc::new(RateLimiter::new(\1)?)/g
|
||
SED
|
||
|
||
sed -i -f /tmp/fix_rate_limiter.sed \
|
||
/home/jgrusewski/Work/foxhunt/services/api_gateway/tests/rate_limiter_stress_test.rs
|
||
echo " ✅ Fixed RateLimiter Result unwrapping (13 occurrences)"
|
||
|
||
# Validate
|
||
echo ""
|
||
echo "✅ All fixes applied!"
|
||
echo ""
|
||
echo "🔍 Validating compilation..."
|
||
echo ""
|
||
|
||
if cargo test -p api_gateway --no-run 2>&1 | grep -q "error"; then
|
||
echo "❌ Compilation still has errors. Manual review needed."
|
||
exit 1
|
||
else
|
||
echo "✅ api_gateway tests compile successfully!"
|
||
fi
|
||
|
||
echo ""
|
||
echo "🎉 SUCCESS: All 18 compilation errors fixed!"
|
||
echo ""
|
||
echo "Next steps:"
|
||
echo " 1. Run: cargo test --workspace --all-features --no-run"
|
||
echo " 2. Run: cargo fix --workspace --all-features --allow-dirty"
|
||
echo " 3. Run: cargo clippy --workspace --all-features"
|