Add document ACLs workflow actions

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-06-10 03:43:39 -04:00
parent 505e0bd68b
commit f66328139e
6 changed files with 140 additions and 7 deletions
+35 -1
View File
@@ -5,7 +5,10 @@ from django.contrib.contenttypes.models import ContentType
from mayan.apps.document_states.tests.test_actions import ActionTestCase
from mayan.apps.documents.permissions import permission_document_view
from ..workflow_actions import GrantAccessAction, RevokeAccessAction
from ..workflow_actions import (
GrantAccessAction, GrantDocumentAccessAction, RevokeAccessAction,
RevokeDocumentAccessAction
)
class ACLActionTestCase(ActionTestCase):
@@ -29,6 +32,22 @@ class ACLActionTestCase(ActionTestCase):
)
self.assertEqual(self.test_document.acls.first().role, self._test_case_role)
def test_grant_document_access_action(self):
action = GrantDocumentAccessAction(
form_data={
'roles': [self._test_case_role.pk],
'permissions': [permission_document_view.pk],
}
)
action.execute(context={'document': self.test_document})
self.assertEqual(self.test_document.acls.count(), 1)
self.assertEqual(
list(self.test_document.acls.first().permissions.all()),
[permission_document_view.stored_permission]
)
self.assertEqual(self.test_document.acls.first().role, self._test_case_role)
def test_revoke_access_action(self):
self.grant_access(
obj=self.test_document, permission=permission_document_view
@@ -47,3 +66,18 @@ class ACLActionTestCase(ActionTestCase):
action.execute(context={'entry_log': self.entry_log})
self.assertEqual(self.test_document.acls.count(), 0)
def test_revoke_document_access_action(self):
self.grant_access(
obj=self.test_document, permission=permission_document_view
)
action = RevokeDocumentAccessAction(
form_data={
'roles': [self._test_case_role.pk],
'permissions': [permission_document_view.pk],
}
)
action.execute(context={'document': self.test_document})
self.assertEqual(self.test_document.acls.count(), 0)