コード例 #1
0
 def test_migrate_local_roles_of_nonexisting_user(self):
     portal = self.layer['portal']
     mapping = {'spam': 'peter'}
     results = migrate_localroles(portal, mapping)
     self.assertEquals([], results['moved'])
     self.assertEquals([], results['copied'])
     self.assertEquals([], results['deleted'])
コード例 #2
0
    def test_migrate_local_roles_of_multiple_users(self):
        portal = self.layer['portal']
        mapping = {'jack': 'peter',
                   'john': 'paul'}
        results = migrate_localroles(portal, mapping)

        self.assertIn(('/plone/folder', 'jack', 'peter'), results['moved'])
        self.assertIn(('/plone/folder', 'john', 'paul'), results['moved'])
        self.assertEquals([], results['copied'])
        self.assertEquals([], results['deleted'])

        self.assertIn(
            ('peter', ('Reader', 'Contributor', 'Editor')),
            portal.folder.get_local_roles()
        )
        self.assertNotIn(
            ('jack', ('Reader', 'Contributor', 'Editor')),
            portal.folder.get_local_roles()
        )
        self.assertIn(
            ('paul', ('Reader',)),
            portal.folder.get_local_roles()
        )
        self.assertNotIn(
            ('john', ('Reader',)),
            portal.folder.get_local_roles()
        )
コード例 #3
0
 def test_migrate_local_roles_of_nonexisting_user(self):
     portal = self.layer["portal"]
     mapping = {"spam": "peter"}
     results = migrate_localroles(portal, mapping)
     self.assertEquals([], results["moved"])
     self.assertEquals([], results["copied"])
     self.assertEquals([], results["deleted"])
コード例 #4
0
    def test_delete_localroles(self):
        portal = self.layer['portal']
        mapping = {'john': 'peter'}
        results = migrate_localroles(portal, mapping, mode='delete')

        self.assertIn(('/plone/folder', 'john', None), results['deleted'])
        self.assertEquals([], results['moved'])
        self.assertEquals([], results['copied'])
        self.assertNotIn(('john', ('Reader',)), portal.folder.get_local_roles())
        self.assertNotIn(('peter', ('Reader',)), portal.folder.get_local_roles())
コード例 #5
0
    def test_delete_localroles(self):
        portal = self.layer["portal"]
        mapping = {"john": "peter"}
        results = migrate_localroles(portal, mapping, mode="delete")

        self.assertIn(("/plone/folder", "john", None), results["deleted"])
        self.assertEquals([], results["moved"])
        self.assertEquals([], results["copied"])
        self.assertNotIn(("john", ("Reader",)), portal.folder.get_local_roles())
        self.assertNotIn(("peter", ("Reader",)), portal.folder.get_local_roles())
コード例 #6
0
    def test_reindex_security_on_parent(self):
        portal = self.layer["portal"]
        folder = portal["folder"]
        folder._reindexed_obj_security = False
        subfolder = folder["subfolder"]
        subfolder._reindexed_obj_security = False

        # Patch reindexObjectSecurity
        # Our implementation only sets a marker to see if it was called
        def reindexObjectSecurity(self):
            self._reindexed_obj_security = True

        folder.reindexObjectSecurity = reindexObjectSecurity.__get__(folder, folder.__class__)
        subfolder.reindexObjectSecurity = reindexObjectSecurity.__get__(subfolder, subfolder.__class__)

        mapping = {"john": "peter"}
        migrate_localroles(portal, mapping)

        self.assertTrue(folder._reindexed_obj_security)
        self.assertFalse(subfolder._reindexed_obj_security)
コード例 #7
0
    def test_migrate_local_roles_of_multiple_users(self):
        portal = self.layer["portal"]
        mapping = {"jack": "peter", "john": "paul"}
        results = migrate_localroles(portal, mapping)

        self.assertIn(("/plone/folder", "jack", "peter"), results["moved"])
        self.assertIn(("/plone/folder", "john", "paul"), results["moved"])
        self.assertEquals([], results["copied"])
        self.assertEquals([], results["deleted"])

        self.assertIn(("peter", ("Reader", "Contributor", "Editor")), portal.folder.get_local_roles())
        self.assertNotIn(("jack", ("Reader", "Contributor", "Editor")), portal.folder.get_local_roles())
        self.assertIn(("paul", ("Reader",)), portal.folder.get_local_roles())
        self.assertNotIn(("john", ("Reader",)), portal.folder.get_local_roles())