Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(auth): refresh registration rate-limit fixture comments after #7329 (#7647)

Imaduddin Bhaisahebc003baf70adc
diff --git a/tests/chat/conftest.py b/tests/chat/conftest.py
index b22b0dfa0a..ff00841735 100644
--- a/tests/chat/conftest.py
+++ b/tests/chat/conftest.py
@@ -446,8 +446,8 @@ def second_user_client(app, temp_data_dir):
client = _make_flask_compat_client(app)
_flask = False
# Unique X-Forwarded-For so this client doesn't share the slowapi
- # rate-limit bucket with the first user's client (the "3 per hour"
- # /auth/register cap would otherwise 429 the second registration).
+ # rate-limit bucket with the first user's client (the per-IP
+ # /auth/register rate limit could otherwise 429 the second registration).
import uuid as _uuid
_fwd_ip = (
diff --git a/tests/chat/test_chat_followup_contracts.py b/tests/chat/test_chat_followup_contracts.py
index f431f0bc53..13355deb93 100644
--- a/tests/chat/test_chat_followup_contracts.py
+++ b/tests/chat/test_chat_followup_contracts.py
@@ -161,7 +161,7 @@ def _new_user(app, prefix="chatfu"):
password = "TestPass123"
client = _make_flask_compat_client(app)
# Unique forwarded IP so each user gets their own rate-limit bucket
- # (/auth/register is capped at 3/hour per client key).
+ # (/auth/register is rate limited per client key).
client.headers.update(
{
"X-Forwarded-For": f"10.{uuid.uuid4().int % 250 + 1}.{uuid.uuid4().int % 250 + 1}.7"
diff --git a/tests/conftest.py b/tests/conftest.py
index 4a27f3859f..6acf1d69f5 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -761,8 +761,9 @@ def authenticated_client(app, temp_data_dir, request):
_decode_body = lambda r: r.text # noqa: E731
# Each authenticated_client fixture gets a unique X-Forwarded-For
# so tests don't share the slowapi rate-limit bucket. Without
- # this, every test after the third in a file hits 429 from
- # /auth/register's "3 per hour" cap. TRUST_PROXY_HEADERS isn't
+ # this, registrations from one shared IP accumulate in a single
+ # bucket and later tests can hit 429 from /auth/register's per-IP
+ # rate limit. TRUST_PROXY_HEADERS isn't
# required because the slowapi key uses the direct client peer
# for non-private IPs by default — but the testclient peer is
# treated as private, so X-Forwarded-For IS honored.
diff --git a/tests/security/test_auth_routes_fastapi.py b/tests/security/test_auth_routes_fastapi.py
index e86183dfd8..50a052e245 100644
--- a/tests/security/test_auth_routes_fastapi.py
+++ b/tests/security/test_auth_routes_fastapi.py
@@ -83,9 +83,8 @@ TEST_PASSWORD = "AuthRoutePass123" # noqa: S105
def _slowapi_off():
"""Take the per-IP HTTP rate limiter out of the picture for this module.
- ``REGISTRATION_RATE_LIMIT`` defaults to "3 per hour" per IP, and the
- validation tests below need more register POSTs than that to cover every
- branch. None of these tests are ABOUT rate limiting (that is
+ ``REGISTRATION_RATE_LIMIT`` is a per-IP limit, and the validation tests
+ below issue many register POSTs from one client IP to cover every branch. None of these tests are ABOUT rate limiting (that is
``tests/web/routers/test_auth_rate_limits.py``'s job), so a 429 here is
pure noise that would mask the 400/302 each test actually asserts.
The flag is restored afterwards so no other module inherits the change.
diff --git a/tests/security/test_hostile_input_matrix.py b/tests/security/test_hostile_input_matrix.py
index e27519114b..3c7d74b79b 100644
--- a/tests/security/test_hostile_input_matrix.py
+++ b/tests/security/test_hostile_input_matrix.py
@@ -72,7 +72,7 @@ from local_deep_research.web.routes.research_validation import (
PASSWORD = "HostileMatrix!Pass123" # noqa: S105 - test-only credential
# MONOTONIC, not random: rate limiting is keyed per client IP for
-# /auth/register ("3 per hour"), and random octets collide inside a file
+# /auth/register, and random octets collide inside a file
# this size, producing 429s that have nothing to do with the guard under
# test.
_IP_COUNTER = itertools.count(1)
diff --git a/tests/security/test_library_notes_authz_fastapi.py b/tests/security/test_library_notes_authz_fastapi.py
index 99d4e3110c..e9471ac093 100644
--- a/tests/security/test_library_notes_authz_fastapi.py
+++ b/tests/security/test_library_notes_authz_fastapi.py
@@ -50,7 +50,7 @@ Harness (matching the sibling security files):
* CSRF is ASGI-middleware-enforced, so each client mints a real token. A bare
mutating request 403s at CSRF before any dependency runs, which would test
CSRF rather than the guard under test.
- * Rate limiting is keyed per client IP (registration is 3/hour) AND, for the
+ * Rate limiting is keyed per client IP (registration is limited per IP) AND, for the
notes AI buckets, per authenticated user (``_notes_factcheck_limit`` is
3/minute). Every test therefore gets a FRESH user on a FRESH IP drawn from a
MONOTONIC counter -- random addresses collide in a long session and surface
diff --git a/tests/security/test_logout_and_registration_policy_fastapi.py b/tests/security/test_logout_and_registration_policy_fastapi.py
index 4579f2943f..c2cd9da0ce 100644
--- a/tests/security/test_logout_and_registration_policy_fastapi.py
+++ b/tests/security/test_logout_and_registration_policy_fastapi.py
@@ -78,7 +78,7 @@ HARNESS
``app`` fixture from ``tests/conftest.py``. CSRF is ASGI middleware with no
off switch, so every POST carries a token minted by ``GET
/auth/csrf-token``. Rate limits are per client IP, so every client gets its
-own ``X-Forwarded-For`` (``REGISTRATION_RATE_LIMIT`` defaults to 3/hour).
+own ``X-Forwarded-For`` (``REGISTRATION_RATE_LIMIT`` is enforced per IP).
"""
import re
@@ -116,7 +116,7 @@ def _flashed_messages(html: str) -> list:
# Monotonic source of forwarded IPs. RANDOM addresses are not safe here:
-# the limiter buckets per IP at 3 registrations/hour, and with a few hundred
+# the limiter buckets registrations per IP, and with a few hundred
# clients in one session the birthday odds of two of them landing on the same
# random /32 are high enough to hit reliably. When that happened the second
# client got a 429 and the assertions below — which allow only 302/400 —
@@ -130,7 +130,7 @@ def _client(app) -> TestClient:
``_get_client_ip`` trusts ``X-Forwarded-For`` from the TestClient
sentinel peer, so a distinct address per client means a distinct
- rate-limit bucket — otherwise the 3/hour registration limit turns the
+ rate-limit bucket — otherwise the per-IP registration limit can turn the
parametrized cases below into 429s that assert nothing.
"""
n = next(_IP_COUNTER)
diff --git a/tests/security/test_metrics_hostile_input_fastapi.py b/tests/security/test_metrics_hostile_input_fastapi.py
index 5a8dc1f3ef..09123f52bd 100644
--- a/tests/security/test_metrics_hostile_input_fastapi.py
+++ b/tests/security/test_metrics_hostile_input_fastapi.py
@@ -105,7 +105,7 @@ PASSWORD = "MetricsHostile!Pass123" # noqa: S105 — test-only credential
# MONOTONIC, not random. Rate limiting is keyed per client IP
# (``dependencies/rate_limit._get_client_ip`` trusts X-Forwarded-For from
# the TestClient sentinel peer). Random octets collide inside a file this
-# size and produce 429s from /auth/register's "3 per hour" bucket that
+# size and produce 429s from /auth/register's per-IP bucket that
# have nothing to do with the guard under test.
_IP_COUNTER = itertools.count(1)
diff --git a/tests/security/test_news_scheduler_isolation_fastapi.py b/tests/security/test_news_scheduler_isolation_fastapi.py
index bb02063647..389c1db21a 100644
--- a/tests/security/test_news_scheduler_isolation_fastapi.py
+++ b/tests/security/test_news_scheduler_isolation_fastapi.py
@@ -88,7 +88,7 @@ def _fresh_client(app):
Rate limiting is keyed on the client IP (``rate_limit._get_client_ip``,
which trusts X-Forwarded-For from the TestClient sentinel peer). Two
- clients sharing an IP would share ``/auth/register``'s "3 per hour"
+ clients sharing an IP would share ``/auth/register``'s per-IP
bucket and the second registration would 429.
"""
from fastapi.testclient import TestClient
diff --git a/tests/security/test_notes_chat_followup_cross_user.py b/tests/security/test_notes_chat_followup_cross_user.py
index 27854f2276..55e0ad6dff 100644
--- a/tests/security/test_notes_chat_followup_cross_user.py
+++ b/tests/security/test_notes_chat_followup_cross_user.py
@@ -73,7 +73,7 @@ import pytest # noqa: E402
def _unique_forwarded_ip() -> str:
"""A distinct client key per user so the per-IP /auth/register cap
- (3/hour) doesn't reject the second registration."""
+ doesn't reject the second registration."""
n = uuid.uuid4().int
return f"10.{n % 250 + 1}.{(n >> 8) % 250 + 1}.{(n >> 16) % 250 + 1}"
diff --git a/tests/security/test_poisoned_path_reads.py b/tests/security/test_poisoned_path_reads.py
index 65b96bb494..b1c28b5c99 100644
--- a/tests/security/test_poisoned_path_reads.py
+++ b/tests/security/test_poisoned_path_reads.py
@@ -131,8 +131,8 @@ _FORWARDED_IP_SEQ = itertools.count(1)
def _slowapi_off():
"""Take the per-IP HTTP rate limiter out of the picture.
- Every client below registers a fresh user (``/auth/register`` caps at
- 3/hour per IP); nothing here is about rate limiting.
+ Every client below registers a fresh user (``/auth/register`` is rate limited
+ per IP); nothing here is about rate limiting.
"""
from local_deep_research.web.dependencies.rate_limit import limiter
diff --git a/tests/security/test_raw_config_toml_smuggling.py b/tests/security/test_raw_config_toml_smuggling.py
index 17576b9dc3..bdd07bbb24 100644
--- a/tests/security/test_raw_config_toml_smuggling.py
+++ b/tests/security/test_raw_config_toml_smuggling.py
@@ -104,7 +104,7 @@ def _slowapi_off():
"""Take the per-IP HTTP rate limiter out of the picture.
Every payload in this battery registers a fresh user to get a CSRF'd,
- authenticated client, and ``/auth/register`` caps at 3/hour per IP. A
+ authenticated client, and ``/auth/register`` is rate limited per IP. A
429 leaking in would mask the status code each test asserts.
"""
from local_deep_research.web.dependencies.rate_limit import limiter
diff --git a/tests/security/test_research_service_isolation_fastapi.py b/tests/security/test_research_service_isolation_fastapi.py
index b84c50c54a..8bfeb06bae 100644
--- a/tests/security/test_research_service_isolation_fastapi.py
+++ b/tests/security/test_research_service_isolation_fastapi.py
@@ -118,7 +118,7 @@ except (ValueError, TypeError):
# ---------------------------------------------------------------------------
# MONOTONIC, not random: rate limiting is keyed per client IP and random
-# octets collide, producing 429s from /auth/register's "3 per hour" bucket
+# octets collide, producing 429s from /auth/register's per-IP bucket
# that have nothing to do with the guard under test.
_IP_COUNTER = itertools.count(1)
diff --git a/tests/security/test_save_raw_config_blocked_keys_fastapi.py b/tests/security/test_save_raw_config_blocked_keys_fastapi.py
index f36aaec3f7..095e45ed60 100644
--- a/tests/security/test_save_raw_config_blocked_keys_fastapi.py
+++ b/tests/security/test_save_raw_config_blocked_keys_fastapi.py
@@ -120,7 +120,7 @@ def _slowapi_off():
Nothing here is about rate limiting (that is
``tests/security/test_rate_limiter_fastapi.py``'s job), and each test
- registers a user — ``/auth/register`` caps at "3 per hour" per IP.
+ registers a user — ``/auth/register`` is rate limited per IP.
A 429 leaking in would mask the status code each test asserts. The
distinct ``X-Forwarded-For`` per client below is kept anyway so this
file does not silently depend on the flag.
diff --git a/tests/ui_tests/README.md b/tests/ui_tests/README.md
index 394180f040..890db45abd 100644
--- a/tests/ui_tests/README.md
+++ b/tests/ui_tests/README.md
@@ -13,7 +13,7 @@ npm install puppeteer
### Local environment notes
-The auth endpoints rate-limit at **5 logins per 15 min** and **3 registrations per hour** per IP. The full suite re-authenticates dozens of times, so a local run against a default-configured server gets blocked after the first few tests and shows a wave of `Login failed` failures that are not real test failures.
+The auth endpoints rate-limit at **5 logins per 15 min** per IP, and registrations are rate limited per IP as well (see `REGISTRATION_RATE_LIMIT` in `web/dependencies/rate_limit.py`). The full suite re-authenticates dozens of times, so a local run against a default-configured server gets blocked after the first few tests and shows a wave of `Login failed` failures that are not real test failures.
Two options for local runs:
diff --git a/tests/web/routers/test_auth_flow_gaps.py b/tests/web/routers/test_auth_flow_gaps.py
index 7284df07ec..4c435a789c 100644
--- a/tests/web/routers/test_auth_flow_gaps.py
+++ b/tests/web/routers/test_auth_flow_gaps.py
@@ -72,7 +72,7 @@ def _stub_post_login_worker_target(app):
def _unique_ip() -> str:
"""Unique X-Forwarded-For so this module never shares slowapi
- rate-limit buckets (login is 5/15min/IP, register 3/hour/IP)."""
+ rate-limit buckets (login is 5/15min/IP; registration is also limited per IP)."""
return f"10.{uuid.uuid4().int % 254 + 1}.{uuid.uuid4().int % 254 + 1}.2"
diff --git a/tests/web/routers/test_state_changing_flows.py b/tests/web/routers/test_state_changing_flows.py
index 1d07866ccd..70b2e951a0 100644
--- a/tests/web/routers/test_state_changing_flows.py
+++ b/tests/web/routers/test_state_changing_flows.py
@@ -22,7 +22,7 @@ from fastapi.testclient import TestClient
def _unique_ip() -> str:
"""Generate a unique client IP to avoid sharing rate-limit buckets
- with other test files (registration limit is 3/hour/IP)."""
+ with other test files (registration is rate limited per IP)."""
return f"10.{uuid.uuid4().int % 254 + 1}.{uuid.uuid4().int % 254 + 1}.1"
diff --git a/tests/web/test_migration_regression_fixes.py b/tests/web/test_migration_regression_fixes.py
index b40c8d14fc..15eb72b715 100644
--- a/tests/web/test_migration_regression_fixes.py
+++ b/tests/web/test_migration_regression_fixes.py
@@ -42,7 +42,7 @@ TEST_PASSWORD = "TestPassword123!" # noqa: S105
def _fresh_client(app) -> TestClient:
"""TestClient with a unique X-Forwarded-For so each client gets its
- own slowapi rate-limit bucket (register is capped at 3/hour per IP)."""
+ own slowapi rate-limit bucket (registration is rate limited per client IP)."""
client = TestClient(app, raise_server_exceptions=False)
fwd_ip = f"10.{uuid.uuid4().int % 254 + 1}.{uuid.uuid4().int % 254 + 1}.2"
client.headers.update({"X-Forwarded-For": fwd_ip})
diff --git a/tests/web/test_redirect_and_url_generation.py b/tests/web/test_redirect_and_url_generation.py
index 7c43e988f8..94a2c50fed 100644
--- a/tests/web/test_redirect_and_url_generation.py
+++ b/tests/web/test_redirect_and_url_generation.py
@@ -65,7 +65,7 @@ def _unique_ip() -> str:
"""A fresh client IP per login.
``/auth/login`` is rate limited to 5 per 15 minutes per IP and
- ``/auth/register`` to 3 per hour, so tests that log in repeatedly must
+ ``/auth/register`` is rate limited per IP too, so tests that log in repeatedly must
not share a bucket with each other or with other test modules.
"""
n = uuid.uuid4().int
diff --git a/tests/web/test_remember_me_and_json_body_cap.py b/tests/web/test_remember_me_and_json_body_cap.py
index ecbdfbdcab..bb9aa8e054 100644
--- a/tests/web/test_remember_me_and_json_body_cap.py
+++ b/tests/web/test_remember_me_and_json_body_cap.py
@@ -50,7 +50,7 @@ TEST_PASSWORD = "TestPassword123!" # noqa: S105
def _fresh_client(app, base_url="http://testserver"):
"""TestClient with a unique X-Forwarded-For so each client gets its
- own slowapi rate-limit bucket (register is capped at 3/hour per IP;
+ own slowapi rate-limit bucket (registration is rate limited per IP;
the testclient peer is private, so X-Forwarded-For is honored)."""
client = TestClient(app, base_url=base_url, raise_server_exceptions=False)
fwd_ip = f"10.{uuid.uuid4().int % 254 + 1}.{uuid.uuid4().int % 254 + 1}.2"
diff --git a/tests/web/test_session_cookie_behavior.py b/tests/web/test_session_cookie_behavior.py
index da88d491ad..e3d0950c94 100644
--- a/tests/web/test_session_cookie_behavior.py
+++ b/tests/web/test_session_cookie_behavior.py
@@ -40,7 +40,7 @@ THIRTY_DAYS_SECONDS = 30 * 24 * 3600
def _fresh_client(app, base_url="http://testserver"):
"""TestClient with a unique X-Forwarded-For so each client gets its
- own slowapi rate-limit bucket (register is capped at 3/hour per IP;
+ own slowapi rate-limit bucket (registration is rate limited per IP;
the testclient peer is private, so X-Forwarded-For is honored)."""
client = TestClient(app, base_url=base_url, raise_server_exceptions=False)
fwd_ip = f"10.{uuid.uuid4().int % 254 + 1}.{uuid.uuid4().int % 254 + 1}.1"
diff --git a/tests/web/test_session_cookie_semantics.py b/tests/web/test_session_cookie_semantics.py
index 42026c498b..b31fa48670 100644
--- a/tests/web/test_session_cookie_semantics.py
+++ b/tests/web/test_session_cookie_semantics.py
@@ -73,7 +73,7 @@ UNREAD_SAVES = 12
def _fresh_client(app, base_url="http://testserver"):
"""TestClient with a unique X-Forwarded-For so each client lands in its
- own slowapi bucket (register is 3/hour per IP)."""
+ own slowapi bucket (registration is rate limited per client IP)."""
client = TestClient(app, base_url=base_url, raise_server_exceptions=False)
fwd = f"10.{uuid.uuid4().int % 254 + 1}.{uuid.uuid4().int % 254 + 1}.1"
client.headers.update({"X-Forwarded-For": fwd})