Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFPlone.tests.testCookieAuth.TestCookieAuth Class Reference
Inheritance diagram for CMFPlone.tests.testCookieAuth.TestCookieAuth:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testCookieAuth.TestCookieAuth:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testAutoLoginPage
def testInsufficientPrivileges
def testSetSessionCookie
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 portal_url
 portal_path
 folder_path
 auth_info
 cookie

Detailed Description

Definition at line 16 of file testCookieAuth.py.


Member Function Documentation

Definition at line 18 of file testCookieAuth.py.

00018 
00019     def afterSetUp(self):
00020         self.portal_url = self.portal.absolute_url()
00021         self.portal_path = '/%s' % self.portal.absolute_url(1)
00022         self.folder_path = '/%s' % self.folder.absolute_url(1)
00023         self.auth_info = '%s:%s' % (default_user, default_password)
00024         self.cookie = base64.encodestring(self.auth_info)[:-1]
00025         self.folder.manage_permission('View', ['Manager'], acquire=0)

Definition at line 30 of file PloneTestCase.py.

00030 
00031     def getAuthenticator(self):
00032         tag = AuthenticatorView('context', 'request').authenticator()
00033         pattern = '<input .*name="(\w+)".*value="(\w+)"'
00034         return match(pattern, tag).groups()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.tests.PloneTestCase.PloneTestCase.setRequestMethod (   self,
  method 
) [inherited]
This is a stub now, but in case you want to try
   something fancy on Your Branch (tm), put it here.

Definition at line 26 of file PloneTestCase.py.

00026 
00027     def setRequestMethod(self, method):
00028         self.app.REQUEST.set('REQUEST_METHOD', method)
00029         self.app.REQUEST.method = method

Here is the caller graph for this function:

Definition at line 35 of file PloneTestCase.py.

00035 
00036     def setupAuthenticator(self):
00037         name, token = self.getAuthenticator()
00038         self.app.REQUEST.form[name] = token
00039 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 26 of file testCookieAuth.py.

00026 
00027     def testAutoLoginPage(self):
00028         # Should send us to login_form
00029         response = self.publish(self.folder_path)
00030         self.assertEqual(response.getStatus(), 302)
00031 
00032         location = response.getHeader('Location')
00033         self.failUnless(location.startswith(self.portal_url))
00034         self.failUnless(urlparse(location)[2].endswith('/require_login'))

Definition at line 35 of file testCookieAuth.py.

00035 
00036     def testInsufficientPrivileges(self):
00037         # Should send us to login_form
00038         response = self.publish(self.folder_path, extra={'__ac': self.cookie})
00039         self.assertEqual(response.getStatus(), 302)
00040 
00041         location = response.getHeader('Location')
00042         self.failUnless(location.startswith(self.portal_url))
00043         self.failUnless(urlparse(location)[2].endswith('/require_login'))

Definition at line 44 of file testCookieAuth.py.

00044 
00045     def testSetSessionCookie(self):
00046         # The __ac cookie should be set for the session only
00047         form = {'__ac_name': default_user, '__ac_password': default_password}
00048 
00049         response = self.publish(self.portal_path + '/logged_in',
00050                                 env={'QUERY_STRING': urlencode(form)})
00051 
00052         self.assertEqual(response.getStatus(), 200)
00053 
00054         cookie = response.getCookie('__ac')
00055         self.assertEqual(cookie.get('path'), '/')
00056         self.assertEqual(cookie.get('expires'), None)
00057 


Member Data Documentation

Definition at line 22 of file testCookieAuth.py.

Definition at line 23 of file testCookieAuth.py.

Definition at line 21 of file testCookieAuth.py.

Definition at line 20 of file testCookieAuth.py.

Definition at line 19 of file testCookieAuth.py.


The documentation for this class was generated from the following file: