Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

SURFscz/eduteam-account-registry

Repository files navigation

eduTEAMS Account Registry

Build Status codecov

  • Python 3.6.x
  • MySQL v8.x
  • Yarn 1.x
  • node

Create a virtual environment and install the required python packages:

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r ./server/requirements/test.txt

Connect to your local mysql database: mysql -uroot and create the EAR database and user:

DROP DATABASE IF EXISTS ear;
CREATE DATABASE ear DEFAULT CHARACTER SET utf8;
DROP DATABASE IF EXISTS ear_test;
CREATE DATABASE ear_test DEFAULT CHARACTER SET utf8;
CREATE USER 'ear'@'localhost' IDENTIFIED BY 'ear';
GRANT ALL PRIVILEGES ON ear.* TO 'ear'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON ear_test.* TO 'ear'@'localhost' WITH GRANT OPTION;

Ensure MySQL is running and run the Python server with the correct local environment setting: <<<<<<< HEAD

PROFILE=local CONFIG=config/test_config.yml OPEN_MAIL_IN_BROWSER=1 python -m server
=======
```sh
PROFILE=local CONFIG=config/test_config.yml python -m server
>>>>>>> master

With TESTING=1 no mails will be send. If you do want to validate the mails you can run a fake smtp server with:

python -m smtpd -n -c DebuggingServer localhost:1025

If you want the emails to be opened in the browser when developing add the OPEN_MAIL_IN_BROWSER=1 to your environment

First install all dependencies with:

cd client
yarn install

The GUI can be started with:

cd client
yarn start

To create a GUI production build:

yarn build

To analyze the bundle:

yarn analyze

Point your browser to http://localhost:5000/api/users/login?redirect_url=http://www.example.com

To run all Python tests and validate syntax / formatting:

source .venv/bin/activate
pytest server/test
flake8 ./server/

To generate coverage reports:

pytest --cov=server --cov-report html:htmlcov server/test
open htmlcov/index.html

To run all JavaScript tests:

cd client
yarn test

Or to run all the tests and do not watch - like CI:

cd client
CI=true yarn test

With the environment variable CONFIG=config/test_config.yml the test database is used. After you ran one or all of the tests the database is left with the test data seed.

To run AUR in production, we suggest using an Apache server; a single configuration can be used to both serve the static client scripts, and serve the API (server) via wsgi. Similar setups are probably possible using nginx etc.

In the explaination below, we assume you are deploying to a server on http://uar.example.org/

  1. Create a client production build as explained above.
  2. Create a Python virtualenv as explained above,
  3. Set up your config file server/config/config.yml. You can base it on the test_config.yml file in the same directory, but please change at least the following:
    base_url: http://uar.example.org/
    login_url: http://uar.example.org/api/user/login
  4. Create a log dir in which the wsgi server user (configurable in the WSGI config below, but www-data by default on Debian/Ubuntu) can write:
    install -d -m1775 -g www-data log
  5. Copy the wsgi template examples/uar-api.wsgi.template to ./uar-api.wgi and edit the source_dir variable to match your setup.
  6. Install Python (version 3) WSGI support for Apache. In Debian or Ubuntu, this is achieved by installing the package libapache2-mod-wsgi-py3.
  7. Copy the Apache config template to your Apache config directory (/etc/apache2/sites-enabled on Debian/Ubuntu) and adjust it to your setup. At the very least, replace /YOUR/VENV/DIR by the directory of the Virtualenv you created at step 2, and replace /YOUR/SOURCE/DIR by the directory in which you have checked our this repository.
  8. Restart Apache.
  9. Open http://uar.example.org/api/users/login?redirect_url=http://returnurl.example.com in your browser to start the registration process.