Skip to content

Latest commit

 

History

History
132 lines (88 loc) · 2.81 KB

README.md

File metadata and controls

132 lines (88 loc) · 2.81 KB

Outlines

All the versions mentioned are the recommended ones.

Setup development environment

Setup development environment of openxeco-core

This project is dependent of the openxeco-core project. It uses the openXeco API

To know how to deploy openXeco, please see:

https://github.com/CybersecurityLuxembourg/openxeco-core/blob/main/README.md#for-development

Edit the environment variables

The project is using the python-dotenv package so you can copy and adjust the local file openxeco-eccc-middleware/oxe-api/.env.example with such content:

.env.example

ENVIRONMENT=dev

JWT_SECRET_KEY=my_secret_developer_key

OPENXECO_API_ENDPOINT=https://api.example.com/

ECCC_API_ENDPOINT=https://eccc.example.com/
ECCC_API_KEY=EXAMPLE_OF_KEY

Install Python 3.8.6

Python 3.8.6

Create Python virtual environment and install dependencies

For Linux:

$ git clone https://github.com/CybersecurityLuxembourg/openxeco-eccc-middleware.git
$ cd openxeco-eccc-middleware/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-eccc-middleware\oxe-api
> python -m venv venv
> .\venv\Scripts\activate
> pip install -U pip setuptools
> pip install -U -r requirements.txt

Run the project

You have to make sure that the python environment is active, to double check:

$ echo ${VIRTUAL_ENV}
/home/luser/openxeco-eccc-middleware/oxe-api/venv

If not, repeat the steps above.

Copy the config and run the app

$ python app.py

Test and audit the code

Run the unittests

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

Run the code analysers

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/