def test_activate_placeful_workflow_policy_with_mapping(self): container = create( Builder('folder').titled(u'Container').in_state('external')) subfolder = create( Builder('folder').within(container).titled(u'Subfolder').in_state( 'pending')) document = create( Builder('document').within(subfolder).titled( u'The Document').in_state('internally_published')) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={'Folder': 'plone_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy('local_workflow', review_state_mapping={ ('intranet_workflow', 'plone_workflow'): { 'external': 'published', 'pending': 'pending' } }) self.assertReviewStates({ container: 'published', subfolder: 'pending', document: 'internally_published' })
def test_activate_placeful_workflow_policy_with_mapping(self): container = create(Builder('folder') .titled('Container') .in_state('external')) subfolder = create(Builder('folder') .within(container) .titled('Subfolder') .in_state('pending')) document = create(Builder('document') .within(subfolder) .titled('The Document') .in_state('internally_published')) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={ 'Folder': 'plone_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy( 'local_workflow', review_state_mapping={ ('intranet_workflow', 'plone_workflow'): { 'external': 'published', 'pending': 'pending'}}) self.assertReviewStates({ container: 'published', subfolder: 'pending', document: 'internally_published'})
def __call__(self): portal = api.portal.get() private_root = portal.unrestrictedTraverse('private', None) if private_root is None: return activator = PlacefulWorkflowPolicyActivator(private_root) activator.activate_policy( 'opengever_private_policy', review_state_mapping={ ('opengever_document_workflow', 'opengever_private_document_workflow'): { 'document-state-draft': 'document-state-draft', 'document-state-shadow': 'document-state-shadow'}, ('opengever_mail_workflow', 'opengever_private_mail_workflow'): { 'mail-state-active': 'mail-state-active'}})
def test_object_security_is_updated(self): container = create(Builder('folder') .titled('Container') .in_state('external')) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={ 'Folder': 'plone_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy( 'local_workflow', review_state_mapping={ ('intranet_workflow', 'plone_workflow'): { 'external': 'published'}}) self.assertSecurityIsUpToDate()
def test_object_security_is_updated(self): container = create( Builder('folder').titled(u'Container').in_state('external')) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={'Folder': 'plone_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy('local_workflow', review_state_mapping={ ('intranet_workflow', 'plone_workflow'): { 'external': 'published' } }) self.assertSecurityIsUpToDate()
def __call__(self): portal = api.portal.get() private_root = portal.unrestrictedTraverse('private', None) if private_root is None: return activator = PlacefulWorkflowPolicyActivator(private_root) activator.activate_policy( 'opengever_private_policy', review_state_mapping={ ('opengever_document_workflow', 'opengever_private_document_workflow'): { 'document-state-draft': 'document-state-draft', 'document-state-shadow': 'document-state-shadow' }, ('opengever_mail_workflow', 'opengever_private_mail_workflow'): { 'mail-state-active': 'mail-state-active' } })
def update_inbox_workflow(self): self.update_workflow_security( ['opengever_inbox_workflow'], reindex_security=False) inboxes = api.content.find( context=api.portal.get(), depth=1, object_provides=[IInbox, IInboxContainer]) for brain in inboxes: inbox = brain.getObject() activator = PlacefulWorkflowPolicyActivator(inbox) activator.activate_policy( 'opengever_inbox_policy', review_state_mapping={ ('opengever_document_workflow', 'opengever_inbox_document_workflow'): { 'document-state-draft': 'document-state-draft', 'document-state-removed': 'document-state-removed', 'document-state-shadow': 'document-state-shadow'}})
def test_object_security_is_reindexed(self): container = create(Builder('folder') .titled('Container') .in_state('internal')) self.assertIn('Member', self.get_allowed_roles_and_users(for_object=container)) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={ 'Folder': 'plone_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy( 'local_workflow', review_state_mapping={ ('intranet_workflow', 'plone_workflow'): { 'internal': 'published'}}) self.assertEquals( ['Anonymous'], self.get_allowed_roles_and_users(for_object=container))
def test_object_security_is_reindexed(self): container = create( Builder('folder').titled(u'Container').in_state('internal')) self.assertIn('Member', self.get_allowed_roles_and_users(for_object=container)) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={'Folder': 'plone_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy('local_workflow', review_state_mapping={ ('intranet_workflow', 'plone_workflow'): { 'internal': 'published' } }) self.assertEquals( ['Anonymous'], self.get_allowed_roles_and_users(for_object=container))
def test_respects_placeful_workflows_when_updating(self): container = create(Builder('folder')) document = create(Builder('document').within(container)) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={'Document': 'simple_publication_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy( 'local_workflow', review_state_mapping={ (None, 'simple_publication_workflow'): { None: 'private'}}) document.manage_permission('View', roles=[], acquire=True) self.assert_permission_acquired('View', document) updater = WorkflowSecurityUpdater() updater.update(['simple_publication_workflow']) self.assert_permission_not_acquired( 'View', document, 'The document should have been updated but was not.')
def test_respects_placeful_workflows_when_updating(self): container = create(Builder('folder')) document = create(Builder('document').within(container)) self.create_placeful_workflow_policy( named='local_workflow', with_workflows={'Document': 'simple_publication_workflow'}) activator = PlacefulWorkflowPolicyActivator(container) activator.activate_policy('local_workflow', review_state_mapping={ (None, 'simple_publication_workflow'): { None: 'private' } }) document.manage_permission('View', roles=[], acquire=True) self.assert_permission_acquired('View', document) updater = WorkflowSecurityUpdater() updater.update(['simple_publication_workflow']) self.assert_permission_not_acquired( 'View', document, 'The document should have been updated but was not.')