test: force Turnstile test mode in CI
This commit is contained in:
@@ -33,8 +33,19 @@ def load_turnstile_settings() -> TurnstileSettings:
|
||||
enabled = os.getenv("TURNSTILE_ENABLED", "true").lower() not in {"0", "false", "no"}
|
||||
env = _environment()
|
||||
|
||||
if not site_key or not secret_key:
|
||||
if env in {"development", "test"}:
|
||||
known_test_pairs = {
|
||||
(DEFAULT_TURNSTILE_TEST_SITE_KEY, DEFAULT_TURNSTILE_TEST_SECRET_KEY),
|
||||
(ALWAYS_FAIL_TURNSTILE_TEST_SITE_KEY, ALWAYS_FAIL_TURNSTILE_TEST_SECRET_KEY),
|
||||
}
|
||||
|
||||
if env == "test":
|
||||
if (site_key, secret_key) not in known_test_pairs:
|
||||
if site_key or secret_key:
|
||||
logger.info("Ignoring configured Turnstile credentials in test environment and using test keys")
|
||||
site_key = DEFAULT_TURNSTILE_TEST_SITE_KEY
|
||||
secret_key = DEFAULT_TURNSTILE_TEST_SECRET_KEY
|
||||
elif not site_key or not secret_key:
|
||||
if env == "development":
|
||||
site_key = site_key or DEFAULT_TURNSTILE_TEST_SITE_KEY
|
||||
secret_key = secret_key or DEFAULT_TURNSTILE_TEST_SECRET_KEY
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user