Commit 28a89d65 authored by Stefan H. Holek's avatar Stefan H. Holek

Collector #1160: HTTPResponse.expireCookie() potentially didn't

when an 'expires' keyword argument was passed.
parent c9dcc610
...@@ -105,6 +105,9 @@ Zope Changes ...@@ -105,6 +105,9 @@ Zope Changes
Bugs fixed Bugs fixed
- Collector #1160: HTTPResponse.expireCookie() potentially didn't
when an 'expires' keyword argument was passed.
- Collector #1289: Allow ZSQL methods to be edited via WebDAV. - Collector #1289: Allow ZSQL methods to be edited via WebDAV.
- WebDAV property values were not being properly escaped on - WebDAV property values were not being properly escaped on
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
############################################################################## ##############################################################################
'''CGI Response Output formatter '''CGI Response Output formatter
$Id: HTTPResponse.py,v 1.80 2004/01/19 19:56:53 Brian Exp $''' $Id: HTTPResponse.py,v 1.81 2004/04/26 10:12:08 shh Exp $'''
__version__ = '$Revision: 1.80 $'[11:-2] __version__ = '$Revision: 1.81 $'[11:-2]
import types, os, sys, re import types, os, sys, re
import zlib, struct import zlib, struct
...@@ -500,10 +500,10 @@ class HTTPResponse(BaseResponse): ...@@ -500,10 +500,10 @@ class HTTPResponse(BaseResponse):
''' '''
name = str(name) name = str(name)
dict = {'max_age':0, 'expires':'Wed, 31-Dec-97 23:59:59 GMT'} d = kw.copy()
for k, v in kw.items(): d['max_age'] = 0
dict[k] = v d['expires'] = 'Wed, 31-Dec-97 23:59:59 GMT'
apply(HTTPResponse.setCookie, (self, name, 'deleted'), dict) apply(HTTPResponse.setCookie, (self, name, 'deleted'), d)
def setCookie(self,name,value,**kw): def setCookie(self,name,value,**kw):
'''\ '''\
......
...@@ -28,6 +28,43 @@ class HTTPResponseTests(unittest.TestCase): ...@@ -28,6 +28,43 @@ class HTTPResponseTests(unittest.TestCase):
response.setStatus(exc_type) response.setStatus(exc_type)
self.assertEqual(response.status, code) self.assertEqual(response.status, code)
def test_setCookie(self):
response = self._makeOne()
response.setCookie('foo', 'bar', path='/')
cookie = response.cookies.get('foo', None)
self.failUnless(cookie)
self.assertEqual(cookie.get('value'), 'bar')
self.assertEqual(cookie.get('path'), '/')
def test_expireCookie(self):
response = self._makeOne()
response.expireCookie('foo', path='/')
cookie = response.cookies.get('foo', None)
self.failUnless(cookie)
self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT')
self.assertEqual(cookie.get('max_age'), 0)
self.assertEqual(cookie.get('path'), '/')
def test_expireCookie1160(self):
# Verify that the cookie is expired even if an expires kw arg is passed
# http://zope.org/Collectors/Zope/1160
response = self._makeOne()
response.expireCookie('foo', path='/', expires='Mon, 22-Mar-2004 17:59 GMT', max_age=99)
cookie = response.cookies.get('foo', None)
self.failUnless(cookie)
self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT')
self.assertEqual(cookie.get('max_age'), 0)
self.assertEqual(cookie.get('path'), '/')
def test_appendCookie(self):
response = self._makeOne()
response.setCookie('foo', 'bar', path='/')
response.appendCookie('foo', 'baz')
cookie = response.cookies.get('foo', None)
self.failUnless(cookie)
self.assertEqual(cookie.get('value'), 'bar:baz')
self.assertEqual(cookie.get('path'), '/')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(HTTPResponseTests, 'test')) suite.addTest(unittest.makeSuite(HTTPResponseTests, 'test'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment