2019-04-19 15:31:01 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-06-23 14:35:50 +00:00
|
|
|
#### $$VERSION$$ v0.98-dev-70-g694ee61
|
2019-04-19 15:31:01 +00:00
|
|
|
|
2019-04-21 09:34:17 +00:00
|
|
|
# include common functions and definitions
|
|
|
|
# shellcheck source=test/ALL-tests.inc.sh
|
|
|
|
source "./ALL-tests.inc.sh"
|
2019-04-20 19:09:36 +00:00
|
|
|
|
2020-06-01 11:44:30 +00:00
|
|
|
TESTFILES="${TOKENFILE} ${ACLFILE} ${COUNTFILE} ${BLOCKEDFILE} ${ADMINFILE}"
|
2019-04-19 17:24:30 +00:00
|
|
|
|
2019-04-19 15:31:01 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# run bashbot first time with init
|
2019-04-20 19:09:36 +00:00
|
|
|
"${TESTDIR}/bashbot.sh" init >"${LOGFILE}" <<EOF
|
2019-04-19 17:24:30 +00:00
|
|
|
$TESTTOKEN
|
2019-04-19 15:31:01 +00:00
|
|
|
nobody
|
|
|
|
botadmin
|
|
|
|
EOF
|
2019-04-21 09:34:17 +00:00
|
|
|
echo "${SUCCESS}"
|
2019-04-19 17:24:30 +00:00
|
|
|
|
2020-06-23 14:35:50 +00:00
|
|
|
# compare files with reference files
|
2019-04-20 19:31:05 +00:00
|
|
|
echo "Check new files after init ..."
|
|
|
|
export FAIL="0"
|
2019-04-20 19:09:36 +00:00
|
|
|
for file in ${TESTFILES}
|
2019-04-19 17:24:30 +00:00
|
|
|
do
|
2019-04-20 19:09:36 +00:00
|
|
|
ls -d "${TESTDIR}/${file}" >>"${LOGFILE}"
|
2019-05-16 09:23:27 +00:00
|
|
|
diff -q "${TESTDIR}/${file}" "${REFDIR}/${file}" >>"${LOGFILE}" || { echo "${NOSUCCESS} Fail diff ${file}!"; FAIL="1"; }
|
2019-04-19 17:24:30 +00:00
|
|
|
done
|
2019-04-20 19:31:05 +00:00
|
|
|
[ "${FAIL}" != "0" ] && exit "${FAIL}"
|
2019-04-21 09:34:17 +00:00
|
|
|
echo "${SUCCESS}"
|
2019-04-19 17:24:30 +00:00
|
|
|
|
2019-04-20 14:26:16 +00:00
|
|
|
trap exit 1 EXIT
|
2019-04-20 19:09:36 +00:00
|
|
|
cd "${TESTDIR}" || exit
|
2019-04-20 14:26:16 +00:00
|
|
|
|
2019-05-16 09:23:27 +00:00
|
|
|
echo "Test if $JSONSHFILE exists ..."
|
2020-06-01 13:04:37 +00:00
|
|
|
[ ! -x "$JSONSHFILE" ] && { echo "${NOSUCCESS} json.sh not found"; exit 1; }
|
2019-05-16 09:23:27 +00:00
|
|
|
|
|
|
|
echo "Test Sourcing of bashbot.sh ..."
|
2019-04-20 14:26:16 +00:00
|
|
|
# shellcheck source=./bashbot.sh
|
2019-04-20 19:09:36 +00:00
|
|
|
source "${TESTDIR}/bashbot.sh" source
|
2019-05-26 19:25:01 +00:00
|
|
|
echo "Test Sourcing of commands.sh ..."
|
2019-05-13 09:24:42 +00:00
|
|
|
source "${TESTDIR}/commands.sh" source
|
|
|
|
|
2019-04-20 14:26:16 +00:00
|
|
|
trap '' EXIT
|
2019-04-20 19:09:36 +00:00
|
|
|
cd "${DIRME}" || exit 1
|
2019-04-21 09:34:17 +00:00
|
|
|
echo "${SUCCESS}"
|
2019-04-20 19:09:36 +00:00
|
|
|
|
2020-06-01 13:04:37 +00:00
|
|
|
echo "Test bashbot.sh stat"
|
2020-06-01 11:44:30 +00:00
|
|
|
cp "${REFDIR}/count.test" "${TESTDIR}/count.jssh"
|
2020-06-01 13:04:37 +00:00
|
|
|
"${TESTDIR}/bashbot.sh" stats >"${TESTDIR}/stats.out"
|
|
|
|
diff -q "${TESTDIR}/stats.out" "${REFDIR}/stats.out" >>"${LOGFILE}" || { echo "${NOSUCCESS} Fail diff stats output!"; FAIL="1"; }
|