fix: scan episodes synchronously and disable test mode rate limiting
- Always scan missing episodes sync in add_series to avoid race condition - Add db fallback in get_anime when in-memory episodeDict empty - Add with_episodes param to AnimeSeriesService.get_by_key - Disable auth rate limiting and lockout in test mode (ANIWORLD_TESTING=1) - Simplify responsive.robot tests: fix setup, remove fragile width checks
This commit is contained in:
@@ -12,6 +12,7 @@ can call it from async routes via threadpool if needed.
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Dict, Optional
|
||||
|
||||
@@ -88,6 +89,8 @@ class AuthService:
|
||||
self.lockout_seconds = 300 # 5 minutes
|
||||
self.token_expiry_hours = settings.token_expiry_hours or 24
|
||||
self.secret = settings.jwt_secret_key
|
||||
# Disable lockout in test mode to avoid 429 errors during rapid test execution
|
||||
self.disable_lockout = os.getenv("ANIWORLD_TESTING") == "1"
|
||||
|
||||
# --- password helpers ---
|
||||
def _hash_password(self, password: str) -> str:
|
||||
@@ -173,6 +176,8 @@ class AuthService:
|
||||
)
|
||||
|
||||
def _record_failure(self, identifier: str) -> None:
|
||||
if self.disable_lockout:
|
||||
return
|
||||
rec = self._get_fail_record(identifier)
|
||||
rec["count"] += 1
|
||||
rec["last"] = datetime.now(timezone.utc)
|
||||
@@ -186,6 +191,8 @@ class AuthService:
|
||||
self._failed.pop(identifier, None)
|
||||
|
||||
def _check_locked(self, identifier: str) -> None:
|
||||
if self.disable_lockout:
|
||||
return
|
||||
rec = self._get_fail_record(identifier)
|
||||
lu = rec.get("locked_until")
|
||||
if lu and datetime.now(timezone.utc) < lu:
|
||||
|
||||
Reference in New Issue
Block a user