/nl-kat-rocky

Repo nl-kat-rocky for minvws

Primary LanguagePythonEuropean Union Public License 1.2EUPL-1.2

Rocky (nl-kat)

Rocky is part of the openKAT project, made with Django.
See nl-kat for more details about openKAT.

Stack

As said, Django is the framework for this project.
To comply to government standards, use Manon for style and accessibility.
Yarn is used as package manager and ParcelJS is used as bundler to compile the frontend (CSS and Javascript). For browsertests we are using Cypress. You can find the Manon repository here: https://github.com/minvws/nl-rdo-rijksoverheid-ui

Running Rocky

Containerized

To run rocky from the docker container, from the parent directory nl-kat, just run:

$ make kat

and continue reading this document at "First run".

Locally

To run rocky locally, follow these steps.

Installation

Yarn is used to bundle CSS and Javascript. You can build Rocky locally using:

$ make build

This will set up Django and compile the frontend.

Running

You can run Rocky using:

$ make run

First run

After running the first time, visit localhost:8000 in your browser. Log in with credentials: admin / admin

You will be prompted to create secure your account with a One Time Password, so get your authenticator ready.

Testing

To run all tests, run:

$ make test

But first you will need to setup Cypress.

Setting up Cypress

Cypress is installed in a separate directory roeltje. You will need to run the django command setup_test_users to create users and credentials used in cypress
see: cypress.json.

$ python manage.py setup_test_users
$ yarn --cwd roeltje
$ yarn --cwd roeltje cypress open

add to 1Password:

otpauth://totp/localhost%3A8000%3A%20admin?secret=TAAVFPQD3C3NLRSZQBD3CJ7ZUVDJXDS5&digits=6&issuer=localhost%3A8000

So eventually your cypress.json shapes like this:

{
  "viewportWidth": 1280,
  "viewportHeight": 1024,
  "env": {
    "base_url": "http://localhost:8000/",
    "client_user": "admin",
    "client_pass": "admin",
    "client_otp_secret": "TAAVFPQD3C3NLRSZQBD3CJ7ZUVDJXDS5",
  }
}

!! WARNING !! DON'T DO THIS IN ANY PUBLIC FACING INSTALL!

Database

To connect to the PostgreSQL database, set the following environment variables (e.g. "localhost", "5432" etc.):

ROCKY_DB_HOST=
ROCKY_DB_PORT=
ROCKY_DB=
ROCKY_DB_USER=
ROCKY_DB_PASSWORD=

So... How does it flow?

Perform scan (run boefje)

sequenceDiagram
    participant r as Rocky
    participant c as Celery
    participant q as RabbitMQ
    participant b as Boefje
    participant n as Normalizer
    participant o as Octopoes
    r->>+c: Start scan
    c-->>r: task.status = busy
    c->>q: Produce message
    q->>b: Consume message
    q->>n: Consume message
    n->>o: Add object(s)
    c->>-r: task.status = done