Skip to content

Commit

Permalink
Added first implementation of /api/v2/cases/{case_identifier}/assets
Browse files Browse the repository at this point in the history
  • Loading branch information
c8y3 committed Feb 4, 2025
1 parent 959d583 commit 190fd41
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/app/blueprints/rest/case/case_assets_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def case_filter_assets(caseid):

return response_success("", data=ret)


@case_assets_rest_blueprint.route('/case/assets/list', methods=['GET'])
@ac_requires_case_identifier(CaseAccessLevel.read_only, CaseAccessLevel.full_access)
def case_list_assets(caseid):
Expand Down
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/v2/cases/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


# TODO put this endpoint back once it adheres to the conventions (return value for paginated data: field assets should be field data, spurious field state, missing total, last_page, current_page and next_page)
#@case_assets_blueprint.get('')
@case_assets_blueprint.get('')
@ac_api_requires()
def case_list_assets(case_identifier):

Expand Down
6 changes: 5 additions & 1 deletion tests/tests_rest_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def test_update_asset_should_allow_to_update_analysis_status(self):
{'asset_type_id': 1, 'asset_name': 'admin_laptop_test', 'analysis_status_id': 2}).json()
self.assertEqual(2, response['analysis_status_id'])


def test_delete_asset_should_return_204(self):
case_identifier = self._subject.create_dummy_case()
body = {'asset_type_id': 1, 'asset_name': 'admin_laptop_test'}
Expand Down Expand Up @@ -195,3 +194,8 @@ def test_user_should_not_change_comment_of_others(self):
# Try to update the comment from user 2
response = user2.create(f'/case/assets/{asset_identifier}/comments/{comment_identifier}/edit?cid={case_identifier}', {'comment_text': 'updated comment'})
self.assertEqual(400, response.status_code)

def test_get_assets_should_not_fail(self):
case_identifier = self._subject.create_dummy_case()
response = self._subject.get(f'/api/v2/cases/{case_identifier}/assets')
self.assertEqual(200, response.status_code)

0 comments on commit 190fd41

Please sign in to comment.