Skip to content
Snippets Groups Projects
Commit 1383ba77 authored by John Hodge's avatar John Hodge
Browse files

Tests - Tweaking

parent 3c038848
No related merge requests found
Pipeline #396 failed with stages
in 1 minute and 6 seconds
......@@ -30,4 +30,4 @@ test:
- apt update && apt -y install libncurses-dev libmodbus-dev libsqlite3-dev libident netcat sqlite3
- useradd testuser && chown -R testuser .
script:
- cd tests && su -l -c './TEST_basic.sh' testuser
- cd tests && su -c './TEST_basic.sh' testuser
......@@ -4,21 +4,8 @@ TESTNAME=basic
. _common.sh
# (CI runs as root, and root is auto-added by databse creation)
if [[ "x$USER" != "xroot" ]]; then
# Ensure that the databse doesn't already contain the current user
# - 1. Protects against running the test against the production database
# - 2. Allows adding the current user as an admin
if $DISPENSE acct "$USER"; then
FAIL "Database contains '$USER'"
fi
# Add the current user as an admin
sqlite3 "${BASEDIR}cokebank.db" "INSERT INTO accounts (acct_name,acct_is_admin,acct_uid) VALUES ('${USER}',1,1);"
else
if $DISPENSE acct accmurph; then
FAIL "Database contains 'accmurph' (running as root, might be using prodution)"
fi
fi
TRY_COMMAND "$DISPENSE acct ${USER}"
TRY_COMMAND "$DISPENSE pseudo:0"
# Try to add a new user
TRY_COMMAND "$DISPENSE user add unittest_user0"
......
......@@ -25,6 +25,7 @@ coke_dummy_mode yes
EOF
echo "# AUTOGENERATED Test ${TESTNAME}" > ${BASEDIR}cfg_items.conf
echo "pseudo 0 0 Test item" >> ${BASEDIR}cfg_items.conf
LOG() {
echo "TEST ${TESTNAME}: "$*
......@@ -65,3 +66,15 @@ if ! (echo "" | nc localhost ${PORT}); then
cat ${BASEDIR}server.log
exit 1
fi
if [[ "x$USER" == "xroot" ]]; then
FAIL "Running as root"
fi
# Ensure that the database doesn't already contain the current user
# - 1. Protects against running the test against the production database
# - 2. Allows adding the current user as an admin
if $DISPENSE acct "${USER}" 2> /dev/null; then
FAIL "Database contains '$USER', are you running on production?"
fi
# Add the current user as an admin
sqlite3 "${BASEDIR}cokebank.db" "INSERT INTO accounts (acct_name,acct_is_admin,acct_uid) VALUES ('${USER}',1,1);"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment