[CMF-checkins] CVS: Products/CMFCore/tests - test_PortalFolder.py:1.34

Stefan H. Holek stefan at epy.co.at
Sat Jul 31 11:57:42 EDT 2004


Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv19712/CMFCore/tests

Modified Files:
	test_PortalFolder.py 
Log Message:
_verifyObjectPaste() did not check the container's allowed content types,
enabling users to paste objects they were not allowed to add.
Also see http://collector.zope.org/CMF/216


=== Products/CMFCore/tests/test_PortalFolder.py 1.33 => 1.34 ===
--- Products/CMFCore/tests/test_PortalFolder.py:1.33	Sat Jul 31 07:53:07 2004
+++ Products/CMFCore/tests/test_PortalFolder.py	Sat Jul 31 11:57:42 2004
@@ -369,6 +369,41 @@
         assert has_path( catalog._catalog, '/test/sub2/dummy' )
         assert has_path( catalog._catalog, '/test/sub3/dummy' )
 
+    def test_contentPasteAllowedTypes( self ):
+        #
+        #   _verifyObjectPaste() should honor allowed content types
+        #
+        test = self.root.test
+
+        self.root._setObject( 'portal_types', TypesTool() )
+        types_tool = self.root.portal_types
+
+        fti = FTIDATA_DUMMY[0].copy()
+        types_tool._setObject( 'Dummy Content', FTI(**fti) )
+        types_tool._setObject( 'Folder', FTI(**fti) )
+
+        test._setObject( 'sub1', PortalFolder( 'sub1', '' ) )
+        sub1 = test.sub1
+        sub1._setObject( 'dummy', DummyContent( 'dummy' ) )
+
+        test._setObject( 'sub2', PortalFolder( 'sub2', '' ) )
+        sub2 = test.sub2
+        sub2.all_meta_types = extra_meta_types()
+
+        # Allow adding of Dummy Content
+        types_tool.Folder.manage_changeProperties(filter_content_types=False)
+
+        # Copy/paste should work fine 
+        cookie = sub1.manage_copyObjects( ids = ( 'dummy', ) )
+        sub2.manage_pasteObjects( cookie )
+
+        # Disallow adding of Dummy Content
+        types_tool.Folder.manage_changeProperties(filter_content_types=True)
+
+        # Now copy/paste should raise a ValueError
+        cookie = sub1.manage_copyObjects( ids = ( 'dummy', ) )
+        self.assertRaises( ValueError, sub2.manage_pasteObjects, cookie )
+
     def test_setObjectRaisesBadRequest(self):
         #
         #   _setObject() should raise BadRequest on duplicate id



More information about the CMF-checkins mailing list