MCPcopy Create free account
hub / github.com/EasyIME/PIME / test_cookie_special_char

Method test_cookie_special_char

python/python3/tornado/test/web_test.py:356–379  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

354 )
355
356 def test_cookie_special_char(self):
357 response = self.fetch("/special_char")
358 headers = sorted(response.headers.get_list("Set-Cookie"))
359 self.assertEqual(len(headers), 3)
360 self.assertEqual(headers[0], 'equals="a=b"; Path=/')
361 self.assertEqual(headers[1], 'quote="a\\"b"; Path=/')
362 # python 2.7 octal-escapes the semicolon; older versions leave it alone
363 self.assertTrue(
364 headers[2] in ('semicolon="a;b"; Path=/', 'semicolon="a\\073b"; Path=/'),
365 headers[2],
366 )
367
368 data = [
369 ("foo=a=b", "a=b"),
370 ('foo="a=b"', "a=b"),
371 ('foo="a;b"', '"a'), # even quoted, ";" is a delimiter
372 ("foo=a\\073b", "a\\073b"), # escapes only decoded in quotes
373 ('foo="a\\073b"', "a;b"),
374 ('foo="a\\"b"', 'a"b'),
375 ]
376 for header, expected in data:
377 logging.debug("trying %r", header)
378 response = self.fetch("/get", headers={"Cookie": header})
379 self.assertEqual(response.body, utf8(expected))
380
381 def test_set_cookie_overwrite(self):
382 response = self.fetch("/set_overwrite")

Callers

nothing calls this directly

Calls 4

utf8Function · 0.90
get_listMethod · 0.80
debugMethod · 0.80
fetchMethod · 0.45

Tested by

no test coverage detected