mirror of
https://github.com/kennethreitz/responder.git
synced 2026-07-22 10:39:30 +00:00
ca1c259ff9
- secret_key default is now None, not the public "NOTASECRET" (which now
raises). sessions="auto" (default) signs with secret_key /
RESPONDER_SECRET_KEY, else mints a random per-process key with a loud
warning; sessions=True requires a real key; sessions=False disables sessions.
- Session cookies are Secure by default in production (session_https_only=None
-> Secure unless debug); SameSite=None without Secure is rejected. New
session_max_age knob.
- resolve_secret_key() + SessionConfigError in ext/sessions.py.
- req.session raises a guiding RuntimeError when sessions are disabled;
resp.session is now a delegating property (removed from __slots__ + the
eager bind), so resp.session = {...} writes through to the cookie.
- Migrated test fixtures (conftest + make_api + test_round7) to
session_https_only=False so the http TestClient round-trips cookies.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56 lines
1.0 KiB
Python
56 lines
1.0 KiB
Python
import pytest
|
|
|
|
import responder
|
|
|
|
|
|
@pytest.fixture
|
|
def api():
|
|
# session_https_only=False so the http TestClient round-trips cookies
|
|
# (sessions are Secure by default in production from v5).
|
|
return responder.API(debug=False, allowed_hosts=[";"], session_https_only=False)
|
|
|
|
|
|
@pytest.fixture
|
|
def session(api):
|
|
return api.requests
|
|
|
|
|
|
@pytest.fixture
|
|
def url():
|
|
def url_for(s):
|
|
return f"http://;{s}"
|
|
|
|
return url_for
|
|
|
|
|
|
@pytest.fixture
|
|
def flask():
|
|
from flask import Flask
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route("/")
|
|
def hello():
|
|
return "Hello World!"
|
|
|
|
return app
|
|
|
|
|
|
@pytest.fixture
|
|
def template_path(tmp_path):
|
|
template_dir = tmp_path / "static"
|
|
template_dir.mkdir()
|
|
template_file = template_dir / "test.html"
|
|
template_file.write_text("{{ var }}")
|
|
return template_file
|
|
|
|
|
|
@pytest.fixture
|
|
def needs_openapi() -> None:
|
|
try:
|
|
import apispec
|
|
|
|
_ = apispec.APISpec
|
|
except ImportError as ex:
|
|
raise pytest.skip("apispec package not installed") from ex
|