Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update werkzeug to >=2.3.3 #5101

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Version 2.3.2

Unreleased

- Session cookie sets ``Vary: Cookie`` header when it is accessed, modified, cleared,
or refreshed.
- Set ``Vary: Cookie`` header when the session is accessed, modified, or refreshed.
- Update Werkzeug requirement to >=2.3.3 to apply recent bug fixes.


Version 2.3.1
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
"Werkzeug>=2.3.0",
"Werkzeug>=2.3.3",
"Jinja2>=3.1.2",
"itsdangerous>=2.1.2",
"click>=8.1.3",
Expand Down
24 changes: 7 additions & 17 deletions src/flask/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,14 @@ def session_transaction(
:meth:`~flask.Flask.test_request_context` which are directly
passed through.
"""
# new cookie interface for Werkzeug >= 2.3
cookie_storage = self._cookies if hasattr(self, "_cookies") else self.cookie_jar

if cookie_storage is None:
if self._cookies is None:
raise TypeError(
"Cookies are disabled. Create a client with 'use_cookies=True'."
)

app = self.application
ctx = app.test_request_context(*args, **kwargs)

if hasattr(self, "_add_cookies_to_wsgi"):
self._add_cookies_to_wsgi(ctx.request.environ)
else:
self.cookie_jar.inject_wsgi(ctx.request.environ) # type: ignore[union-attr]
self._add_cookies_to_wsgi(ctx.request.environ)

with ctx:
sess = app.session_interface.open_session(app, ctx.request)
Expand All @@ -169,14 +162,11 @@ def session_transaction(
with ctx:
app.session_interface.save_session(app, sess, resp)

if hasattr(self, "_update_cookies_from_response"):
self._update_cookies_from_response(
ctx.request.host.partition(":")[0], resp.headers.getlist("Set-Cookie")
)
else:
self.cookie_jar.extract_wsgi( # type: ignore[union-attr]
ctx.request.environ, resp.headers
)
self._update_cookies_from_response(
ctx.request.host.partition(":")[0],
ctx.request.path,
resp.headers.getlist("Set-Cookie"),
)

def _copy_environ(self, other):
out = {**self.environ_base, **other}
Expand Down