Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testFolderLocalRoleAddPostOnly
def testFolderLocalRoleDeletePostOnly
def testFolderLocalRoleDelete2PostOnly
def testFolderLocalRoleSetPostOnly
def testFolderLocalRoleAdd
def testFolderLocalRoleDelete
def testFolderLocalRoleView
def testDeleteSingleRole
def testDeleteAllUserRoles
def testAddRoleForUser
def testIsLocalRoleAcquired
def testStopAcquireLocalRole
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 membership

Detailed Description

Definition at line 14 of file testFolderLocalRoleForm.py.


Member Function Documentation

Definition at line 16 of file testFolderLocalRoleForm.py.

00016 
00017     def afterSetUp(self):
00018         self.membership = self.portal.portal_membership
00019         self.membership.addMember('user2', 'secret', ['Member'], [])
00020         self.portal.acl_users.addRole('Foo')
00021         self.portal.acl_users.addRole('Bar')
00022         self.portal.acl_users.addRole('Baz')
00023         # Cannot assign a role I do not have myself...
00024         self.setRoles(['Member', 'Foo', 'Bar', 'Baz'])
00025         self.setupAuthenticator()

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 105 of file testFolderLocalRoleForm.py.

00105 
00106     def testAddRoleForUser(self):
00107         # Try adding a new role for a user
00108         member = self.membership.getMemberById('user2')
00109         # add a role the old way
00110         self.setRequestMethod('POST')
00111         self.folder.folder_localrole_edit('add', ['user2'], 'Foo')
00112 
00113         # add another role the new way
00114         self.folder.folder_localrole_add(member_ids=['user2'], member_roles=['Bar', 'Baz'])
00115         self.setRequestMethod('GET')
00116         self.assertEqual(sortTuple(member.getRolesInContext(self.folder)),
00117                          ('Authenticated', 'Bar', 'Baz', 'Foo', 'Member'))

Here is the call graph for this function:

Definition at line 91 of file testFolderLocalRoleForm.py.

00091 
00092     def testDeleteAllUserRoles(self):
00093         # Try deleting a all roles
00094         member = self.membership.getMemberById('user2')
00095         # add two roles
00096         self.setRequestMethod('POST')
00097         self.folder.folder_localrole_edit('add', ['user2'], 'Foo')
00098         self.folder.folder_localrole_edit('add', ['user2'], 'Bar')
00099 
00100         # remove a user
00101         self.folder.folder_localrole_delete(member_ids=['user2'])
00102         self.setRequestMethod('GET')
00103         self.assertEqual(sortTuple(member.getRolesInContext(self.folder)),
00104                          ('Authenticated', 'Member'))

Here is the call graph for this function:

Definition at line 77 of file testFolderLocalRoleForm.py.

00077 
00078     def testDeleteSingleRole(self):
00079         # Try deleting a single role
00080         member = self.membership.getMemberById('user2')
00081         # add two roles
00082         self.setRequestMethod('POST')
00083         self.folder.folder_localrole_edit('add', ['user2'], 'Foo')
00084         self.folder.folder_localrole_edit('add', ['user2'], 'Bar')
00085 
00086         # remove the Bar role
00087         self.folder.folder_localrole_delete(member_role_ids=['user2((Bar))'])
00088         self.setRequestMethod('GET')
00089         self.assertEqual(sortTuple(member.getRolesInContext(self.folder)),
00090                          ('Authenticated', 'Foo', 'Member'))

Here is the call graph for this function:

Definition at line 50 of file testFolderLocalRoleForm.py.

00050 
00051     def testFolderLocalRoleAdd(self):
00052         # Should assing a local role
00053         self.setRequestMethod('POST')
00054         self.folder.folder_localrole_edit('add', ['user2'], 'Foo')
00055         self.setRequestMethod('GET')
00056         member = self.membership.getMemberById('user2')
00057         self.assertEqual(sortTuple(member.getRolesInContext(self.folder)),
00058                          ('Authenticated', 'Foo', 'Member'))

Here is the call graph for this function:

Definition at line 26 of file testFolderLocalRoleForm.py.

00026 
00027     def testFolderLocalRoleAddPostOnly(self):
00028         # Should try to use get on assing a local role
00029         self.setRequestMethod('GET')
00030         self.assertRaises(Forbidden, self.folder.folder_localrole_edit,'add',['user2'],'Foo')

Here is the call graph for this function:

Definition at line 59 of file testFolderLocalRoleForm.py.

00059 
00060     def testFolderLocalRoleDelete(self):
00061         # Should delete a local role
00062         self.setRequestMethod('POST')
00063         self.folder.folder_localrole_edit('add', ['user2'], 'Foo')
00064         member = self.membership.getMemberById('user2')
00065         self.assertEqual(sortTuple(member.getRolesInContext(self.folder)),
00066                          ('Authenticated', 'Foo', 'Member'))
00067         self.folder.folder_localrole_edit('delete', ['user2'])
00068         self.setRequestMethod('GET')
00069         self.assertEqual(sortTuple(member.getRolesInContext(self.folder)),
00070                          ('Authenticated', 'Member'))

Here is the call graph for this function:

Definition at line 38 of file testFolderLocalRoleForm.py.

00038 
00039     def testFolderLocalRoleDelete2PostOnly(self):
00040         # Should try to use get on delete a local role
00041         self.setRequestMethod('POST')
00042         self.folder.folder_localrole_edit('add', ['user2'], 'Foo')
00043         self.setRequestMethod('GET')
00044         self.assertRaises(Forbidden, self.folder.folder_localrole_delete,['user2'])

Here is the call graph for this function:

Definition at line 31 of file testFolderLocalRoleForm.py.

00031 
00032     def testFolderLocalRoleDeletePostOnly(self):
00033         # Should try to use get on delete a local role
00034         self.setRequestMethod('POST')
00035         self.folder.folder_localrole_edit('add', ['user2'], 'Foo')
00036         self.setRequestMethod('GET')
00037         self.assertRaises(Forbidden, self.folder.folder_localrole_edit,'delete',['user2'])

Here is the call graph for this function:

Definition at line 45 of file testFolderLocalRoleForm.py.

00045 
00046     def testFolderLocalRoleSetPostOnly(self):
00047         # Should try to use get on assing a local role
00048         self.setRequestMethod('GET')
00049         self.assertRaises(Forbidden, self.folder.folder_localrole_set)

Here is the call graph for this function:

Definition at line 71 of file testFolderLocalRoleForm.py.

00071 
00072     def testFolderLocalRoleView(self):
00073         # sharing should render
00074         self.loginAsPortalOwner()
00075         view = self.folder.restrictedTraverse("sharing")
00076         view()

Here is the call graph for this function:

Definition at line 118 of file testFolderLocalRoleForm.py.

00118 
00119     def testIsLocalRoleAcquired(self):
00120         # Try setting the stop acquisition flag on a folder
00121         putils = self.portal.plone_utils
00122         putils.acquireLocalRoles(self.folder, status=0)
00123         self.assertEqual(putils.isLocalRoleAcquired(self.folder), 0)

Here is the call graph for this function:

Definition at line 124 of file testFolderLocalRoleForm.py.

00124 
00125     def testStopAcquireLocalRole(self):
00126         # See if a sub folder really didn't get the roles by acquisition
00127         member = self.membership.getMemberById('user2')
00128         self.setRequestMethod('POST')
00129         self.folder.folder_localrole_add(member_ids=['user2'], member_roles=['Bar'])
00130 
00131         # check if the role was assigned
00132         self.assertEqual(sortTuple(member.getRolesInContext(self.folder)),
00133                          ('Authenticated', 'Bar', 'Member'))
00134 
00135         self.folder.invokeFactory('Folder', id='A')
00136         putils = self.portal.plone_utils
00137         putils.acquireLocalRoles(self.folder.A, status=0)
00138         self.setRequestMethod('GET')
00139 
00140         # check if inheritance is blocked
00141         self.assertEqual(sortTuple(member.getRolesInContext(self.folder.A)),
00142                          ('Authenticated', 'Member'))
00143 

Here is the call graph for this function:


Member Data Documentation

Definition at line 17 of file testFolderLocalRoleForm.py.


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