Skip to content

Testing

Mathias Stuhlmacher edited this page Dec 17, 2021 · 2 revisions

Testing and implemented GitHub actions

Django Tests

  • Action:
    • .github/workflows/django_tests.yml

This action runs the Python standard tests and uploads the result to Codecov.

Manual testing

To test DFIRTrack you have the following possibilities:

  • using Django's test-execution framework
  • test the code coverage using coverage

Prerequisites

Make sure to install the requirements:

$ git clone https://github.com/stuhli/dfirtrack.git ~/dfirtrack
$ virtualenv -p /usr/bin/python3 ~/dfirtrack/venv
$ source ~/dfirtrack/venv/bin/activate
$ pip3 install -r ~/dfirtrack/requirements.txt
(venv) $ cd ~/dfirtrack

Testing with Django

Start the tests and wait for the results:

(venv) $ python3 manage.py test --settings=dfirtrack.test_settings

Testing with coverage

Start the tests and monitor the results:

(venv) $ coverage run manage.py test --settings=dfirtrack.test_settings

Check the code coverage:

(venv) $ coverage report -m

Lint Python

  • Action:
    • .github/workflows/lint_python.yml

This action performs various lint actions on the code.

Manual testing

Make sure to install the requirements:

$ source ~/dfirtrack/venv/bin/activate
$ pip3 install -r ~/dfirtrack/lint_requirements.txt
(venv) $ cd ~/dfirtrack

Most of the time your code will fail on black. To avoid this from the outset, it is best to do this locally.

(venv) $ black --skip-string-normalization .

Second most common problem that will occur is the sorting of imports. This can also be tested locally. It is important to know that isort behaves differently depending on the path from which you start the test. It is best to always run it from the root directory of the project. This ensures that the results are the same as in the github action.

(venv) $ isort --profile black .

Lint Ansible

  • Action:
    • .github/workflows/lint_ansible.yml

This action performs various lint actions on the Ansible playbook and role.

Docker publish

  • Action:
    • .github/workflows/docker_publish.yml

This action creates current images based on the master and develop branch and uploads them to Docker.