fix: add DEVPLACE_DISABLE_RATE_LIMIT env var to bypass middleware in tests

Add a RATE_LIMIT_DISABLED flag read from DEVPLACE_DISABLE_RATE_LIMIT env var that short-circuits the rate_limit_middleware when set, allowing test suites to disable per-IP throttling globally in conftest while individual rate-limit tests re-enable it via monkeypatch.
This commit is contained in:
2026-06-13 09:19:46 +00:00
parent 5ffd3d14ee
commit 1a26428952
4 changed files with 43 additions and 16 deletions
+6 -2
View File
@@ -24,9 +24,13 @@ os.environ["SECRET_KEY"] = "test-secret-key"
os.environ["DEVPLACE_DISABLE_SERVICES"] = "1"
os.environ["DEVPLACE_RATE_LIMIT"] = "1000000"
# Pin a single web worker so the per-worker rate-limit divisor is 1 regardless of
# any DEVPLACE_WEB_WORKERS the host (or a server .env) exports; otherwise the test
# server would inherit a production worker count and throttle dense request bursts.
# any DEVPLACE_WEB_WORKERS the host (or a server .env) exports.
os.environ["DEVPLACE_WEB_WORKERS"] = "1"
# Disable per-IP rate limiting outright for the suite: the middleware short-circuits
# when this is set, so request-dense tests (e.g. test_auth_matrix) are never throttled
# regardless of host environment. test_ratelimit.py re-enables it per test to exercise
# the limiter directly.
os.environ["DEVPLACE_DISABLE_RATE_LIMIT"] = "1"
os.environ["DEVPLACE_SITEMAP_TTL"] = "0"