X-Git-Url: https://git.ucc.asn.au/?p=tpg%2Fopendispense2.git;a=blobdiff_plain;f=tests%2F_common.sh;fp=tests%2F_common.sh;h=e43a2c8c1611e3558d87f3a6bc2127ae4f9a591d;hp=04d165702941ed14a410db26ca76ea1a04ab7276;hb=1383ba77ec33e94ab104aa2d6bc0c27ec8931727;hpb=3c03884844384020aac5a789aa36a1453bf57b78 diff --git a/tests/_common.sh b/tests/_common.sh index 04d1657..e43a2c8 100644 --- a/tests/_common.sh +++ b/tests/_common.sh @@ -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);"