test: bypass Turnstile network calls in test env
Some checks failed
CI / lint (push) Successful in 9s
CI / type-check (push) Successful in 16s
CI / test (push) Failing after 2m17s

This commit is contained in:
Bu5hm4nn
2026-04-08 16:53:40 +02:00
parent eb262189cf
commit e45c935eb6
2 changed files with 27 additions and 1 deletions

View File

@@ -66,6 +66,14 @@ def verify_turnstile_token(token: str, remote_ip: str | None = None) -> bool:
return True
if not token.strip():
return False
if _environment() == "test":
if (
settings.site_key == ALWAYS_FAIL_TURNSTILE_TEST_SITE_KEY
and settings.secret_key == ALWAYS_FAIL_TURNSTILE_TEST_SECRET_KEY
):
return False
if settings.uses_test_keys:
return True
try:
response = requests.post(
TURNSTILE_VERIFY_URL,