mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-38976: Add support for HTTP Only flag in MozillaCookieJar (#17471)
Add support for HTTP Only flag in MozillaCookieJar Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
parent
a3c4ceffe6
commit
16ee68da6e
3 changed files with 35 additions and 14 deletions
|
@ -1773,6 +1773,10 @@ class LWPCookieTests(unittest.TestCase):
|
|||
interact_netscape(c, "http://www.foo.com/",
|
||||
"fooc=bar; Domain=www.foo.com; %s" % expires)
|
||||
|
||||
for cookie in c:
|
||||
if cookie.name == "foo1":
|
||||
cookie.set_nonstandard_attr("HTTPOnly", "")
|
||||
|
||||
def save_and_restore(cj, ignore_discard):
|
||||
try:
|
||||
cj.save(ignore_discard=ignore_discard)
|
||||
|
@ -1787,6 +1791,7 @@ class LWPCookieTests(unittest.TestCase):
|
|||
new_c = save_and_restore(c, True)
|
||||
self.assertEqual(len(new_c), 6) # none discarded
|
||||
self.assertIn("name='foo1', value='bar'", repr(new_c))
|
||||
self.assertIn("rest={'HTTPOnly': ''}", repr(new_c))
|
||||
|
||||
new_c = save_and_restore(c, False)
|
||||
self.assertEqual(len(new_c), 4) # 2 of them discarded on save
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue