Commit cf7b8110 authored by Vincent Pelletier's avatar Vincent Pelletier

tests: Make cookie generation request a bit more realistic.

parent 6940b138
......@@ -28,7 +28,10 @@
#
##############################################################################
from functools import partial
from StringIO import StringIO
import unittest
import urllib
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime
......@@ -69,9 +72,17 @@ class TestAuoLogout(ERP5TypeTestCase):
portal = self.getPortal()
request = self.app.REQUEST
stdin = urllib.urlencode({
'__ac_name': self.manager_username,
'__ac_password': self.manager_password,
})
now = DateTime()
path = portal.absolute_url_path() + '/view?__ac_name=%s&__ac_password=%s' %(self.manager_username, self.manager_password)
response = self.publish(path)
publish = partial(
self.publish,
portal.absolute_url_path() + '/view',
request_method='POST',
)
response = publish(stdin=StringIO(stdin))
self.assertIn('Welcome to ERP5', response.getBody())
# check '__ac' cookie has set an expire timeout
......@@ -86,7 +97,7 @@ class TestAuoLogout(ERP5TypeTestCase):
self.tic()
portal.portal_caches.clearAllCache()
response = self.publish(path)
response = publish(stdin=StringIO(stdin))
self.assertIn('Welcome to ERP5', response.getBody())
ac_cookie = response.getCookie('__ac')
self.assertNotEqual(ac_cookie, None)
......
......@@ -1292,6 +1292,7 @@ class TestAuthenticationCookie(UserManagementTestCase):
request.form['__ac_name'] = login
request.form['__ac_password'] = password
request['PARENTS'] = [self.portal]
request.method = request.environ['REQUEST_METHOD'] = 'POST'
# (the secure flag is only set if we accessed through https)
request.setServerURL('https', 'example.com')
......
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