Skip to content

Latest commit

 

History

History
128 lines (91 loc) · 3.31 KB

File metadata and controls

128 lines (91 loc) · 3.31 KB

Development Environment - Local

Introduction

This document provides guidance on setting up an IPManager Django development environment on a local workstation.

Prerequisites

  • Python 3.12

  • Install libxmlsec1. This is required for the SAML authentication using djangosaml2.

    On Mac, it is available via Homebrew:

    brew install xmlsec1

    On Debian or Ubuntu Linux, it is available via apt:

    sudo apt-get install xmlsec1
  • Update the /etc/hosts file to add:

    127.0.0.1 ipmanager-local

Application Setup

  1. Clone ipmanager-django from GitHub:

    git clone git@github.com:umd-lib/ipmanager-django.git
    cd ipmanager-django
  2. Set up the Python virtual environment, and install the dependencies

    python -m venv .venv --prompt "ipmanager-django-py$(cat .python-version)"
    source .venv/bin/activate
    pip install --upgrade pip
    pip install -e .
  3. Retrieve the SAML Key and Cert information. The cert file can be accessed through Box. Alternatively, you can pull the key and cert from the Kubernetes cluster into files using the following commands:

    # Key File
    kubectl -n test get secret ipmanager-common-env-secret -o jsonpath='{.data.SAML_SP_PRIVATE_KEY}' | base64 --decode > ipmanager-key.key
    
    # Certificate File
    kubectl -n test get secret ipmanager-common-env-secret -o jsonpath='{.data.SAML_SP_CERTIFICATE}' | base64 --decode > ipmanager-cert.crt

    ℹ️ Note: These files can be placed in a directory outside the project, if desired - just change the location of the output file.

  4. Copy the "env_example" file to ".env":

    cp env_example .env

    and update the following variables with the appropriate values:

    • SAML_KEY_FILE - relative (or absolute) file path to the ipmanager-key.key file
    • SAML_CERT_FILE - relative (or absolute) file path to the ipmanager-cert.crt file
    • SECRET_KEY - Either comment out (a random key will be automatically generated), or populate with anything with sufficient randomness, i.e. uuidgen | shasum -a 256 | cut -c-64
    • XMLSEC1_PATH - The full file path to the "xmlsec1" binary, (usually findable by running which xmlsec1)
  5. Initialize the database:

    ./src/manage.py migrate
  6. Run the application. The default port is 3001; this is also the port that is registered with DIT to allow SAML authentication to work from local:

    ./src/manage.py runserver

    The application will be running at http://ipmanager-local:3001/

    To change the port, provide an argument to runserver, e.g.:

    ./src/manage.py runserver 5555

Tests

To install test dependencies, install the test extra:

pip install -e '.[test]'

This project uses pytest in conjunction with the pytest-django plugin to run its tests. To run the test suite:

pytest

To run with coverage information:

pytest --cov src --cov-report term-missing