All the versions mentioned are the recommended ones.
# Change 3306 to 3307 if another local MariaDB is installed. Make sure to adapt config files.
$ docker run -d \
--network openxeco \
--network-alias mariadb \
-p 3306:3306 \
-e MARIADB_ROOT_PASSWORD=E4syPass \
mariadb:10.7.3
The project is using the python-dotenv package so you can copy and adjust the local file openxeco-core/oxe-api/.env.example with such content:
.env.example
ENVIRONMENT=dev
JWT_SECRET_KEY=my_secret_developer_key
DB_HOSTNAME=127.0.0.1
DB_PORT=3306
DB_NAME=OPENXECO
DB_USERNAME=root
DB_PASSWORD=E4syPass
MAIL_SERVER=127.0.0.1
MAIL_PORT=1025
MAIL_USE_TLS=False
MAIL_USE_SSL=False
[email protected]
IMAGE_FOLDER=/var/lib/oxe-api/image_folder
DOCUMENT_FOLDER=/var/lib/oxe-api/document_folder
[email protected]
For Linux:
$ git clone https://github.com/CybersecurityLuxembourg/openxeco-core.git
$ cd openxeco-core/oxe-api
$ cp .env.example .env # Edit accordingly
$ sudo apt install python3-venv -y
$ python3 -m venv venv
$ source ./venv/bin/activate
$ pip install -U pip setuptools
$ pip install -U -r requirements.txt
For Windows
> cd %USERPROFILE%\openxeco-core\oxe-api
> python -m venv venv
> .\venv\Scripts\activate
> pip install -U pip setuptools
> pip install -U -r requirements.txt
You have to make sure that the python environment is active, to double check:
$ echo ${VIRTUAL_ENV}
/home/luser/openxeco-core/oxe-api/venv
If not, repeat the steps above.
$ python app.py
Some resources of the API requires a SMTP server, you can simulate in local environment with the following command:
$ python -m smtpd -n -c DebuggingServer localhost:1025
Alternatively you can use a docker container for the fake SMTP server.
$ docker run -d \
--network openxeco \
--network-alias smtp \
-p 1025:1025 \
-p 1080:1080 \
reachfive/fake-smtp-server
The mails are retrievable via http://localhost:1080.
To run a single test
$ python -m unittest test/resource/entity/test_get_entity.py
To run the whole set use the command below. (Here --buffer or -b is used to discard the output on a successful test run.)
$ python -m unittest --buffer
Run the test coverage report (with the venv activated).
$ coverage run --source=resource,utils,db,decorator -m unittest discover && coverage report
Run the test coverage report (with the venv activated) for a specific package.
$ coverage run --source=resource/user -m unittest discover test/resource/user/ && coverage report
Run the test coverage report and generate in HTML (with the venv activated).
$ coverage run --source=resource,utils,db,decorator -m unittest discover && coverage html
npm is required
$ sudo apt install npm -y
To run the PyCQA/prospector use the command below.
$ npm install prospector
$ prospector -i venv/ --no-autodetect
To run the PyCQA/bandit use the command below.
$ sudo apt install bandit
$ bandit -r . -x ./test/,./venv/
The database structure is automatically created/upgraded when starting the API.
For further information about the structure management, please see the documentation of Flask-Migrate.