test: remove Turnstile widget dependency from test mode
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user