Skip to content

Commit

Permalink
Merge pull request #700 from dfir-iris/dashobard_user_tasks_list_not_…
Browse files Browse the repository at this point in the history
…working

Fixed regression on GET /user/tasks/list
  • Loading branch information
whikernel authored Jan 24, 2025
2 parents e1911d9 + dff9808 commit 44bce5e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
13 changes: 12 additions & 1 deletion source/app/datamgmt/dashboard/dashboard_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,18 @@ def list_user_reviews():


def list_user_tasks():
ct = CaseTasks.query.join(
ct = CaseTasks.query.with_entities(
CaseTasks.id.label("task_id"),
CaseTasks.task_title,
CaseTasks.task_description,
CaseTasks.task_last_update,
CaseTasks.task_tags,
Cases.name.label('task_case'),
CaseTasks.task_case_id.label('case_id'),
CaseTasks.task_status_id,
TaskStatus.status_name,
TaskStatus.status_bscolor
).join(
CaseTasks.case
).order_by(
desc(TaskStatus.status_name)
Expand Down
18 changes: 18 additions & 0 deletions tests/tests_rest_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ def test_delete_task_with_missing_task_identifier_should_return_404(self):
test = self._subject.delete(f'/api/v2/cases/{case_identifier}/tasks/{_IDENTIFIER_FOR_NONEXISTENT_OBJECT}')
self.assertEqual(404, test.status_code)

def test_get_user_task_should_not_fail(self):
case_identifier = self._subject.create_dummy_case()
user = self._subject.create_dummy_user()
body = {'task_assignees_id': [user.get_identifier()], 'task_description': '', 'task_status_id': 1, 'task_tags': '', 'task_title': 'dummy title',
'custom_attributes': {}}
self._subject.create(f'/api/v2/cases/{case_identifier}/tasks', body)
response = user.get('/user/tasks/list')
self.assertEqual(200, response.status_code)

def test_get_user_task_should_contain_task_case_field(self):
case_identifier = self._subject.create_dummy_case()
user = self._subject.create_dummy_user()
body = {'task_assignees_id': [user.get_identifier()], 'task_description': '', 'task_status_id': 1, 'task_tags': '', 'task_title': 'dummy title',
'custom_attributes': {}}
self._subject.create(f'/api/v2/cases/{case_identifier}/tasks', body)
response = user.get('/user/tasks/list').json()
self.assertEqual(f'#{case_identifier} - case name', response['data']['tasks'][0]['task_case'])

def test_update_task_should_not_fail(self):
case_identifier = self._subject.create_dummy_case()
body = {'task_assignees_id': [], 'task_status_id': 1, 'task_title': 'dummy title'}
Expand Down

0 comments on commit 44bce5e

Please sign in to comment.