1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/bin/sh
set -x
BASEDIR=/var/lib/snac2
HOSTNAME=localhost
USERNAME=tester
TESTFAILED=0
# add a user
printf '%s\n' "$USERNAME" | runuser -u debian-snac -- snac adduser "$BASEDIR" >adduser.log
PASSWORD=$(grep "User password is" adduser.log | sed 's/.* //')
test $? -eq 0 || TESTFAILED=1
# test http service proxied through apache
# Main web access point
wget --output-document social.html "http://$HOSTNAME/social" 2>&1
cat social.html
grep --quiet "@$USERNAME@$HOSTNAME" social.html
test $? -eq 0 || TESTFAILED=1
rm social.html
# Login as user
wget --output-document admin.html --user "$USERNAME" --password "$PASSWORD" \
"http://$HOSTNAME/social/$USERNAME/admin" 2>&1
cat admin.html
grep --quiet "@$USERNAME@$HOSTNAME" admin.html
test $? -eq 0 || TESTFAILED=1
rm admin.html
# WebFinger
wget --output-document webfinger.json "http://$HOSTNAME/.well-known/webfinger?resource=acct%3A$USERNAME%40$HOSTNAME" 2>&1
cat webfinger.json
grep --quiet "acct:$USERNAME@$HOSTNAME" webfinger.json
test $? -eq 0 || TESTFAILED=1
rm webfinger.json
# NodeInfo
wget --output-document nodeinfo.json "http://$HOSTNAME/.well-known/nodeinfo" 2>&1
cat nodeinfo.json
grep --quiet nodeinfo nodeinfo.json
test $? -eq 0 || TESTFAILED=1
rm nodeinfo.json
# Mastodon API
wget --output-document instance.json "http://$HOSTNAME/api/v1/instance" 2>&1
cat instance.json
grep --quiet "$HOSTNAME" instance.json
test $? -eq 0 || TESTFAILED=1
rm instance.json
# check results
if [ $TESTFAILED -eq 1 ]; then
echo "One or more test steps failed."
exit 1
else
echo "All test steps passed."
fi
|