Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testGetUser
def testGetBadUser
def testGetUserById
def testGetBadUserById
def testGetUsers
def testGetUserNames
def testGetRoles
def testGetRolesInContext
def testHasRole
def testHasLocalRole
def testHasPermission
def testHasLocalRolePermission
def testValidate
def testNotValidateWithoutAuth
def testValidateWithoutRoles
def testNotValidateWithEmptyRoles
def testNotValidateWithWrongRoles
def testAllowAccessToUser
def testDenyAccessToAnonymous
def beforeTearDown
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 uf
 basic

Detailed Description

Definition at line 19 of file testUserFolderBasics.py.


Member Function Documentation

Definition at line 21 of file testUserFolderBasics.py.

00021 
00022     def afterSetUp(self):
00023         self.logout()
00024         self.uf = self.portal.acl_users
00025         self.basic = 'Basic %s' % base64.encodestring('%s:%s' % (default_user, default_password))
00026         # Set up a published object accessible to the default user
00027         self.folder.addDTMLMethod('doc', file='')
00028         self.folder.doc.manage_permission('View', [user_role], acquire=0)
00029         # Rig the REQUEST so it looks like we traversed to 'doc'
00030         self.app.REQUEST.set('PUBLISHED', self.folder['doc'])
00031         self.app.REQUEST.set('PARENTS', [self.folder, self.app])
00032         folder_path = list(self.folder.getPhysicalPath())
00033         self.app.REQUEST.steps = folder_path + ['doc']
00034         self._trap_warning_output()
00035 
00036         if 'auto_group' in self.uf.objectIds():
00037             self.uf.manage_delObjects(['auto_group'])
00038 
00039         # Nuke Administators and Reviewers groups added in 2.1a2 migrations
00040         # (and any other migrated-in groups) to avoid test confusion
00041         self.portal.portal_groups.removeGroups(self.portal.portal_groups.listGroupIds())

Here is the call graph for this function:

Definition at line 133 of file testUserFolderBasics.py.

00133 
00134     def beforeTearDown(self):
00135         self._free_warning_output()
00136 

Here is the call graph for this function:

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 123 of file testUserFolderBasics.py.

00123 
00124     def testAllowAccessToUser(self):
00125         self.login()
00126         try:
00127             self.folder.restrictedTraverse('doc')
00128         except Unauthorized:
00129             self.fail('Unauthorized')

Here is the call graph for this function:

Definition at line 130 of file testUserFolderBasics.py.

00130 
00131     def testDenyAccessToAnonymous(self):
00132         self.assertRaises(Unauthorized, self.folder.restrictedTraverse, 'doc')

Definition at line 45 of file testUserFolderBasics.py.

00045 
00046     def testGetBadUser(self):
00047         self.assertEqual(self.uf.getUser('user2'), None)

Definition at line 51 of file testUserFolderBasics.py.

00051 
00052     def testGetBadUserById(self):
00053         self.assertEqual(self.uf.getUserById('user2'), None)

Definition at line 64 of file testUserFolderBasics.py.

00064 
00065     def testGetRoles(self):
00066         user = self.uf.getUser(default_user)
00067         self.failUnless(user_role in user.getRoles())

Definition at line 68 of file testUserFolderBasics.py.

00068 
00069     def testGetRolesInContext(self):
00070         user = self.uf.getUser(default_user)
00071         self.folder.manage_addLocalRoles(default_user, ['Owner'])
00072         roles = user.getRolesInContext(self.folder)
00073         self.failUnless(user_role in roles)
00074         self.failUnless('Owner' in roles)

Here is the call graph for this function:

Definition at line 42 of file testUserFolderBasics.py.

00042 
00043     def testGetUser(self):
00044         self.failIfEqual(self.uf.getUser(default_user), None)

Definition at line 48 of file testUserFolderBasics.py.

00048 
00049     def testGetUserById(self):
00050         self.failIfEqual(self.uf.getUserById(default_user), None)

Definition at line 59 of file testUserFolderBasics.py.

00059 
00060     def testGetUserNames(self):
00061         names = self.uf.getUserNames()
00062         self.failUnless(names)
00063         self.assertEqual(names[0], default_user)

Definition at line 54 of file testUserFolderBasics.py.

00054 
00055     def testGetUsers(self):
00056         users = self.uf.getUsers()
00057         self.failUnless(users)
00058         self.assertEqual(users[0].getUserName(), default_user)

Definition at line 79 of file testUserFolderBasics.py.

00079 
00080     def testHasLocalRole(self):
00081         user = self.uf.getUser(default_user)
00082         self.folder.manage_addLocalRoles(default_user, ['Owner'])
00083         self.failUnless(user.has_role('Owner', self.folder))

Here is the call graph for this function:

Definition at line 90 of file testUserFolderBasics.py.

00090 
00091     def testHasLocalRolePermission(self):
00092         user = self.uf.getUser(default_user)
00093         self.folder.manage_role('Owner', ['Add Folders'])
00094         self.folder.manage_addLocalRoles(default_user, ['Owner'])
00095         self.failUnless(user.has_permission('Add Folders', self.folder))

Here is the call graph for this function:

Definition at line 84 of file testUserFolderBasics.py.

00084 
00085     def testHasPermission(self):
00086         user = self.uf.getUser(default_user)
00087         self.failUnless(user.has_permission('View', self.folder))
00088         self.folder.manage_role(user_role, ['Add Folders'])
00089         self.failUnless(user.has_permission('Add Folders', self.folder))

Here is the call graph for this function:

Definition at line 75 of file testUserFolderBasics.py.

00075 
00076     def testHasRole(self):
00077         user = self.uf.getUser(default_user)
00078         self.failUnless(user.has_role(user_role, self.folder))

Here is the call graph for this function:

Definition at line 113 of file testUserFolderBasics.py.

00113 
00114     def testNotValidateWithEmptyRoles(self):
00115         self.app.REQUEST._auth = self.basic
00116         user = self.uf.validate(self.app.REQUEST, self.basic, [])
00117         self.assertEqual(user, None)

Definition at line 102 of file testUserFolderBasics.py.

00102 
00103     def testNotValidateWithoutAuth(self):
00104         self.app.REQUEST._auth = ''
00105         user = self.uf.validate(self.app.REQUEST, '', ['role1'])
00106         self.assertEqual(user, None)

Definition at line 118 of file testUserFolderBasics.py.

00118 
00119     def testNotValidateWithWrongRoles(self):
00120         self.app.REQUEST._auth = self.basic
00121         user = self.uf.validate(self.app.REQUEST, self.basic, ['Manager'])
00122         self.assertEqual(user, None)

Definition at line 96 of file testUserFolderBasics.py.

00096 
00097     def testValidate(self):
00098         self.app.REQUEST._auth = self.basic
00099         user = self.uf.validate(self.app.REQUEST, self.basic, [user_role])
00100         self.failIfEqual(user, None)
00101         self.assertEqual(user.getUserName(), default_user)

Definition at line 107 of file testUserFolderBasics.py.

00107 
00108     def testValidateWithoutRoles(self):
00109         self.app.REQUEST._auth = self.basic
00110         # Roles will be determined by looking at 'doc' itself
00111         user = self.uf.validate(self.app.REQUEST, self.basic)
00112         self.assertEqual(user.getUserName(), default_user)


Member Data Documentation

Definition at line 24 of file testUserFolderBasics.py.

Definition at line 23 of file testUserFolderBasics.py.


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