Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions orbit/test-style.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
#!/bin/bash

FLAKE8_FLAGS=""

while getopts "v" FLAG; do
case $FLAG in
v)
FLAKE8_FLAGS="$FLAKE8_FLAGS "
;;
esac
done

SOURCES=""
scan() {
echo "[SCAN] ${1}"
flake8 ${FLAKE8_FLAGS} ${1}
RES=$?
if test "$RES" -ne "0"
then
exit 1
fi
}
scan() { echo "[SCAN] ${1}" ; flake8 "${1}" || exit 1 ; }

scan radius.py
scan config.py
Expand Down
54 changes: 34 additions & 20 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
#!/bin/bash
#
#!/usr/bin/env bash

# Testing script for singularity and orbit

# This line:
# - aborts the script after any pipeline returns nonzero (e)
# - shows all commands as they are run (x)
# - sets any dereference of an unset variable to trigger an error (u)
# - causes the return value of a pipeline to be the nonzero return value
# of the furthest right failing command or zero if no command failed (o pipefail)
set -exuo pipefail

require() { command -v "$1" || { echo "error: $1 command required yet absent" ; exit 1 ; } ; }
require curl
require flake8
require chcon
require podman
require shellcheck

# Reset the tests and mail directories
rm -rf test email/logs/* email/mail/*
sudo rm -rf test email/logs/* email/mail/*
mkdir -p test

# This is a temporary workaround until we properly implement volumes
Expand All @@ -19,20 +32,17 @@ PORT=${PORT:-443}
POP_PORT=${POP_PORT:-995}
SMTP_PORT=${SMTP_PORT:-465}
EMAIL_HOSTNAME="kdlp.underground.software"
export DOCKER=${DOCKER:-"sudo podman"}
export CONTAINER=${CONTAINER:-"singularity_orbit_1"}

# NOTE: don't set DEVEL and STAGING at the same time

if [ ! -z "$DEVEL" ]; then
if [ -n "$DEVEL" ]; then
PORT=1443
POP_PORT=1995
SMTP_PORT=1465
EMAIL_HOSTNAME="localhost"
export DOCKER="podman"
fi

if [ ! -z "$STAGING" ]; then
if [ -n "$STAGING" ]; then
EMAIL_HOSTNAME="dev.underground.software"
fi

Expand Down Expand Up @@ -71,7 +81,7 @@ curl --url "https://localhost:$PORT/register" \
| tee test/register_fail_wrong \
| grep "msg = no such student"

# Check that registration suceeds with correct student id
# Check that registration succeeds with correct student id
curl --url "https://localhost:$PORT/register" \
--verbose \
--insecure \
Expand Down Expand Up @@ -121,7 +131,8 @@ curl --url "pop3s://localhost:$POP_PORT" \
| diff <(printf '\r\n') /dev/stdin

CR=$(printf "\r")
# Check that the user can send a message to the sever
# Check that the user can send a message to the server
(
Comment thread
theyoyojo marked this conversation as resolved.
curl --url "smtps://localhost:$SMTP_PORT" \
--verbose \
--insecure \
Expand All @@ -130,34 +141,37 @@ curl --url "smtps://localhost:$SMTP_PORT" \
--mail-from "user@$EMAIL_HOSTNAME" \
--mail-rcpt "other@$EMAIL_HOSTNAME" \
--upload-file - \
--user 'user:pass' \
> test/smtp_send_email <<EOF
--user 'user:pass' <<EOF
Subject: Message Subject$CR
$CR
To whom it may concern,$CR
$CR
Bottom text$CR
EOF
) | tee test/smtp_send_email \
| diff <(printf "") /dev/stdin

# Check that the user can get the most recent message sent to the server
curl --url "pop3s://localhost:$POP_PORT/1" \
--verbose \
--insecure \
--fail \
--no-progress-meter \
--user user:pass
> test/pop_get_message
test_pop_get_message=$?
--user user:pass \
| tee test/pop_get_message \
| grep "Bottom text"

# Check that we can delete a user
orbit/warpdrive.sh \
-u user -w \
> test/delete_user
| tee test/delete_user \
| grep "user"

# Check for shell script styyle compliance with shellcheck
shellcheck test.sh
shellcheck orbit/test-style.sh

# Check style compliance
python -m venv orbit-dev
source orbit-dev/bin/activate
pip install -r orbit/dev-requirements.txt
# Check python style compliance with flake8
pushd orbit
./test-style.sh
popd
Expand Down