Skip to content

Commit

Permalink
add test and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
liborjelinek committed Jul 14, 2023
1 parent af2c9d7 commit 074a182
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/_newsfragments/2157.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:class:`~falcon.testing.TestCase` mimics behavior of real WSGI servers following WSGI spec where is said that ``PATH_INFO`` CGI variable for WSGI app is already percent-decoded. However, this breaks routing if slash (encoded as ``%2F``) is part of path element, not a path separator, as explained in the FAQ :ref:`routing_encoded_slashes`. The workaround based on some WSGI servers' non-standard CGI variables described in :ref:`raw_url_path_recipe` recipe breaks tests because :py:func:`falcon.testing.helpers.create_environ` hard-code CGI variable ``RAW_URI`` to ``/`` instead to real path *before* percent-decoding.
7 changes: 7 additions & 0 deletions tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ def test_create_environ_default_ua_override():
assert req.user_agent == ua


def test_create_environ_preserve_raw_uri():
uri = '/cache/http%3A%2F%2Ffalconframework.org/status'
environ = testing.create_environ(path=uri)
assert environ['PATH_INFO'] == '/cache/http://falconframework.org/status'
assert environ['RAW_URI'] == uri


def test_missing_header_is_none():
req = testing.create_req()
assert req.auth is None
Expand Down

0 comments on commit 074a182

Please sign in to comment.