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:
Jacob Neil Taylor 2020-10-24 09:48:55 +11:00 committed by GitHub
parent a3c4ceffe6
commit 16ee68da6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 14 deletions

View file

@ -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