Skip to content

Commit

Permalink
Merge pull request #405 from gabrielgisoldo/master
Browse files Browse the repository at this point in the history
Update expire date on expireCookie function
  • Loading branch information
dataflake committed Nov 25, 2018
2 parents 49d7e5b + 39025ce commit 96627fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ZPublisher/HTTPResponse.py
Expand Up @@ -331,7 +331,7 @@ def expireCookie(self, name, **kw):
if 'value' in d:
d.pop('value')
d['max_age'] = 0
d['expires'] = 'Wed, 31-Dec-97 23:59:59 GMT'
d['expires'] = 'Wed, 31 Dec 1997 23:59:59 GMT'

self.setCookie(name, value='deleted', **d)

Expand Down
14 changes: 8 additions & 6 deletions src/ZPublisher/tests/testHTTPResponse.py
Expand Up @@ -208,7 +208,7 @@ def test_setCookie_no_attrs(self):
self.assertEqual(cookies[0], ('Set-Cookie', 'foo="bar"'))

def test_setCookie_w_expires(self):
EXPIRES = 'Wed, 31-Dec-97 23:59:59 GMT'
EXPIRES = 'Wed, 31 Dec 1997 23:59:59 GMT'
response = self._makeOne()
response.setCookie('foo', 'bar', expires=EXPIRES)
cookie = response.cookies.get('foo', None)
Expand Down Expand Up @@ -383,7 +383,8 @@ def test_expireCookie(self):
response.expireCookie('foo', path='/')
cookie = response.cookies.get('foo', None)
self.assertTrue(cookie)
self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT')
self.assertEqual(cookie.get('expires'),
'Wed, 31 Dec 1997 23:59:59 GMT')
self.assertEqual(cookie.get('max_age'), 0)
self.assertEqual(cookie.get('path'), '/')

Expand All @@ -392,10 +393,11 @@ def test_expireCookie1160(self):
# http://zope.org/Collectors/Zope/1160
response = self._makeOne()
response.expireCookie('foo', path='/',
expires='Mon, 22-Mar-2004 17:59 GMT', max_age=99)
expires='Mon, 22 Mar 2004 17:59 GMT', max_age=99)
cookie = response.cookies.get('foo', None)
self.assertTrue(cookie)
self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT')
self.assertEqual(cookie.get('expires'),
'Wed, 31 Dec 1997 23:59:59 GMT')
self.assertEqual(cookie.get('max_age'), 0)
self.assertEqual(cookie.get('path'), '/')

Expand Down Expand Up @@ -1068,7 +1070,7 @@ def test_listHeaders_after_expireCookie(self):
self.assertEqual(
set(cookie_header.split('; ')),
set(['qux="deleted"', 'Path=/', 'Max-Age=0',
'Expires=Wed, 31-Dec-97 23:59:59 GMT'])
'Expires=Wed, 31 Dec 1997 23:59:59 GMT'])
)

def test_listHeaders_after_addHeader(self):
Expand Down Expand Up @@ -1223,7 +1225,7 @@ def test___str__after_expireCookie(self):
self.assertEqual(
set(cookie_value.split(b'; ')),
set([b'qux="deleted"', b'Path=/', b'Max-Age=0',
b'Expires=Wed, 31-Dec-97 23:59:59 GMT'])
b'Expires=Wed, 31 Dec 1997 23:59:59 GMT'])
)

def test___str__after_addHeader(self):
Expand Down

0 comments on commit 96627fb

Please sign in to comment.