fix(admin): secure routes, add real IP detection, SMTP header validation, and fix Next.js layout hydration mismatch
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m5s

This commit is contained in:
2026-06-01 23:16:03 +02:00
parent 6d27dc4cda
commit 6da8a85b1d
10 changed files with 1165 additions and 96 deletions

View File

@@ -200,7 +200,7 @@ def app_client_for_quota(tmp_path, monkeypatch, admin_password):
monkeypatch.setattr(auth_svc, "USERS_FILE", tmp_path / "users.json")
monkeypatch.setattr(auth_svc, "USE_DATABASE", False)
monkeypatch.setattr(auth_svc, "DATABASE_AVAILABLE", False)
monkeypatch.setattr(tier_quota_mod, "_async_redis", None)
monkeypatch.setattr(tier_quota_mod, "_get_async_redis", lambda: None)
monkeypatch.setenv("REDIS_URL", "")
_memory_usage.clear()
@@ -267,8 +267,11 @@ def test_after_upgrade_to_pro_user_can_translate_beyond_five(
Path(output_path).write_bytes(b"dummy")
with patch(
"translators.excel_translator.excel_translator.translate_file",
"routes.translate_routes.ExcelTranslator.translate_file",
side_effect=_fake_translate,
), patch(
"routes.translate_routes.ExcelTranslator.get_translation_stats",
return_value={"attempted": 1, "changed": 1},
):
for _ in range(6):
with open(minimal_xlsx, "rb") as f:
@@ -333,8 +336,11 @@ def test_after_downgrade_to_free_quota_five_applies(
Path(output_path).write_bytes(b"dummy")
with patch(
"translators.excel_translator.excel_translator.translate_file",
"routes.translate_routes.ExcelTranslator.translate_file",
side_effect=_fake_translate,
), patch(
"routes.translate_routes.ExcelTranslator.get_translation_stats",
return_value={"attempted": 1, "changed": 1},
):
for _ in range(5):
with open(minimal_xlsx, "rb") as f:
@@ -350,6 +356,8 @@ def test_after_downgrade_to_free_quota_five_applies(
data={"target_lang": "fr", "provider": "google"},
headers={"Authorization": f"Bearer {access_token}"},
)
import time
time.sleep(0.5)
client.patch(
f"{ADMIN_USERS_PATCH}/{user_id}",
json={"plan": "free"},