Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ jobs:
docker load --input ${{ runner.temp }}/iriswebapp_app.tar
- name: Check out iris
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ui/package-lock.json
- name: Build ui to be mounted in development docker
working-directory: ui
run: |
npm ci
npm run build
- name: Start development server
run: |
# Even though, we use --env-file option when running docker compose, this is still necessary, because the compose has a env_file attribute :(
Expand Down
4 changes: 1 addition & 3 deletions source/app/schema/marshables.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ def store_icon(file):

try:
store_fullpath = os.path.join(app.config['ASSET_STORE_PATH'], filename)
show_fullpath = os.path.join(app.config['APP_PATH'], 'app',
app.config['ASSET_SHOW_PATH'].strip(os.path.sep),
filename)
show_fullpath = os.path.join(app.config['APP_PATH'], app.config['ASSET_SHOW_PATH'].strip(os.path.sep), filename)
file.save(store_fullpath)
os.symlink(store_fullpath, show_fullpath)

Expand Down
Binary file added tests/data/img/desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def delete(self, path):
def post_multipart_encoded_file(self, path, data, file_path):
return self._api.post_multipart_encoded_file(path, data, file_path)

def post_multipart_encoded_files(self, path, data, files):
return self._api.post_multipart_encoded_files(path, data, files)

def _create_user(self, user_name):
body = {
'user_name': user_name,
Expand Down
8 changes: 8 additions & 0 deletions tests/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,11 @@ def post_multipart_encoded_file(self, path, data, file_path):
response_as_string = self._convert_response_to_string(response)
print(f'POST {url} {data} {file_path} => {response_as_string}')
return response

def post_multipart_encoded_files(self, path, data, files):
headers = {'Authorization': f'Bearer {self._api_key}'}
url = self._build_url(path)
response = requests.post(url, headers=headers, data=data, files=files)
response_as_string = self._convert_response_to_string(response)
print(f'POST {url} {data} {list(files)} => {response_as_string}')
return response
39 changes: 39 additions & 0 deletions tests/tests_rest_asset_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# IRIS Source Code
# Copyright (C) 2023 - DFIR-IRIS
# [email protected]
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from unittest import TestCase
from iris import Iris

_FIRST_ASSET_TYPE_IDENTIFIER = 1


class TestsRestAssetTypes(TestCase):

def setUp(self) -> None:
self._subject = Iris()

def tearDown(self):
self._subject.clear_database()

def test_update_asset_type_should_return_200(self):
url = f'/manage/asset-type/update/{_FIRST_ASSET_TYPE_IDENTIFIER}'
data = {'asset_name': 'Account', 'asset_description': 'Generic Account'}
with open('data/img/desktop.png', 'rb') as file_not_compromised:
files = {'asset_icon_not_compromised': file_not_compromised, 'asset_icon_compromised': ('', '')}
response = self._subject.post_multipart_encoded_files(url, data, files)
self.assertEqual(200, response.status_code)