Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testRenameMemberContent
def testRenameOtherMemberContentFails
def testCopyMemberContent
def testCopyOtherMemberContent
def testCutMemberContent
def testCutOtherMemberContent
def test_Bug2183_PastingIntoFolderFailsForNotAllowedContentTypes
def test_Bug2183_PastingIntoPortalFailsForNotAllowedContentTypes
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 membership

Detailed Description

Definition at line 13 of file testCutPasteSecurity.py.


Member Function Documentation

Definition at line 15 of file testCutPasteSecurity.py.

00015 
00016     def afterSetUp(self):
00017         self.portal.acl_users._doAddUser('user1', 'secret', ['Member'], [])
00018         self.portal.acl_users._doAddUser('user2', 'secret', ['Member'], [])
00019         self.membership = self.portal.portal_membership
00020         self.createMemberarea('user1')
00021         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 96 of file testCutPasteSecurity.py.

00096 
00097     def test_Bug2183_PastingIntoFolderFailsForNotAllowedContentTypes(self):
00098         # Test fix for http://dev.plone.org/plone/ticket/2183
00099         # The fix itself is in CMFCore.PortalFolder, not Plone
00100 
00101         # add the document to be copy and pasted later
00102         self.folder.invokeFactory('Document', 'doc')
00103 
00104         # add the folder where we try to paste the document later
00105         self.folder.invokeFactory('Folder', 'subfolder')
00106         subfolder = self.folder.subfolder
00107 
00108         # now disallow adding Document globaly
00109         types = self.portal.portal_types
00110         types.Document.manage_changeProperties(global_allow=0)
00111 
00112         # copy and pasting the object into the subfolder should raise
00113         # a ValueError.
00114         self.assertRaises(
00115             ValueError,
00116             subfolder.manage_pasteObjects,
00117             self.folder.manage_copyObjects(ids=['doc'])
00118         )

Definition at line 119 of file testCutPasteSecurity.py.

00119 
00120     def test_Bug2183_PastingIntoPortalFailsForNotAllowedContentTypes(self):
00121         # Test fix for http://dev.plone.org/plone/ticket/2183
00122         # The fix itself is in CMFCore.PortalFolder, not Plone
00123 
00124         # add the document to be copy and pasted later
00125         self.folder.invokeFactory('Document', 'doc')
00126 
00127         # now disallow adding Document globaly
00128         types = self.portal.portal_types
00129         types.Document.manage_changeProperties(global_allow=0)
00130 
00131         # need to be manager to paste into portal
00132         self.setRoles(['Manager'])
00133 
00134         # copy and pasting the object into the portal should raise
00135         # a ValueError.
00136         self.assertRaises(
00137             ValueError,
00138             self.portal.manage_pasteObjects,
00139             self.folder.manage_copyObjects(ids=['doc'])
00140         )
00141 

Here is the call graph for this function:

Definition at line 43 of file testCutPasteSecurity.py.

00043 
00044     def testCopyMemberContent(self):
00045         self.login('user1')
00046         src = self.membership.getHomeFolder('user1')
00047         src.invokeFactory('Document', id='testcopy')
00048         src.invokeFactory('Folder', id='dest')
00049         dest = src.dest
00050         dest.manage_pasteObjects(src.manage_copyObjects('testcopy'))
00051 
00052         # After a copy/paste, they should *both* have a copy
00053         self.failUnless(hasattr(aq_base(src), 'testcopy'))
00054         self.failUnless(hasattr(aq_base(dest), 'testcopy'))

Here is the call graph for this function:

Definition at line 55 of file testCutPasteSecurity.py.

00055 
00056     def testCopyOtherMemberContent(self):
00057         self.login('user1')
00058         src = self.membership.getHomeFolder('user1')
00059         src.invokeFactory('Document', id='testcopy')
00060 
00061         self.login('user2')
00062         dest = self.membership.getHomeFolder('user2')
00063         dest.manage_pasteObjects(src.manage_copyObjects('testcopy'))
00064         # After a copy/paste, they should *both* have a copy
00065         self.failUnless(hasattr(aq_base(src), 'testcopy'))
00066         self.failUnless(hasattr(aq_base(dest), 'testcopy'))

Here is the call graph for this function:

Definition at line 67 of file testCutPasteSecurity.py.

00067 
00068     def testCutMemberContent(self):
00069         self.login('user1')
00070         src = self.membership.getHomeFolder('user1')
00071         src.invokeFactory('Document', id='testcut')
00072 
00073         # We need to commit here so that _p_jar isn't None and move
00074         # will work
00075         transaction.savepoint(optimistic=True)
00076 
00077         src.invokeFactory('Folder', id='dest')
00078         dest = src.dest
00079         dest.manage_pasteObjects(src.manage_cutObjects('testcut'))
00080 
00081         # After a cut/paste, only destination has a copy
00082         self.failIf(hasattr(aq_base(src), 'testcut'))
00083         self.failUnless(hasattr(aq_base(dest), 'testcut'))

Here is the call graph for this function:

Definition at line 84 of file testCutPasteSecurity.py.

00084 
00085     def testCutOtherMemberContent(self):
00086         self.login('user1')
00087         src = self.membership.getHomeFolder('user1')
00088         src.invokeFactory('Document', id='testcut')
00089 
00090         # We need to commit here so that _p_jar isn't None and move
00091         # will work
00092         transaction.savepoint(optimistic=True)
00093 
00094         self.login('user2')
00095         self.assertRaises(Unauthorized, src.restrictedTraverse, 'manage_cutObjects')

Here is the call graph for this function:

Definition at line 22 of file testCutPasteSecurity.py.

00022 
00023     def testRenameMemberContent(self):
00024         self.login('user1')
00025         folder = self.membership.getHomeFolder('user1')
00026         folder.invokeFactory('Document', id='testrename')
00027 
00028         # We need to commit here so that _p_jar isn't None and move
00029         # will work
00030         transaction.savepoint(optimistic=True)
00031         folder.manage_renameObject('testrename', 'new')
00032         self.failIf(hasattr(aq_base(folder), 'testrename'))
00033         self.failUnless(hasattr(aq_base(folder), 'new'))

Here is the call graph for this function:

Definition at line 34 of file testCutPasteSecurity.py.

00034 
00035     def testRenameOtherMemberContentFails(self):
00036         self.login('user1')
00037         src = self.membership.getHomeFolder('user1')
00038         src.invokeFactory('Document', id='testrename')
00039 
00040         self.login('user2')
00041         folder = self.membership.getHomeFolder('user1')
00042         self.assertRaises(CopyError, folder.manage_renameObject, 'testrename', 'bad')

Here is the call graph for this function:


Member Data Documentation

Definition at line 18 of file testCutPasteSecurity.py.


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