-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10659 from archesproject/raise-exception-arg
Add raise_exception arg to @group_required #10658
- Loading branch information
Showing
3 changed files
with
30 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
import uuid | ||
import datetime | ||
|
||
from django.contrib.auth.models import User | ||
from django.contrib.auth.models import Group, User | ||
from django.urls import reverse | ||
from django.test.client import Client | ||
|
||
from arches.app.models.models import WorkflowHistory | ||
from tests.base_test import ArchesTestCase | ||
|
||
# these tests can be run from the command line via | ||
# python manage.py test tests.views.workflow_tests --settings="tests.test_settings" | ||
|
||
|
||
class WorkflowHistoryTests(ArchesTestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.client = Client() | ||
cls.admin = User.objects.get(username="admin") | ||
cls.anonymous = User.objects.get(username="anonymous") | ||
cls.editor = User.objects.create_user(username="editor", email="[email protected]", password="Test12345!") | ||
group = Group.objects.get(name="Resource Editor") | ||
group.user_set.add(cls.editor) | ||
super().setUpClass() | ||
|
||
def setUp(self): | ||
|
@@ -73,7 +79,7 @@ def test_get_workflow_history(self): | |
response = self.client.get(reverse("workflow_history", kwargs={"workflowid": str(self.history.workflowid)})) | ||
|
||
self.assertEqual(response.status_code, 403) | ||
self.assertIn(b"Permission Denied", response.content) | ||
self.assertIn(b"Forbidden", response.content) | ||
|
||
self.client.force_login(self.admin) | ||
response = self.client.get(reverse("workflow_history", kwargs={"workflowid": str(self.history.workflowid)})) | ||
|
@@ -83,13 +89,6 @@ def test_get_workflow_history(self): | |
|
||
def test_post_workflow_history(self): | ||
"""Partial updates of componentdata and stepdata are allowed.""" | ||
self.client.force_login(self.anonymous) | ||
response = self.client.post(reverse("workflow_history", kwargs={"workflowid": str(self.history.workflowid)})) | ||
|
||
self.assertEqual(response.status_code, 403) | ||
self.assertIn(b"Permission Denied", response.content) | ||
|
||
self.client.force_login(self.admin) | ||
post_data = { | ||
"workflowid": str(self.history.workflowid), # required | ||
"workflowname": 'test-name', | ||
|
@@ -128,6 +127,18 @@ def test_post_workflow_history(self): | |
}, | ||
} | ||
|
||
# Non-superuser cannot update someone else's workflow. | ||
self.client.force_login(self.editor) | ||
response = self.client.post( | ||
reverse("workflow_history", kwargs={"workflowid": str(self.history.workflowid)}), | ||
post_data, | ||
content_type="application/json", | ||
) | ||
|
||
self.assertEqual(response.status_code, 403) | ||
self.assertIn(b"Forbidden", response.content) | ||
|
||
self.client.force_login(self.admin) | ||
response = self.client.post( | ||
reverse("workflow_history", kwargs={"workflowid": str(self.history.workflowid)}), | ||
post_data, | ||
|