MCPcopy
hub / github.com/django/django / test_invalid_unicode_cookie

Method test_invalid_unicode_cookie

tests/handlers/tests.py:70–81  ·  view source on GitHub ↗

Invalid cookie content should result in an absent cookie, but not in a crash while trying to decode it (#23638).

(self)

Source from the content-addressed store, hash-verified

68 self.assertEqual(request.COOKIES["want"], "café")
69
70 def test_invalid_unicode_cookie(self):
71 """
72 Invalid cookie content should result in an absent cookie, but not in a
73 crash while trying to decode it (#23638).
74 """
75 environ = self.request_factory.get("/").environ
76 environ["HTTP_COOKIE"] = "x=W\x03c(h]\x8e"
77 request = WSGIRequest(environ)
78 # We don't test COOKIES content, as the result might differ between
79 # Python version because parsing invalid content became stricter in
80 # latest versions.
81 self.assertIsInstance(request.COOKIES, dict)
82
83 @override_settings(ROOT_URLCONF="handlers.urls")
84 def test_invalid_multipart_boundary(self):

Callers

nothing calls this directly

Calls 2

WSGIRequestClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected