- 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
. _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"
EOF
echo "# AUTOGENERATED Test ${TESTNAME}" > ${BASEDIR}cfg_items.conf
+echo "pseudo 0 0 Test item" >> ${BASEDIR}cfg_items.conf
LOG() {
echo "TEST ${TESTNAME}: "$*
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);"