diff --git a/prepare_server_cypress.sh b/prepare_server_cypress.sh new file mode 100755 index 00000000..023ac515 --- /dev/null +++ b/prepare_server_cypress.sh @@ -0,0 +1,102 @@ +#!/bin/bash + +if [ -z "$CI" ]; +then + # kill all subprocess on exit + trap "exit" INT TERM ERR + trap "kill 0" EXIT +else echo "CI is set to $CI"; +fi + +# script should fail when any process returns non zero code +set -ev + +# handle arguments +SKIP_SETUP=false +START_BACKGROUND=false +PROXY_VUE=false + +for i in "$@" +do +case $i in + --start-background) + START_BACKGROUND=true + shift # past argument + ;; + --skip-setup) + SKIP_SETUP=true + shift # past argument with no value + ;; + --proxy-vue) + PROXY_VUE=true + shift # past argument with no value + ;; + *) + # unknown option + ;; +esac +done + +echo "SKIP_SETUP = ${SKIP_SETUP}" + +DJANGO_SETTINGS_MODULE=config.settings.test_cypress +CYPRESS_DB=vbv_lernwelt_cypress + +if [ "$SKIP_SETUP" = false ]; then + if [ -z "$PG_PORT" ]; then # if the port is set in the env, use it + DB_PORT=""; + else + DB_PORT="-p $PG_PORT"; + fi + if [ -z "$PG_USER" ]; then # if the user is set in the env, use it + DB_USER=""; + else + DB_USER="-U $PG_USER"; + fi + echo "psql -h localhost $DB_PORT $DB_USER -c 'drop database if exists $CYPRESS_DB;'" + # create database + psql -h localhost $DB_PORT $DB_USER -c "drop database if exists $CYPRESS_DB;" + psql -h localhost $DB_PORT $DB_USER -c "create database $CYPRESS_DB;" + + # reset data + # python3 src/manage.py randomdata --settings="$DJANGO_SETTINGS_MODULE" + python3 server/manage.py createcachetable --settings="$DJANGO_SETTINGS_MODULE" + python3 server/manage.py migrate --settings="$DJANGO_SETTINGS_MODULE" + + # make django translations + (cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE") + +# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set API_WFM_BACKEND_ENABLED true +# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set TIBCO_SOAP_CUSTOMER_INTERACTION_CLIENT_ENABLED true +# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set API_EMAIL_MESSAGING_ENABLED true +# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set C4_NOTIFICATIONS_ENABLED true +# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set SFTP_POSTFINANCE_ENABLED true +# python3 src/manage.py constance --settings="$DJANGO_SETTINGS_MODULE" set EASY_INSURANCE_AGENT_CAN_CREATE true +else + echo "else" +# python3 src/manage.py recreate_customer_data_for_integration_tests --settings="$DJANGO_SETTINGS_MODULE" +fi + +if [ "$PROXY_VUE" = true ]; then + export DJANGO_VUE_LANDINGPAGE_PROXY=http://localhost:8080/ +fi + +# install cypress here to avoid problems with `npm install` on the iesc servers +CYPRESS_INSTALLED=0 +#npx --no-install cypress --version || CYPRESS_INSTALLED=$? +if [ $CYPRESS_INSTALLED -ne 0 ]; then + echo "install cypress" +# npm install cypress@5.6.0 @testing-library/cypress@7.0.2 --no-save +fi + + +# the sftp server is currently not needed +# rm -rf test_sftp +# mkdir -p test_sftp +# (cd test_sftp && mkdir -p outbox && sftpserver -p 3373 -k ../src/myservice/apps/export/sftp_test_key.pem -l INFO &) + +if [ "$START_BACKGROUND" = true ]; then + python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE" > /dev/null & +else + python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE" +fi diff --git a/server/config/settings/test_cypress.py b/server/config/settings/test_cypress.py new file mode 100644 index 00000000..076e11dd --- /dev/null +++ b/server/config/settings/test_cypress.py @@ -0,0 +1,45 @@ +# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position +import getpass +import os + +from .base import * # noqa +from .base import env + +# GENERAL +# ------------------------------------------------------------------------------ +# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key +SECRET_KEY = env( + "VBV_DJANGO_SECRET_KEY", + default="1LhwZ0DvP4cGBgbBdCfaBQV7eiaOc4jWKdzO9WEXLFT7AaqBN6jqd0uyaZeAZ19K", +) + +# EMAIL +# ------------------------------------------------------------------------------ +# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend +EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" + +CYPRESS_TEST = True +DEBUG = True + + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql_psycopg2", + "NAME": "vbv_lernwelt_cypress", + "USER": os.environ.get("PG_USER", getpass.getuser()), + "PASSWORD": os.environ.get("PG_PASSWORD"), + "HOST": "localhost", + "PORT": os.environ.get("PG_PORT", ""), + } +} + +# Your stuff... +# ------------------------------------------------------------------------------ +# REST_FRAMEWORK['DEFAULT_THROTTLE_RATES'] = { +# 'anon': '100/day', +# 'hour-throttle': '40000/hour', +# 'day-throttle': '2000000/day', +# 'easy-throttle': '50000/day', +# } +# +# RATELIMIT_ENABLE = False diff --git a/server/vbv_lernwelt/core/templates/core/login.html b/server/vbv_lernwelt/core/templates/core/login.html index 1bd79dcd..1120c217 100644 --- a/server/vbv_lernwelt/core/templates/core/login.html +++ b/server/vbv_lernwelt/core/templates/core/login.html @@ -1,8 +1,34 @@ -