test: remove Turnstile widget dependency from test mode
All checks were successful
CI / lint (push) Successful in 8s
CI / type-check (push) Successful in 15s
CI / test (push) Successful in 1m12s

This commit is contained in:
Bu5hm4nn
2026-04-08 17:01:31 +02:00
parent e45c935eb6
commit f6a85b9e42
2 changed files with 29 additions and 10 deletions

View File

@@ -162,6 +162,25 @@ def test_turnstile_settings_support_always_fail_test_keys(monkeypatch) -> None:
assert settings.uses_test_keys is False
def test_welcome_page_uses_hidden_test_token_without_turnstile_widget_in_test_env(monkeypatch, tmp_path) -> None:
from app.models import workspace as workspace_module
from app.models.workspace import WorkspaceRepository
repo = WorkspaceRepository(base_path=tmp_path / "workspaces")
monkeypatch.setattr(workspace_module, "_workspace_repo", repo)
monkeypatch.setenv("APP_ENV", "test")
monkeypatch.delenv("TURNSTILE_SITE_KEY", raising=False)
monkeypatch.delenv("TURNSTILE_SECRET_KEY", raising=False)
with TestClient(app) as client:
response = client.get("/")
assert response.status_code == 200
assert "test-token" in response.text
assert "data-sitekey=" not in response.text
assert "challenges.cloudflare.com/turnstile/v0/api.js" not in response.text
def test_bootstrap_stays_blocked_under_always_fail_turnstile_test_keys(monkeypatch, tmp_path) -> None:
from app.models import workspace as workspace_module
from app.models.workspace import WorkspaceRepository