Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testCreateMemberContent
def testCreateOtherMemberContentFails
def testCreateRootContentFails
def testDeleteMemberContent
def testDeleteOtherMemberContent
def testCreateWithLocalRole
def testCreateFailsWithLocalRoleBlocked
def testCreateSucceedsWithLocalRoleBlockedInParentButAssingedInSubFolder
def testViewAllowedOnContentInAcquisitionBlockedFolder
def testViewAllowedOnContentInPrivateFolder
def testViewAllowedOnContentInAcquisitionBlockedFolderWithCustomWorkflow
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 membership
 workflow

Detailed Description

Definition at line 11 of file testContentSecurity.py.


Member Function Documentation

Definition at line 13 of file testContentSecurity.py.

00013 
00014     def afterSetUp(self):
00015         self.portal.acl_users._doAddUser('user1', 'secret', ['Member'], [])
00016         self.portal.acl_users._doAddUser('user2', 'secret', ['Member'], [])
00017         #_ender_'s member who's not a Member usecase
00018         self.portal.acl_users._doAddUser('user3', 'secret', [], [])
00019         self.membership = self.portal.portal_membership
00020         self.workflow= self.portal.portal_workflow
00021         self.createMemberarea('user1')
00022         self.createMemberarea('user2')

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 62 of file testContentSecurity.py.

00062 
00063     def testCreateFailsWithLocalRoleBlocked(self):
00064         # Ensure that local role blocking works for blocking content creation
00065         self.login('user1')
00066         self.setupAuthenticator()
00067         folder = self.membership.getHomeFolder('user1')
00068         folder.manage_addLocalRoles('user2', ('Owner',))
00069         folder.invokeFactory('Folder', id='subfolder')
00070         #Turn off local role acquisition
00071         self.setRequestMethod('POST')
00072         folder.subfolder.folder_localrole_set(use_acquisition=0)
00073         self.setRequestMethod('GET')
00074         self.login('user2')
00075         # This should now raise Unauthorized
00076         self.assertRaises(Unauthorized, folder.subfolder.invokeFactory, 'Document', 'new')

Here is the call graph for this function:

Definition at line 23 of file testContentSecurity.py.

00023 
00024     def testCreateMemberContent(self):
00025         self.login('user1')
00026         folder = self.membership.getHomeFolder('user1')
00027         folder.invokeFactory('Document', id='new')
00028         self.failUnless(hasattr(aq_base(folder), 'new'))

Here is the call graph for this function:

Definition at line 29 of file testContentSecurity.py.

00029 
00030     def testCreateOtherMemberContentFails(self):
00031         self.login('user1')
00032         folder = self.membership.getHomeFolder('user2')
00033         self.assertRaises(Unauthorized, folder.invokeFactory, 'Document', 'new')

Here is the call graph for this function:

Definition at line 34 of file testContentSecurity.py.

00034 
00035     def testCreateRootContentFails(self):
00036         self.login('user1')
00037         self.assertRaises(Unauthorized, self.portal.invokeFactory, 'Document', 'new')

Here is the call graph for this function:

Definition at line 77 of file testContentSecurity.py.

00077 
00078     def testCreateSucceedsWithLocalRoleBlockedInParentButAssingedInSubFolder(self):
00079         # Make sure that blocking a acquisition in a folder does not interfere
00080         # with assigning a role in subfolders
00081         self.login('user1')
00082         self.setupAuthenticator()
00083         folder = self.membership.getHomeFolder('user1')
00084         folder.manage_addLocalRoles('user2', ('Owner',))
00085         folder.invokeFactory('Folder', id='subfolder')
00086         subfolder = folder.subfolder
00087         #Turn off local role acquisition
00088         self.setRequestMethod('POST')
00089         subfolder.folder_localrole_set(use_acquisition=0)
00090         self.setRequestMethod('GET')
00091         subfolder.invokeFactory('Folder', id='subsubfolder')
00092         subfolder.subsubfolder.manage_addLocalRoles('user2', ('Owner',))
00093         self.login('user2')
00094         # This should not raise Unauthorized
00095         subfolder.subsubfolder.invokeFactory('Document', id='new')

Here is the call graph for this function:

Definition at line 54 of file testContentSecurity.py.

00054 
00055     def testCreateWithLocalRole(self):
00056         self.login('user1')
00057         folder = self.membership.getHomeFolder('user1')
00058         folder.manage_addLocalRoles('user2', ('Owner',))
00059         self.login('user2')
00060         # This will raise Unauthorized if the role is not set
00061         folder.invokeFactory('Document', id='new')

Here is the call graph for this function:

Definition at line 38 of file testContentSecurity.py.

00038 
00039     def testDeleteMemberContent(self):
00040         self.login('user1')
00041         folder = self.membership.getHomeFolder('user1')
00042         folder.invokeFactory('Document', id='new')
00043         folder.manage_delObjects(['new'])
00044         self.failIf(hasattr(aq_base(folder), 'new'))

Here is the call graph for this function:

Definition at line 45 of file testContentSecurity.py.

00045 
00046     def testDeleteOtherMemberContent(self):
00047         self.login('user1')
00048         folder = self.membership.getHomeFolder('user1')
00049         folder.invokeFactory('Document', id='new')
00050 
00051         self.login('user2')
00052         folder = self.membership.getHomeFolder('user1')
00053         self.assertRaises(Unauthorized, folder.manage_delObjects, ['new'])

Here is the call graph for this function:

Definition at line 96 of file testContentSecurity.py.

00096 
00097     def testViewAllowedOnContentInAcquisitionBlockedFolder(self):
00098         # Test for http://dev.plone.org/plone/ticket/4055 which seems to be
00099         # invalid
00100         self.login('user1')
00101         self.setupAuthenticator()
00102         folder = self.membership.getHomeFolder('user1')
00103         self.setRequestMethod('POST')
00104         folder.manage_addLocalRoles('user2', ('Owner',))
00105         self.setRequestMethod('GET')
00106         folder.invokeFactory('Folder', id='subfolder')
00107         subfolder = folder.subfolder
00108         self.setRequestMethod('POST')
00109         subfolder.folder_localrole_set(use_acquisition=0)
00110         self.setRequestMethod('GET')
00111         #Turn off local role acquisition
00112         subfolder.invokeFactory('Document', id='new')
00113         subfolder.new.content_status_modify(workflow_action='publish')
00114         subfolder.new.manage_addLocalRoles('user2', ('Member',))
00115         self.login('user2')
00116         # This should not raise Unauthorized
00117         subfolder.new.base_view()

Here is the call graph for this function:

Definition at line 133 of file testContentSecurity.py.

00133 
00134     def testViewAllowedOnContentInAcquisitionBlockedFolderWithCustomWorkflow(self):
00135         # Another test for http://dev.plone.org/plone/ticket/4055
00136         # using a paired down version of the custom workflow described therein
00137         # 'Access contents information' must be enabled for Authenticated/
00138         # Anonymous on folders for even simple actions to evaluate properly.
00139 
00140         # Create more private workflow starting with folder_workflow
00141         wf = self.portal.portal_workflow.folder_workflow
00142         visible = wf.states.visible
00143         visible.setPermission('View',0,('Manager','Owner'))
00144         visible.setPermission('Modify portal content',0,('Manager','Owner'))
00145         # Then plone workflow
00146         p_wf = self.portal.portal_workflow.plone_workflow
00147         published = p_wf.states.published
00148         published.setPermission('View',0,('Manager','Member','Owner'))
00149         published.setPermission('Access contents information',0,('Manager','Member','Owner'))
00150         published.setPermission('Modify portal content',0,('Manager','Member','Owner'))
00151         self.portal.portal_workflow.updateRoleMappings()
00152 
00153         self.login('user1')
00154         self.setupAuthenticator()
00155         self.setRequestMethod('POST')
00156         folder = self.membership.getHomeFolder('user1')
00157         self.setRequestMethod('GET')
00158         folder.manage_addLocalRoles('user2', ('Member',))
00159         folder.invokeFactory('Folder', id='subfolder')
00160         subfolder = folder.subfolder
00161         self.setRequestMethod('POST')
00162         subfolder.folder_localrole_set(use_acquisition=0)
00163         self.setRequestMethod('GET')
00164         subfolder.invokeFactory('Document', id='new')
00165         subfolder.new.content_status_modify(workflow_action='publish')
00166         subfolder.new.manage_addLocalRoles('user3', ('Member',))
00167         self.login('user3')
00168         # This shouldn't either, but strangely it never does even if the script
00169         # below, which is called in here, does.  What is wrong here?
00170         try:
00171             subfolder.new.base_view()
00172         except Unauthorized:
00173             self.fail("Could not access base_view on 'new'")
00174         # This should not raise Unauthorized
00175 

Here is the call graph for this function:

Definition at line 118 of file testContentSecurity.py.

00118 
00119     def testViewAllowedOnContentInPrivateFolder(self):
00120         self.login('user1')
00121         folder = self.membership.getHomeFolder('user1')
00122         folder.content_status_modify(workflow_action='private')
00123         folder.invokeFactory('Document', id='doc1')
00124         doc = folder.doc1
00125         doc.content_status_modify(workflow_action='publish')
00126         doc.manage_addLocalRoles('user2', ('Owner',))
00127         self.login('user2')
00128         # This should not raise Unauthorized
00129         doc.base_view()
00130         # Neither should anonymous
00131         self.logout()
00132         doc.base_view()

Here is the call graph for this function:


Member Data Documentation

Definition at line 18 of file testContentSecurity.py.

Definition at line 19 of file testContentSecurity.py.


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